private void Driver_AddBtn_Click_1(object sender, EventArgs e) { Validation_Class v = new Validation_Class(); if (Bus_ID_CB.Text == "") { MessageBox.Show("Please Enter a Bus ID"); return; } if (v.Check_Name(DriverName_Insert_Texbox.Text) && v.PhoneNumber(DriverPhone_Texbox.Text) && v.IsPositiveNumber(DriverSalary_Insert_Texbox.Text)) { if (v.NationalID(DriverNID_Insert_Texbox.Text) && v.Two_Dates(BD_DatePicker.Value, DateTime.Today.AddYears(-18))) { if (v.Is_Empty(DriverAdress_Insert_Texbox.Text) && v.IsPositiveNumber(DriverLicence_Number_Insert_Texbox.Text) && v.Check_Name(Driver_Traffic.Text) && v.Two_Dates(DateTime.Today, Driver_Licence_EndDate.Value)) { string name = DriverName_Insert_Texbox.Text; string phone = DriverPhone_Texbox.Text; int salary = Convert.ToInt32(DriverSalary_Insert_Texbox.Text); string blood = Blood_CBox.Text; string NID = DriverNID_Insert_Texbox.Text; DateTime BD = BD_DatePicker.Value; string address = DriverAdress_Insert_Texbox.Text; string gender = Gender_CBox.Text; string DrivingLicence = DriverLicence_Number_Insert_Texbox.Text; string trafficDepartment = Driver_Traffic.Text; DateTime RDate = Driver_Licence_EndDate.Value; int result = controller.Insert_Driver(name, BD, phone, address, salary, NID, gender, blood, trafficDepartment, DrivingLicence, RDate, Convert.ToInt32(Bus_ID_CB.Text)); if (result == 0) { Message_Form message = new Message_Form(); message.Title("There was an Error inserting the Driver"); message.Title_Color(Color.Red); message.Show(); } else { Message_Form message = new Message_Form(); Object id = controller.Last_Driver_ID(); message.Title("Driver was added with ID = " + id.ToString()); message.Show(); DataTable d = controller.Get_Non_Driven_Buses(); Bus_ID_CB.DataSource = d; Bus_ID_CB.DisplayMember = "Bus_ID"; Bus_ID_CB.ValueMember = "Bus_ID"; Bus_ID_CB.Refresh(); } } } } }
public void Refreshing() { DataTable d = controller.Get_Non_Driven_Buses(); Bus_ID_CB.DataSource = d; Bus_ID_CB.DisplayMember = "Bus_ID"; Bus_ID_CB.ValueMember = "Bus_ID"; Bus_ID_CB.Refresh(); if (d == null) { Bus_ID_CB.Text = ""; } else { Bus_ID_CB.Text = d.Rows[0][0].ToString(); } }
private void Search_btn_Click(object sender, EventArgs e) { Validation_Class v = new Validation_Class(); if (v.PhoneNumber(DPhone_Search_Texbox.Text)) { DataTable result = controller.Search_Driver(DPhone_Search_Texbox.Text); if (result == null) { NotFound(); } else { Found(); DataTable d = controller.Get_Non_Driven_Buses(); Bus_ID_CB.DataSource = d; Bus_ID_CB.DisplayMember = "Bus_ID"; Bus_ID_CB.ValueMember = "Bus_ID"; Bus_ID_CB.Refresh(); if (d == null) { Bus_ID_CB.Text = ""; } else { Bus_ID_CB.Text = d.Rows[0][0].ToString(); } DName_Update_Texbox.Text = result.Rows[0][1].ToString(); BD_DatePicker.Value = Convert.ToDateTime(result.Rows[0][2].ToString()); DriverPhone_Update_Texbox.Text = result.Rows[0][3].ToString(); DAdress_Update_Texbox.Text = result.Rows[0][4].ToString(); DSalary_Update_Texbox.Text = result.Rows[0][5].ToString(); DID_Update_Texbox.Text = result.Rows[0][6].ToString(); Blood_CBox.Text = result.Rows[0][9].ToString(); Driver_Traffic_Update_TB.Text = result.Rows[0][10].ToString(); DriverLicence_Number_Update_Texbox.Text = result.Rows[0][11].ToString(); Driver_Licence_EndDate.Value = Convert.ToDateTime(result.Rows[0][12].ToString()); OldPhone = DriverPhone_Update_Texbox.Text; } } }
private void Driver_UpdateBtn_Click(object sender, EventArgs e) { Validation_Class v = new Validation_Class(); int busid = -1; if (Change_CheckBox.Checked) { if (Bus_ID_CB.Text == "") { Message_Form message = new Message_Form(); message.Title("Error: The Driver does not have a Bus ID"); message.Title_Color(Color.Red); message.Show(); return; } else if (v.IsPositiveNumber(Bus_ID_CB.Text)) { busid = Convert.ToInt32(Bus_ID_CB.Text); } else { Message_Form message = new Message_Form(); message.Title("Please Enter a Positive Bus ID"); message.Title_Color(Color.Red); message.Show(); return; } } if (v.Check_Name(DName_Update_Texbox.Text) && v.PhoneNumber(DriverPhone_Update_Texbox.Text) && v.IsPositiveNumber(DSalary_Update_Texbox.Text)) { if (v.NationalID(DID_Update_Texbox.Text) && v.Two_Dates(BD_DatePicker.Value, DateTime.Today.AddYears(-18))) { if (v.Is_Empty(DAdress_Update_Texbox.Text) && v.IsPositiveNumber(DriverLicence_Number_Update_Texbox.Text) && v.Check_Name(Driver_Traffic_Update_TB.Text) && v.Two_Dates(DateTime.Today, Driver_Licence_EndDate.Value)) { string name = DName_Update_Texbox.Text; string phone = DriverPhone_Update_Texbox.Text; int salary = Convert.ToInt32(DSalary_Update_Texbox.Text); string blood = Blood_CBox.Text; string NID = DID_Update_Texbox.Text; DateTime BD = BD_DatePicker.Value; string address = DAdress_Update_Texbox.Text; string DrivingLicence = DriverLicence_Number_Update_Texbox.Text; string trafficDepartment = Driver_Traffic_Update_TB.Text; DateTime RDate = Driver_Licence_EndDate.Value; int resulut = controller.Update_Driver(name, BD, OldPhone, phone, address, salary, NID, blood, trafficDepartment, DrivingLicence, RDate, busid); if (resulut == 0) { Message_Form message = new Message_Form(); message.Title("There was an Error Updating this Driver"); message.Title_Color(Color.Red); message.Show(); } else { Message_Form message = new Message_Form(); message.Title("Driver was Updated Successfully"); message.Show(); DataTable d = controller.Get_Non_Driven_Buses(); Bus_ID_CB.DataSource = d; Bus_ID_CB.DisplayMember = "Bus_ID"; Bus_ID_CB.ValueMember = "Bus_ID"; Bus_ID_CB.Refresh(); if (d == null) { Bus_ID_CB.Text = ""; } else { Bus_ID_CB.Text = d.Rows[0][0].ToString(); } } } } } }