protected void Page_Load(object sender, EventArgs e) { objdriver = new clsDriver(); sCOM = new Common(); if (!Page.IsPostBack) { sSQL = objdriver.DispDataAll(); //To Fill Gridview sCOM.setGridView(GridView1, sSQL); } }
protected void Page_Load(object sender, EventArgs e) { objdriver = new clsDriver(); sCOM = new Common(); uname = (String)Session["uname"]; if (uname != null) { txtuname.Text = uname; } else { txtuname.Text = "travelagent"; } if (!Page.IsPostBack) { if (Request.QueryString["action"] == "add") { txtdcode.Text = sCOM.setAutoID("Driver", "DCode").ToString(); } else if (Request.QueryString["action"] == "edit") { if (Request.QueryString["ec"] != null) { string ec = (Request.QueryString["ec"].ToString()); txtdcode.Text = ec; objdriver = objdriver.GetData(ec); /*if (chkStatus.Checked == true) * { * objdriver.Status = "Active"; * } * else * { * objdriver.Status = "Inactive"; * }*/ txtuname.Text = objdriver.Username; txtdname.Text = objdriver.DriverName; txtmno.Text = objdriver.MobileNo.ToString(); txtresadd.Text = objdriver.ResidentAddress; txtlicno.Text = objdriver.LicenseNo.ToString(); txtlicexpdate.Text = objdriver.LicenseExpDate.ToString(); txtdphoto.Text = objdriver.DriverPhoto; drpstatus.Text = objdriver.Status; } } else { //Error Page } } }
public void UpdateData(clsDriver objdriver, string dcode) { cmd = new SqlCommand(); myDB = new DBHelper(); sSQL = "UPDATE Driver set Username=@Username,DriverName=@DriverName,MobileNo=@MobileNo,ResidentAddress=@ResidentAddress,LicenseNo=@LicenseNo,LicenseExpDate=@LicenseExpDate,DriverPhoto=@DriverPhoto,Status=@Status where Dcode=" + dcode; cmd.Parameters.AddWithValue("@Username", objdriver.Username); cmd.Parameters.AddWithValue("@DriverName", objdriver.DriverName); cmd.Parameters.AddWithValue("@MobileNo", objdriver.MobileNo); cmd.Parameters.AddWithValue("@ResidentAddress", objdriver.ResidentAddress); cmd.Parameters.AddWithValue("@LicenseNo", objdriver.LicenseNo); cmd.Parameters.AddWithValue("@LicenseExpDate", objdriver.LicenseExpDate); cmd.Parameters.AddWithValue("@DriverPhoto", objdriver.DriverPhoto); cmd.Parameters.AddWithValue("@Status", objdriver.Status); myDB.Execute(sSQL, cmd); }
public void InsertData(clsDriver objdriver) { cmd = new SqlCommand(); myDB = new DBHelper(); sSQL = "INSERT into Driver(Username,DriverName,MobileNo,ResidentAddress,LicenseNo,LicenseExpDate,DriverPhoto,Status)values (@Username,@DriverName,@MobileNo,@ResidentAddress,@LicenseNo,@LicenseExpDate,@DriverPhoto,@Status)"; cmd.Parameters.AddWithValue("@Username", objdriver.Username); cmd.Parameters.AddWithValue("@DriverName", objdriver.DriverName); cmd.Parameters.AddWithValue("@MobileNo", objdriver.MobileNo); cmd.Parameters.AddWithValue("@ResidentAddress", objdriver.ResidentAddress); cmd.Parameters.AddWithValue("@LicenseNo", objdriver.LicenseNo); cmd.Parameters.AddWithValue("@LicenseExpDate", objdriver.LicenseExpDate); cmd.Parameters.AddWithValue("@DriverPhoto", objdriver.DriverPhoto); cmd.Parameters.AddWithValue("@Status", objdriver.Status); myDB.Execute(sSQL, cmd); }
protected void btnsave_Click(object sender, EventArgs e) { //url = "http://www.mettawalfare.somee.com/"; objdriver = new clsDriver(); if ((FileUpload1.HasFile)) { if ((CheckFileType(FileUpload1.FileName))) { filePath = "~/Drivers/" + FileUpload1.FileName; FileUpload1.SaveAs(MapPath(filePath)); txtdphoto.Text = filePath; //Image2.ImageUrl = filePath; } } try { //objdriver.Dcode= Convert.ToInt32(txtdcode.Text); objdriver.Username = txtuname.Text; objdriver.DriverName = txtdname.Text; objdriver.MobileNo = txtmno.Text; objdriver.ResidentAddress = txtresadd.Text; objdriver.LicenseNo = txtlicno.Text; objdriver.LicenseExpDate = Convert.ToDateTime(txtlicexpdate.Text); objdriver.DriverPhoto = txtdphoto.Text; objdriver.Status = drpstatus.Text; if (Request.QueryString["action"] == "add") { objdriver.InsertData(objdriver); } else if (Request.QueryString["action"] == "edit") { objdriver.UpdateData(objdriver, txtdcode.Text); } } catch (Exception x) { } }
public clsDriver GetData(string dcode) { clsDriver objdriver; myDB = new DBHelper(); objdriver = new clsDriver(); sSQL = objdriver.DispDataCode(dcode); SqlDataReader sDr = myDB.GetFromReader(sSQL); sDr.Read(); if (sDr.HasRows) { objdriver.Username = sDr["Username"].ToString(); objdriver.MobileNo = sDr["MobileNo"].ToString(); objdriver.DriverName = sDr["DriverName"].ToString(); objdriver.ResidentAddress = sDr["ResidentAddress"].ToString(); objdriver.LicenseNo = sDr["LicenseNo"].ToString(); objdriver.LicenseExpDate = Convert.ToDateTime(sDr["LicenseExpDate"].ToString()); objdriver.DriverPhoto = sDr["DriverPhoto"].ToString(); objdriver.Status = sDr["Status"].ToString(); } return(objdriver); }
protected void cmdDelete_Click(object sender, EventArgs e) { clsDriver DB = new clsDriver(); try { if (txtDriverNo.Text == null) { lblResults.Text = "Please enter the driver number"; return; } if (txtFirstName.Text == null) { lblResults.Text = "Enter the first name"; return; } if (txtLastName.Text == null) { lblResults.Text = "Enter the last name"; return; } if (txtPlaceOfIssue.Text == null) { lblResults.Text = "Enter the last name"; return; } if (dtLicenseRenewalDate.GetType() != typeof(DateTime)) { lblResults.Text = "Enter a valid license renewal date"; return; } if (dtEmploymentDate.GetType() != typeof(DateTime)) { lblResults.Text = "Enter a valid license employment date"; return; } if (dtLicenseDate.GetType() != typeof(DateTime)) { lblResults.Text = "Enter a valid license issue date"; return; } if (cboDept.GetType() != typeof(string)) { lblResults.Text = "Select a valid department"; return; } if (txtJobTitle.GetType() != typeof(string)) { lblResults.Text = "Select a valid JobTitle"; return; } if (txtLicenseNo.GetType() != typeof(string)) { lblResults.Text = "Enter a valid license number"; return; } if (txtLicenseType.GetType() != typeof(string)) { lblResults.Text = "Enter a valid license type"; return; } if (txtLicenseValidity.GetType() != typeof(string)) { lblResults.Text = "Enter a valid license validity"; return; } if (cboEducation.GetType() != typeof(string)) { lblResults.Text = "Select a valid education"; return; } if (txtNoofChildren.GetType() != typeof(int)) { txtNoofChildren.Text = "0"; } int reccount = 0; reccount = DB.FindKount(txtDriverNo.Text); if (reccount == 0) { lblResults.Text = "Record does not exist!!!"; return; } DB.Delete_rec(txtDriverNo.Text); // Fill the DataSet. DataSet ds = new DataSet(); ds = DB.FindTable(); //adapter.Fill(ds, "tb_Customer"); // Perform the binding. GridView1.DataSource = ds; GridView1.DataBind(); lblResults.Text = "Operation successful"; txtDriverNo.Text = ""; txtFirstName.Text = ""; txtLastName.Text = ""; txtJobTitle.Text = ""; cboDept.Text = ""; txtPostalAddress.Text = ""; txtResidAddress.Text = ""; cboMaritalStatus.Text = ""; txtTelephoneNo.Text = ""; txtSpouseName.Text = ""; txtNoofChildren.Text = "0"; txtHomeTown.Text = ""; cboEducation.Text = ""; txtLicenseType.Text = ""; txtLicenseNo.Text = ""; txtPlaceOfIssue.Text = ""; txtLicenseValidity.Text = ""; cboEmpStatus.Text = ""; return; } catch (FormatException err) { EventLog log = new EventLog(); log.Source = "Milorry Transport Frontend"; log.WriteEntry(err.Message, EventLogEntryType.Error); } }
protected void Page_Load(object sender, EventArgs e) { objbooking = new clsBooking(); objcarmaster = new clsCarMaster(); objcustomer = new clsCustomer(); objdriver = new clsDriver(); sCOM = new Common(); //txtbdate.Text = .ToDateTime.now(); //To fill Dropdownlist /* uname = (String)Session["uname"]; * if (uname != null) * { * txtdname.Text = uname; * } * else * { * txtdname.Text = "travelagent"; * }*/ if (!Page.IsPostBack) { sSQL = objcarmaster.DispDataAll(); sCOM.setDropDownList(drpcarcode, sSQL, "CarName", "CarCode"); sSQL = objcustomer.DispDataAll(); sCOM.setDropDownList(drpcustcode, sSQL, "CustName", "CustCode"); sSQL = objdriver.DispDataAll(); sCOM.setDropDownList(drpdrcode, sSQL, "DriverName", "Dcode"); if (Request.QueryString["action"] == "add") { txtbdate.Text = DateTime.Now.Date.ToString(); txtbcode.Text = sCOM.setAutoID("Booking", "BookingCode").ToString(); } else if (Request.QueryString["action"] == "edit") { if (Request.QueryString["ec"] != null) { string ec = (Request.QueryString["ec"].ToString()); txtbcode.Text = ec; objbooking = objbooking.GetData(ec); /*if (chkStatus.Checked == true) * { * objdriver.Status = "Active"; * } * else * { * objdriver.Status = "Inactive"; * }*/ txtpckdate.Text = objbooking.PickupDate.ToString(); txtdrpdate.Text = objbooking.DropDate.ToString(); drpcustcode.Text = objbooking.CustCode.ToString(); drpcarcode.Text = objbooking.CarCode.ToString(); drpdrcode.Text = objbooking.DriverCode.ToString(); drppassengers.Text = objbooking.Passengers.ToString(); txtpckaddress.Text = objbooking.PickupAddress; txtdraddress.Text = objbooking.DropAddress; txtremark.Text = objbooking.Remark; txtbdate.Text = objbooking.BookingDate.ToString(); txtfare.Text = objbooking.Fare.ToString(); drpstatus.Text = objbooking.Status; } } else { //Error Page } } }