You are on page 1of 27

AYUBO DRIVES SYSTEM CODING WITH INTERFACE

DESIGNS

1. Login Interface

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace ayubo_drive
{
public partial class frm_Login : Form
{
SqlConnection con = new SqlConnection("Data Source=LAPTOP-
MINHAJ;Initial Catalog=ayubo_drive;Integrated Security=True");

string User, Pass;


public frm_Login()
{
InitializeComponent();
}

private void btn_login_Click(object sender, EventArgs e)


{
User = txt_username.Text;
Pass = txt_password.Text;

if(User=="admin" && Pass=="1234")


{
MessageBox.Show("welcome to ayubo drives", "Login Success",
MessageBoxButtons.OK, MessageBoxIcon.Information);

frm_home fh = new frm_home();


fh.Show();
this.Hide();
}
else
{
MessageBox.Show("invalid username or password", "Login
failed", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);

txt_username.Clear();
txt_password.Clear();
txt_username.Focus();

}
}

private void btnExit_Click(object sender, EventArgs e)


{
Application.Exit();
}
}
}
2. Home Interface

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ayubo_drive
{
public partial class frm_home : Form
{
public frm_home()
{
InitializeComponent();
}

private void btn_logout_Click(object sender, EventArgs e)


{
DialogResult ans = MessageBox.Show("Do you want to LOGOUT from
your system ? ", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (ans == DialogResult.Yes)
{
Application.Exit();
}
}

private void btn_vehicle_Click(object sender, EventArgs e)


{
frm_vehicle fv = new frm_vehicle();
this.Hide();
fv.Show();
}

private void btn_package_Click(object sender, EventArgs e)


{
frm_package fp = new frm_package();
this.Hide();
fp.Show();
}

private void btn_rent_cal_Click(object sender, EventArgs e)


{
frm_rent_calculation fr = new frm_rent_calculation();
this.Hide();
fr.Show();
}

private void btn_daytour_Click(object sender, EventArgs e)


{
frm_day_tour fd = new frm_day_tour();
this.Hide();
fd.Show();
}

private void btn_longtour_cal_Click(object sender, EventArgs e)


{
frm_long_tour fl = new frm_long_tour();
this.Hide();
fl.Show();
}
}
}

3. Vehicle Details Interface

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace ayubo_drive
{
public partial class frm_vehicle : Form
{
SqlConnection con = new SqlConnection("Data Source=LAPTOP-
MINHAJ;Initial Catalog=ayubo_drive;Integrated Security=True");

public frm_vehicle()
{
InitializeComponent();
FillComboBox();
}

private void FillComboBox()


{
SqlDataAdapter da = new SqlDataAdapter("select reg_no from
vehicle", con);
DataTable dt = new DataTable();
da.Fill(dt);
cb_regno.DataSource = dt;
cb_regno.DisplayMember = "reg_no";
cb_regno.ValueMember = "reg_no";
}

private void clear()


{
cb_regno.Text = "";
txt_dayrate.Clear();
txt_driverrate.Clear();
txt_monthrate.Clear();
txt_v_model.Clear();
txt_v_type.Clear();
txt_weekrate.Clear();
}
private void btn_search_Click(object sender, EventArgs e)
{
con.Open();
string sqlsearch;
sqlsearch = "select * from vehicle Where Reg_no='" +
cb_regno.Text + "'";
SqlCommand cmd = new SqlCommand(sqlsearch, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
cb_regno.Text = dr["reg_no"].ToString();
txt_v_type.Text = dr["v_type"].ToString();
txt_v_model.Text = dr["v_model"].ToString();
txt_dayrate.Text = dr["day_rate"].ToString();
txt_weekrate.Text = dr["week_rate"].ToString();
txt_monthrate.Text = dr["month_rate"].ToString();
txt_driverrate.Text = dr["driver_rate"].ToString();
}
else
{
MessageBox.Show("Record Not Found", "",
MessageBoxButtons.OK, MessageBoxIcon.Error);
cb_regno.Text="";
cb_regno.Focus();
}
con.Close();
}

private void btn_home_Click(object sender, EventArgs e)


{
frm_home fh = new frm_home();
fh.Show();
this.Hide();

private void frm_vehicle_Load(object sender, EventArgs e)


{
// TODO: This line of code loads data into the
'ayubo_driveDataSet.vehicle' table. You can move, or remove it, as needed.
this.vehicleTableAdapter.Fill(this.ayubo_driveDataSet.vehicle);

private void btn_clear_Click(object sender, EventArgs e)


{
clear();
}
private void btn_add_Click(object sender, EventArgs e)
{
string sqlAdd;
con.Open();
sqlAdd = "insert into vehicle (reg_no, v_type,
v_model,day_rate, week_rate, month_rate, driver_rate) Values('"
+cb_regno.Text + "','" + txt_v_type.Text + "','" + txt_v_model.Text + "','"
+ txt_dayrate.Text + "','" +txt_weekrate.Text + "','" + txt_monthrate.Text
+ "','" + txt_driverrate.Text + "')";
SqlCommand cmd = new SqlCommand(sqlAdd, con);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Vehicle Details Added", "Record Added
Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
clear();
}

private void btn_update_Click(object sender, EventArgs e)


{
con.Open();
string sqlUpdate;
sqlUpdate = "UPDATE vehicle set v_type='" + txt_v_type.Text +
"',v_model = '" + txt_v_model.Text + "',day_rate='" + txt_dayrate.Text +
"',week_rate='" + txt_weekrate.Text + "',month_rate='" + txt_monthrate.Text
+ "',driver_rate='" + txt_driverrate.Text + "' where reg_no =
'"+cb_regno.Text+"'";
SqlCommand cmd = new SqlCommand(sqlUpdate, con);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Vehicle Details Updated", "Updation
Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
clear();
}

private void btn_delete_Click(object sender, EventArgs e)


{
con.Open();
string sqlDelete;
sqlDelete = "delete from vehicle Where reg_no='" +
cb_regno.Text + "'";
SqlCommand cmd = new SqlCommand(sqlDelete, con);
cmd.ExecuteNonQuery();
DialogResult ans = MessageBox.Show("Do you want to Delete This
Record ? ", "Conformation For Deleting", MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
if (ans == DialogResult.Yes)
{
MessageBox.Show("Record Deleted", "", MessageBoxButtons.OK,
MessageBoxIcon.Information);
clear();
}
con.Close();
}
}
}

4. Package Details Interface


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace ayubo_drive
{
public partial class frm_package : Form
{
SqlConnection con = new SqlConnection("Data Source=LAPTOP-
MINHAJ;Initial Catalog=ayubo_drive;Integrated Security=True");

public frm_package()
{
InitializeComponent();
FillComboBox();
}

public void FillComboBox()


{
SqlDataAdapter da = new SqlDataAdapter("select package_id from
package", con);
DataTable dt = new DataTable();
da.Fill(dt);
cb_p_id.DataSource = dt;
cb_p_id.DisplayMember = "package_id";
cb_p_id.ValueMember = "package_id";
}

public void Clear()


{
cb_p_id.Text = "";
txt_d_nightrate.Clear();
txt_e_hour_rate.Clear();
txt_e_km_rate.Clear();
txt_max_hour.Clear();
txt_max_km.Clear();
txt_packagerate.Clear();
txt_p_name.Clear();
txt_v_type.Clear();
txt_v_nightrate.Clear();
}

private void btn_home_Click(object sender, EventArgs e)


{
frm_home fh = new frm_home();
fh.Show();
this.Hide();
}

private void frm_package_Load(object sender, EventArgs e)


{
// TODO: This line of code loads data into the
'ayubo_driveDataSet1.package' table. You can move, or remove it, as needed.
this.packageTableAdapter.Fill(this.ayubo_driveDataSet1.package);

private void btn_search_Click(object sender, EventArgs e)


{
con.Open();
string sqlSearch;
sqlSearch = "select * from package where package_id='" +
cb_p_id.Text + "'";
SqlCommand cmd = new SqlCommand(sqlSearch, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
txt_p_name.Text = dr["package_name"].ToString();
txt_v_type.Text = dr["v_type"].ToString();
txt_max_km.Text = dr["max_km"].ToString();
txt_max_hour.Text = dr["max_hour"].ToString();
txt_e_km_rate.Text = dr["ex_km_rate"].ToString();
txt_e_hour_rate.Text = dr["ex_hour_rate"].ToString();
txt_packagerate.Text = dr["package_rate"].ToString();
txt_v_nightrate.Text = dr["vehicle_nrate"].ToString();
txt_d_nightrate.Text = dr["driver_nrate"].ToString();
}
else
{
MessageBox.Show("Record Not Found", "", MessageBoxButtons.OK,
MessageBoxIcon.Error);
cb_p_id.Text = "";
cb_p_id.Focus();
}
con.Close();
}

private void btn_clear_Click(object sender, EventArgs e)


{
Clear();
}

private void btn_add_Click(object sender, EventArgs e)


{
con.Open();
string sqladd;
sqladd = "insert into package
(package_id,package_name,v_type,max_km,max_hour,ex_km_rate,ex_hour_rate,package
_rate,vehicle_nrate,driver_nrate) Values('" + cb_p_id.Text + "','" +
txt_p_name.Text + "','" + txt_v_type.Text + "','" + txt_max_km.Text + "','" +
txt_max_hour.Text + "','" + txt_e_km_rate.Text + "','" + txt_e_hour_rate.Text +
"','" + txt_packagerate.Text + "','" + txt_v_nightrate.Text + "','" +
txt_d_nightrate.Text + "' )";
SqlCommand cmd = new SqlCommand(sqladd, con);
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Package Details y Added", "Record Added Success",
MessageBoxButtons.OK, MessageBoxIcon.Information);
Clear();
}

private void btn_update_Click(object sender, EventArgs e)


{
try
{
con.Open();
string sqlupdate;
sqlupdate = "update package set
package_name='"+txt_p_name.Text+"',v_type='"+txt_v_type.Text+"',max_km='"+txt_m
ax_km.Text+"',max_hour='"+txt_max_hour.Text+"',ex_km_rate='"+txt_e_km_rate.Text
+ "',ex_hour_rate='"+txt_e_hour_rate.Text+
"',package_rate='"+txt_packagerate.Text+
"',vehicle_nrate='"+txt_v_nightrate.Text+
"',driver_nrate='"+txt_d_nightrate.Text+"' where package_id='" + cb_p_id.Text +
"'";
SqlCommand cmd = new SqlCommand(sqlupdate, con);
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con.Close();
}

MessageBox.Show("Package Details were Updated", "",


MessageBoxButtons.OK, MessageBoxIcon.Information);
Clear();
}

private void btn_delete_Click(object sender, EventArgs e)


{
con.Open();
string sqldelete;
sqldelete = "delete from package where package_id='" + cb_p_id.Text
+ "'";
SqlCommand cmd = new SqlCommand(sqldelete, con);
cmd.ExecuteNonQuery();
DialogResult ans = MessageBox.Show("Do you want to Delete This
Record ? ", "Conformation For Deleting", MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
if (ans == DialogResult.Yes)
{
MessageBox.Show("Record Deleted", "", MessageBoxButtons.OK,
MessageBoxIcon.Information);
Clear();
}
con.Close();
}
}
}

5. Rent Calculation Interface

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace ayubo_drive
{
public partial class frm_rent_calculation : Form
{
SqlConnection con = new SqlConnection("Data Source=LAPTOP-
MINHAJ;Initial Catalog=ayubo_drive;Integrated Security=True");

int tot_days, month, week, day;


public frm_rent_calculation()
{
InitializeComponent();
FillComboBox();
}
public void Clear()
{
txt_dayrate.Clear();
txt_monthrate.Clear();
txt_weekrate.Clear();
txt_t_amount.Clear();
txt_days.Clear();
txt_weeks.Clear();
txt_months.Clear();
txt_tdays.Clear();
txt_driver_rate.Clear();
cb_reg_no.Text = "";
}
public void FillComboBox()
{
SqlDataAdapter da = new SqlDataAdapter("select reg_no from
vehicle", con);
DataTable dt = new DataTable();
da.Fill(dt);
cb_reg_no.DataSource = dt;
cb_reg_no.DisplayMember = "reg_no";
cb_reg_no.ValueMember = "reg_no";
}
private void btn_home_Click(object sender, EventArgs e)
{
frm_home fh = new frm_home();
fh.Show();
this.Hide();

}
private void btn_t_amount_Click(object sender, EventArgs e)
{
double amount;
double dayrate, weekrate, monthrate, driverrate;
dayrate = double.Parse(txt_dayrate.Text);
weekrate = double.Parse(txt_weekrate.Text);
monthrate = double.Parse(txt_monthrate.Text);
driverrate = double.Parse(txt_driver_rate.Text);
if (chk_withdriver.Checked == true)
{
amount = (dayrate * day + weekrate * week + monthrate *
month + driverrate * tot_days);
}
else
{
amount = (dayrate * day + weekrate * week + monthrate *
month);
}
txt_t_amount.Text = amount.ToString();
}

private void btn_total_days_Click(object sender, EventArgs e)


{
DateTime startdate, enddate;
startdate = DateTime.Parse(dtp_sdate.Text);
enddate = DateTime.Parse(dtp_edate.Text);

TimeSpan gap;
gap = enddate - startdate;
txt_tdays.Text = gap.ToString();

double totaldays;
totaldays = gap.Days;
txt_tdays.Text = totaldays.ToString();

tot_days = int.Parse(txt_tdays.Text);

//month
month = tot_days / 30;
txt_months.Text = month.ToString();
int remainder = tot_days % 30;

//week
week = remainder / 7;
txt_weeks.Text = week.ToString();

//days
day = remainder % 7;
txt_days.Text = day.ToString();
}

private void btn_clear_Click(object sender, EventArgs e)


{
Clear();
}

private void btn_search_Click(object sender, EventArgs e)


{
con.Open();
string sqlsearch;
sqlsearch = "select * from vehicle Where reg_no='" +
cb_reg_no.Text + "'";
SqlCommand cmd = new SqlCommand(sqlsearch, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
txt_dayrate.Text = dr["day_rate"].ToString();
txt_weekrate.Text = dr["week_rate"].ToString();
txt_monthrate.Text = dr["month_rate"].ToString();
txt_driver_rate.Text = dr["driver_rate"].ToString();

}
con.Close();
}
}
}
6. Day Tour Interface

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace ayubo_drive
{
public partial class frm_day_tour : Form
{
SqlConnection con = new SqlConnection("Data Source=LAPTOP-
MINHAJ;Initial Catalog=ayubo_drive;Integrated Security=True");

double extrakmcharge, extrahourcharge;

public frm_day_tour()
{
InitializeComponent();
FillComboBox();
}

public void FillComboBox()


{
SqlDataAdapter da = new SqlDataAdapter("select package_id from
package", con);
DataTable dt = new DataTable();
da.Fill(dt);
cb_p_id.DataSource = dt;
cb_p_id.DisplayMember = "package_id";
cb_p_id.ValueMember = "package_id";
}

private void clear()


{
txt_ekm.Clear();
txt_extra_hours.Clear();
txt_extra_hour_charge.Clear();
txt_e_hour_rate.Clear();
txt_extra_km.Clear();
txt_extra_km_charge.Clear();
txt_e_km_rate.Clear();
txt_max_hour.Clear();
txt_max_km.Clear();
txt_no_of_hours.Clear();
txt_no_of_km.Clear();
txt_packagerate.Clear();
txt_package_name.Clear();
txt_skm.Clear();
txt_tot_cost.Clear();
cb_p_id.Text = "";
dtp_etime.Text = "";
dtp_stime.Text = "";
}

private void btn_home_Click(object sender, EventArgs e)


{
frm_home fh = new frm_home();
fh.Show();
this.Hide();
}

private void btn_clear_Click(object sender, EventArgs e)


{
clear();
}

private void btn_search_Click(object sender, EventArgs e)


{
con.Open();
string sqlsearch;
sqlsearch = "select * from package where package_id='" +
cb_p_id.Text + "'";
SqlCommand cmd = new SqlCommand(sqlsearch, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
txt_max_km.Text = dr["max_km"].ToString();
txt_max_hour.Text = dr["max_hour"].ToString();
txt_e_km_rate.Text = dr["ex_km_rate"].ToString();
txt_e_hour_rate.Text = dr["ex_hour_rate"].ToString();
txt_packagerate.Text = dr["package_rate"].ToString();
txt_package_name.Text = dr["package_name"].ToString();
}
else
{
MessageBox.Show("Record Not Found", "Not Found",
MessageBoxButtons.OK, MessageBoxIcon.Error);
cb_p_id.Text = "";
}
con.Close();
}

private void btn_cal_km_Click(object sender, EventArgs e)


{
double startkm, endkm;
startkm = double.Parse(txt_skm.Text);
endkm = double.Parse(txt_ekm.Text);

double Totalkm;
Totalkm = endkm - startkm;
txt_no_of_km.Text = Totalkm.ToString();

//finding extra km
double max_km, extra_km;
max_km = double.Parse(txt_max_km.Text);
if (Totalkm > max_km)
{
extra_km = (Totalkm - max_km);
}
else
{
extra_km = 0;
}
txt_extra_km.Text = extra_km.ToString();

//finding extrakm charges


double extra_kmrate, extra_km_charge;
extra_kmrate = double.Parse(txt_e_km_rate.Text);
extra_km_charge = (extra_kmrate * extra_km);
txt_extra_km_charge.Text = extra_km_charge.ToString();
}

private void btn_tot_cost_Click(object sender, EventArgs e)


{
double totalcost, packagerate;
packagerate = double.Parse(txt_packagerate.Text);
extrakmcharge = double.Parse(txt_extra_km_charge.Text);
extrahourcharge = double.Parse(txt_extra_hour_charge.Text);

totalcost = (packagerate + extrakmcharge + extrahourcharge);


txt_tot_cost.Text = totalcost.ToString();
}

private void btn_cal_hours_Click(object sender, EventArgs e)


{
DateTime starttime, endtime;
starttime = DateTime.Parse(dtp_stime.Text);
endtime = DateTime.Parse(dtp_etime.Text);

TimeSpan gap;
gap = endtime - starttime;
txt_no_of_hours.Text = gap.ToString();

double No_of_hours;
No_of_hours = gap.Hours;
txt_no_of_hours.Text = No_of_hours.ToString();

//finding the extra hours


double max_hour, extra_hours;
max_hour = double.Parse(txt_max_hour.Text);
if (No_of_hours > max_hour)
{
extra_hours = (No_of_hours - max_hour);
}
else
{
extra_hours = 0;
}
txt_extra_hours.Text = extra_hours.ToString();

//finding the extrahours charge


double extrahourrate, extrahourcharge;
extrahourrate = double.Parse(txt_e_hour_rate.Text);
extrahourcharge = (extrahourrate * extra_hours);
txt_extra_hour_charge.Text = extrahourcharge.ToString();
}
}
}
7. Long Tour Interface

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace ayubo_drive
{
public partial class frm_long_tour : Form
{
SqlConnection con = new SqlConnection("Data Source=LAPTOP-
MINHAJ;Initial Catalog=ayubo_drive;Integrated Security=True");

double NoofDays, extrakm;


public frm_long_tour()
{
InitializeComponent();
fillcombobox();
}
public void fillcombobox()
{
SqlDataAdapter da = new SqlDataAdapter("select package_id from
package", con);
DataTable dt = new DataTable();
da.Fill(dt);
cb_p_id.DataSource = dt;
cb_p_id.DisplayMember = "package_id";
cb_p_id.ValueMember = "package_id";
}

public void clear()


{
txt_base_charge.Clear();
txt_d_nightrate.Clear();
txt_ekm.Clear();
txt_extra_km.Clear();
txt_e_km_charge.Clear();
txt_e_km_rate.Clear();
txt_max_hour.Clear();
txt_max_km.Clear();
txt_no_of_Days.Clear();
txt_no_of_km.Clear();
txt_over_night_charge.Clear();
txt_packagerate.Clear();
txt_package_name.Clear();
txt_skm.Clear();
txt_tot_cost.Clear();
txt_v_nightrate.Clear();
cb_p_id.Text = "";
}

private void btn_home_Click(object sender, EventArgs e)


{
frm_home fh = new frm_home();
fh.Show();
this.Hide();
}

private void btn_clear_Click(object sender, EventArgs e)


{
clear();
}

private void btn_cal_km_Click(object sender, EventArgs e)


{
double startkm, endkm;

//no of km calculation
startkm = double.Parse(txt_skm.Text);
endkm = double.Parse(txt_ekm.Text);

double No_of_km;
No_of_km = endkm - startkm;
txt_no_of_km.Text = No_of_km.ToString();

//extra km calculation
double allowedkm, maxkm;
maxkm = double.Parse(txt_max_km.Text);
allowedkm = maxkm * NoofDays;

if (No_of_km > allowedkm)


{
extrakm = No_of_km - allowedkm;
}
else
{
extrakm = 0;
}
txt_extra_km.Text = extrakm.ToString();

}
private void btn_cal_days_Click(object sender, EventArgs e)
{
//no of days calculation
DateTime StartDay, EndDay;
StartDay = DateTime.Parse(dtp_sdate.Text);
EndDay = DateTime.Parse(dtp_edate.Text);

TimeSpan gap;
gap = EndDay - StartDay;
txt_no_of_Days.Text = gap.ToString();

NoofDays = gap.Days;
txt_no_of_Days.Text = NoofDays.ToString();
NoofDays = int.Parse(txt_no_of_Days.Text);
}

private void btn_search_Click(object sender, EventArgs e)


{
con.Open();
string sqlsearch;
sqlsearch = "select * from package where package_id='" +
cb_p_id.Text + "'";
SqlCommand cmd = new SqlCommand(sqlsearch, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
txt_max_km.Text = dr["max_km"].ToString();
txt_max_hour.Text = dr["max_hour"].ToString();
txt_e_km_rate.Text = dr["ex_km_rate"].ToString();
txt_packagerate.Text = dr["package_rate"].ToString();
txt_package_name.Text = dr["package_name"].ToString();
txt_v_nightrate.Text = dr["vehicle_nrate"].ToString();
txt_d_nightrate.Text = dr["driver_nrate"].ToString();
}
else
{
MessageBox.Show("Record Not Found", "",
MessageBoxButtons.OK, MessageBoxIcon.Error);
cb_p_id.Text = "";
}
con.Close();
}

private void btn_cal_total_Click(object sender, EventArgs e)


{
//calculate extra_km_charge
double extra_km_charge, extra_km_rate;

extra_km_rate = double.Parse(txt_e_km_rate.Text);
extra_km_charge = extrakm * extra_km_rate;

txt_e_km_charge.Text = extra_km_charge.ToString();

//calculate base hire charge


double package_rate, base_hire_charge;

package_rate = double.Parse(txt_packagerate.Text);
base_hire_charge = NoofDays * package_rate;

txt_base_charge.Text = base_hire_charge.ToString();

//calculate over night charges


double overnight_charge, driver_night_rate, vehicle_night_rate;

driver_night_rate = double.Parse(txt_d_nightrate.Text);
vehicle_night_rate = double.Parse(txt_v_nightrate.Text);

overnight_charge = (driver_night_rate + vehicle_night_rate) *


(NoofDays - 1);
txt_over_night_charge.Text = overnight_charge.ToString();

//calculate total cost


double Tot_amount;

Tot_amount = extra_km_charge + base_hire_charge +


overnight_charge;
txt_tot_cost.Text = Tot_amount.ToString();
}
}
}

You might also like