private void startd_ValueChanged(object sender, EventArgs e)
        {
            Validation_Class v = new Validation_Class();

            if (v.Two_Dates(startd.Value, endd.Value) && v.Two_Dates(DateTime.Today, startd.Value))
            {
                DataTable dt = controller.Search_Available_Rent_Buses(startd.Value, endd.Value);
                dataGridView1.DataSource = dt;
                dataGridView1.Refresh();
            }
            else
            {
                dataGridView1.DataSource = null;
                dataGridView1.Refresh();
            }
        }
        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();
                        }
                    }
                }
            }
        }
Exemple #3
0
        private void BUS_Insert_btn_Click(object sender, EventArgs e)
        {
            Validation_Class v = new Validation_Class();

            if (v.Is_Empty(EngineNo_TB.Text) && v.Check_Name(Manufacturer_TB.Text) && v.Check_Name(Model_TB.Text))
            {
                if (v.IsPositiveNumber(ModelYear_TB.Text))
                {
                    int modelYear = Convert.ToInt32(ModelYear_TB.Text);
                    if (modelYear < 2010 || modelYear > 2021)
                    {
                        Message_Form message = new Message_Form();
                        message.Title("Please Enter Model Year");
                        message.Title_Color(Color.Red);
                        message.Extra_Message("Between 2010 and 2021");
                        message.Extra_Message_Color(Color.Red);
                        message.Show();
                        return;
                    }

                    if (v.Two_Dates(DateTime.Today, RDate_Picker.Value) && v.Check_Name(Department_TB.Text) && v.Is_Empty(License_TB.Text))
                    {
                        string   engineNO   = EngineNo_TB.Text;
                        string   mac        = Manufacturer_TB.Text;
                        string   model      = Model_TB.Text;
                        DateTime Rdate      = RDate_Picker.Value;
                        string   department = Department_TB.Text;
                        string   type       = Type_CB.SelectedItem.ToString();
                        string   licnece    = License_TB.Text;
                        int      seats      = Convert.ToInt32(Seats_Numeric.Value);

                        int result = controller.Insert_Bus(modelYear, engineNO, mac, model, Rdate, department, licnece, type, seats);
                        if (result == 0)
                        {
                            Message_Form message = new Message_Form();
                            message.Title("There was an Error Inserting this Bus");
                            message.Title_Color(Color.Red);
                            message.Show();
                        }
                        else
                        {
                            Message_Form message = new Message_Form();
                            Object       id      = controller.Last_Bus_ID();
                            message.Title("Bus was added with ID = " + id.ToString());
                            message.Show();
                        }
                    }
                }
            }
        }
        private void Employee_UpdateBtn_Click(object sender, EventArgs e)
        {
            Validation_Class v = new Validation_Class();

            if (v.Check_Name(EName_Update_Texbox.Text) && v.IsPositiveNumber(ESalary_Update_Texbox.Text) && v.IsValidEmail(EEmail_Update_Texbox.Text))
            {
                if (EPass_Update_Texbox.Text.Length < 8)
                {
                    MessageBox.Show("PassWord cannot be less than 8 Characters");
                    return;
                }                                                                                                                             // It Should me before 18 years from today
                else if (v.NationalID(EID_Update_Texbox.Text) && v.Is_Empty(EAdress_Update_Texbox.Text) && v.Two_Dates(BD_DatePicker.Value, DateTime.Today.AddYears(-18)))
                {
                    string   name    = EName_Update_Texbox.Text;
                    string   email   = EEmail_Update_Texbox.Text;
                    string   pass    = v.Encrypt_PassWord(EPass_Update_Texbox.Text);
                    int      salary  = Convert.ToInt32(ESalary_Update_Texbox.Text);
                    string   NID     = EID_Update_Texbox.Text;
                    DateTime BD      = BD_DatePicker.Value;
                    string   address = EAdress_Update_Texbox.Text;
                    string   type    = Type_CBox.SelectedItem.ToString();

                    int result = controller.Update_Employee(name, salary, email, pass, type, NID, BD, address);
                    if (result == 0)
                    {
                        Message_Form message = new Message_Form();
                        message.Title("There was an Error Updating this Employee");
                        message.Title_Color(Color.Red);
                        message.Show();
                    }
                    else
                    {
                        Message_Form message = new Message_Form();
                        message.Title("The Employee is Updated Successfully");
                        message.Show();
                    }
                }
            }
        }
        private void Insert_btn_Click(object sender, EventArgs e)
        {
            if (busID.Text == "")
            {
                MessageBox.Show("Please Select a Bus ID");
                return;
            }
            Validation_Class v = new Validation_Class();

            DateTime startDate   = startd.Value;
            DateTime Enddate     = endd.Value;
            int      price       = Convert.ToInt32(Price.Value);
            string   Gender      = genderCombo.Text;
            string   Name        = name.Text;
            string   NID         = id.Text;
            string   Address     = address.Text;
            string   PhoneNumber = phonenum.Text;

            if (v.Check_Name(Name) && v.NationalID(NID) && v.Is_Empty(Address) && v.PhoneNumber(PhoneNumber) && v.Two_Dates(startDate, Enddate))
            {
                int BusID  = Convert.ToInt32(busID.Text);
                int result = controller.Insert_Rent_Contract(startDate, Enddate, price, Name, NID, Address, Gender, BusID, PhoneNumber);
                if (result == 0)
                {
                    MessageBox.Show("Error");
                }
                else
                {
                    MessageBox.Show("Inserted");
                }
                Date_ValueChanged(sender, e);
            }
        }
        private void Employee_AddBtn_Click(object sender, EventArgs e)
        {
            Validation_Class v = new Validation_Class();

            if (v.Check_Name(EmployeeName_Insert_Texbox.Text) && v.IsPositiveNumber(EmployeeSalary_Insert_Texbox.Text) && v.IsValidEmail(EmployeeEmail_Insert_Texbox.Text))
            {
                if (EPassword_TB.Text.Length < 8)
                {
                    MessageBox.Show("PassWord cannot be less than 8 Characters");
                    return;
                }                                                                                                                             // It Should me before 18 years from today
                else if (v.NationalID(EmployeeID_Insert_Texbox.Text) && v.Is_Empty(EmployeeAdress_Insert_Texbox.Text) && v.Two_Dates(BD_DatePicker.Value, DateTime.Today.AddYears(-18)))
                {
                    if (EPassword_TB.Text.Length < 8)
                    {
                        MessageBox.Show("PassWord cannot be less than 8 Characters");
                        return;
                    }
                    string   name   = EmployeeName_Insert_Texbox.Text;
                    int      salary = Convert.ToInt32(EmployeeSalary_Insert_Texbox.Text);
                    string   email  = EmployeeEmail_Insert_Texbox.Text;
                    string   pass   = v.Encrypt_PassWord(EPassword_TB.Text);
                    string   type   = Type_CBox.Text;
                    string   NID    = EmployeeID_Insert_Texbox.Text;
                    DateTime BOD    = BD_DatePicker.Value;
                    string   adress = EmployeeAdress_Insert_Texbox.Text;
                    string   gender = Gender_CBox.Text;
                    if (controller.Insert_Employee(name, salary, email, pass, type, NID, BOD, adress, gender) == 1)
                    {
                        Message_Form message = new Message_Form();
                        Object       id      = controller.Last_Emplopyee_ID();
                        message.Title("Employee was added with ID = " + id.ToString());
                        message.Show();
                    }
                    else
                    {
                        Message_Form message = new Message_Form();
                        message.Title("There was an Error inserting this Emoployee");
                        message.Title_Color(Color.Red);
                        message.Show();
                    }
                }
            }
        }
Exemple #7
0
        private void Insert_btn_Click(object sender, EventArgs e)
        {
            Validation_Class v = new Validation_Class();

            if (v.Check_Name(nametxt.Text) && v.NationalID(id.Text) && v.PhoneNumber(phonenum.Text) && v.Is_Empty(address.Text) && v.Two_Dates(DateTime.Today, startd.Value))
            {
                int       interval = Convert.ToInt32(controller.Find_Duration(packageCombo.Text).Rows[0][0]);
                DateTime  s        = startd.Value;
                DateTime  end      = s.AddDays(interval);
                DataTable Buses    = controller.Search_Bus_For_AD_Contract(s, end);

                if (Buses != null)
                {
                    int x = controller.Insert_Ad_Contract(s, end, nametxt.Text, id.Text, address.Text, genderCombo.Text, packageCombo.Text, phonenum.Text, Convert.ToInt32(Buses.Rows[0][0]));
                    if (x == 0)
                    {
                        MessageBox.Show("Error");
                    }
                    else
                    {
                        MessageBox.Show("Inserted");
                    }
                }
                else
                {
                    MessageBox.Show("No Available Buses With this Dates");
                }
            }
        }
Exemple #8
0
        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();
                            }
                        }
                    }
                }
            }
        }