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

            if (v.PhoneNumber(Passenger_PhoneNumber_textBox.Text))
            {
                DataTable P = controllerObj.Get_Passenger_id(Passenger_PhoneNumber_textBox.Text);
                if (P == null) //we need to store Passenger's information
                {
                    Passenger_Email_textBox.Visible   = true;
                    Passenger_Gender_comboBox.Visible = true;
                    label4.Visible      = true;
                    label5.Visible      = true;
                    label2.Visible      = true;
                    pictureBox4.Visible = true;
                    pictureBox2.Visible = true;
                    pictureBox3.Visible = true;
                    panel1.Visible      = true;
                    panel2.Visible      = true;
                    panel3.Visible      = true;
                    Passenger_Gender_comboBox.Visible = true;
                    Passenger_Name_textBox.Visible    = true;
                    Done_Button.Visible          = true;
                    Search_For_Passenger.Visible = false;

                    MessageBox.Show("It is the first time for that Passenger So Get his information first ");
                }
                else
                {
                    MessageBox.Show("We have already the information of that Passenger and reservation done succesfully ");
                    int result = controllerObj.Insert_Passenger_Trip((int)P.Rows[0][0], Trip_Id, Num_Of_Seats, Trip_Total_Price);
                }
            }
        }
Beispiel #2
0
        private void complaintadding_Click(object sender, EventArgs e)
        {
            Validation_Class v = new Validation_Class();

            if (pID.Text == "" || Tid.Text == "" || !v.Is_Empty(complaintdiscpribtion.Text))
            {
                MessageBox.Show("all values are required ");
            }
            else if (v.IsPositiveNumber(Tid.Text) && v.PhoneNumber(pID.Text))
            {
                DataTable passengerid = controllerObj.Get_Passenger_id(pID.Text);
                if (passengerid == null)
                {
                    MessageBox.Show("No passenger with this Phone number exists ");
                }
                else if (Convert.ToInt32(controllerObj.CheckTripID(Tid.Text)) == 0)
                {
                    MessageBox.Show("No trip with this ID exists ");
                }
                else if (Convert.ToInt32(controllerObj.PassengerinTrip(passengerid.Rows[0][0].ToString(), Tid.Text)) == 0)
                {
                    MessageBox.Show("This passenger is not in this Bus trip ");
                }
                else
                {
                    DataTable dt1      = controllerObj.DriverOfWeeklTrip(Tid.Text);
                    string    driverid = dt1.Rows[0][0].ToString();
                    int       res      = controllerObj.AddComplaint(Tid.Text, passengerid.Rows[0][0].ToString(), complaintdiscpribtion.Text, driverid);
                    if (res == 1)
                    {
                        MessageBox.Show("Complaint's added successfully !");
                    }
                }
            }
        }
Beispiel #3
0
        private void Done_Click(object sender, EventArgs e)
        {
            Validation_Class v = new Validation_Class();

            if (v.IsValidEmail(Email_textbox.Text) && v.Is_Empty(Password_textbox.Text))
            {
                DataTable employee = controllerObj.Get_Employee_byEmail(Email_textbox.Text);
                if (employee == null)
                {
                    MessageBox.Show("There is no Employee with the Provided Email");
                }
                else
                {
                    string pass = v.Decrypt_PassWord(employee.Rows[0][5].ToString());
                    if (pass == Password_textbox.Text)
                    {
                        string type = employee.Rows[0][11].ToString();

                        /*Customer Service
                         * Contract Administrator
                         * IT Administrator
                         * Receptionist*/
                        this.Hide();
                        if (type == "Contract Administrator")
                        {
                            ContractAdministrator _Administrator = new ContractAdministrator();
                            _Administrator.Show();
                        }
                        else if (type == "IT Administrator")
                        {
                            ITAdministrator t_Administrator = new ITAdministrator();
                            t_Administrator.Show();
                        }
                        else if (type == "Customer Service")
                        {
                            CS_Main_Functions CS = new CS_Main_Functions(this, Convert.ToInt32(employee.Rows[0][0]));
                            CS.Show();
                        }
                        else if (type == "Receptionist")
                        {
                            Inquiries_about_trips I = new Inquiries_about_trips(this);
                            I.Show();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Wrong Password");
                        Password_textbox.Text = "";
                    }
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Validation_Class v = new Validation_Class();

            if (v.Is_Empty(textBox1.Text))
            {
                if (Convert.ToInt32(controllerObj.CheckPromoCodeName(textBox1.Text)) == 0)
                {
                    MessageBox.Show("There is no promo code with this name !");
                }
                else
                {
                    int res = controllerObj.RemovePromoCode(textBox1.Text);
                    if (res == 1)
                    {
                        MessageBox.Show("Promo code is removed Successfully !");
                    }
                }
            }
        }
Beispiel #5
0
        private void confirmAddPromo_Click(object sender, EventArgs e)
        {
            Validation_Class v = new Validation_Class();

            if (v.Is_Empty(PC_name.Text) && v.IsPositiveNumber(WT_id.Text))
            {
                if (Convert.ToInt32(controllerObj.CheckPromoCodeName(PC_name.Text)) == 1)
                {
                    MessageBox.Show("This name is already taken");
                }
                else if (Convert.ToInt32(controllerObj.CheckWTID(WT_id.Text)) == 0)
                {
                    MessageBox.Show("Weekly trip  ID is invalid !");
                }
                else
                {
                    controllerObj.AddPromoCode(PC_name.Text, discount.Value.ToString(), LoggedinEmployee);
                    controllerObj.AddPromoToWT(PC_name.Text, WT_id.Text);
                    MessageBox.Show("Promo Code is added Successfully");
                }
            }
        }
        private void Done_Button_Click(object sender, EventArgs e)
        {
            Validation_Class v = new Validation_Class();

            if (v.Check_Name(Passenger_Name_textBox.Text) && v.PhoneNumber(Passenger_PhoneNumber_textBox.Text) /*v.IsValidEmail(Passenger_Email_textBox.Text) &&*/)
            {
                int result = controllerObj.Insert_Passenger(Passenger_Name_textBox.Text, Passenger_PhoneNumber_textBox.Text, Passenger_Email_textBox.Text, Passenger_Gender_comboBox.Text);
                if (result == 1)
                {
                    MessageBox.Show("Insertion done succesfully");
                    Passenger_Name_textBox.Text    = "";
                    Passenger_Email_textBox.Text   = "";
                    Passenger_Gender_comboBox.Text = "";
                    DataTable P = controllerObj.Get_Passenger_id(Passenger_PhoneNumber_textBox.Text);
                    result = controllerObj.Insert_Passenger_Trip((int)P.Rows[0][0], Trip_Id, Num_Of_Seats, Trip_Total_Price);
                    Passenger_PhoneNumber_textBox.Text = "";
                }
                else
                {
                    MessageBox.Show("Insertion Failed"); //shouldn't appear to the user
                }
            }
        }
        private void Search_Click(object sender, EventArgs e)
        {
            Validation_Class v = new Validation_Class();

            if (v.Is_Empty(location1) && v.Is_Empty(location2) && v.Is_Empty(Time_TimePicker.Text) && v.Two_Dates(DateTime.Today, Date_TimePicker.Value))
            {
                T = controllerObj.Check(location1, location2, Date_TimePicker.Value.DayOfWeek.ToString(), Time_TimePicker.Value.TimeOfDay, Date_TimePicker.Value);


                if (T != null)
                {
                    Trip_Price = (int)T.Rows[0][1];
                    ID_B       = (int)T.Rows[0][0];

                    //if The Bus Trip was Found, Then there will be passengers in this trip
                    Object    Seatsum = controllerObj.Count_Current_seats(ID_B);
                    DataTable Num     = controllerObj.Find_Num_Of_Seats_in_the_Bus(ID_B);
                    // check number of seats in this trip
                    if ((int)Num.Rows[0][0] - Convert.ToInt32(Seatsum) > Seats_Numeric.Value)
                    {
                        MessageBox.Show("There is an available trip ,You can reserve for Passenger now ");
                        //Calculate the total money the passenger should pay
                        Total_Price = Trip_Price * (int)Seats_Numeric.Value;
                        //check frist if the promo code valid for this trip or not
                        DataTable P = controllerObj.Check_Promo_Code_Validation(PromoCode_textBox.Text, ID_B);
                        Discount = (int)P.Rows[0][0];
                        if (P != null)
                        {
                            Total_Price = Total_Price - Convert.ToInt16(Total_Price * (Discount / 100.0));
                            MessageBox.Show("Promo Code is Applied succefully");
                        }
                        else if (PromoCode_textBox.Text != "")
                        {
                            MessageBox.Show("Promo Code is not valid for this trip");
                        }
                        MessageBox.Show("Total Price is " + Total_Price.ToString());
                        Insert_Passenger_information p = new Insert_Passenger_information(this, (int)Seats_Numeric.Value, ID_B, Total_Price);
                        p.Show();
                    }
                    else
                    {
                        MessageBox.Show("Sorry, but the trip is fully booked");
                    }
                }
                else
                {
                    dT = controllerObj.Find_Weekly_Trips(location1, location2, Date_TimePicker.Value.DayOfWeek.ToString(), Time_TimePicker.Value.TimeOfDay);

                    if (dT != null)
                    {
                        Trip_Price = (int)dT.Rows[0][1];
                        ID_W       = (int)dT.Rows[0][0];
                        DataTable Numseats_W = controllerObj.Find_Num_Of_Seats_in_the_Bus_Using_IDW(ID_W);
                        if ((int)Numseats_W.Rows[0][0] < Seats_Numeric.Value)
                        {
                            MessageBox.Show("Too much number of seats ,Can't reserve for that passenger ");
                        }
                        else
                        {
                            int result = controllerObj.Insert_Bus_Trip(Date_TimePicker.Value, ID_W);
                            T    = controllerObj.Check(location1, location2, Date_TimePicker.Value.DayOfWeek.ToString(), Time_TimePicker.Value.TimeOfDay, Date_TimePicker.Value);
                            ID_B = (int)T.Rows[0][0];


                            if (result == 1)
                            {
                                MessageBox.Show("there is an available trip ,You can reserve for Passenger now ");
                                //Calculate the total money the passenger should pay
                                Total_Price = Trip_Price * (int)Seats_Numeric.Value;
                                //check frist if the promo code valid for this trip or not
                                DataTable P = controllerObj.Check_Promo_Code_Validation(PromoCode_textBox.Text, ID_B);

                                if (P != null)
                                {
                                    Discount    = (int)P.Rows[0][0];
                                    Total_Price = Total_Price - Convert.ToInt16(Total_Price * (Discount / 100.0));
                                    MessageBox.Show("Promo Code is Applied succefully");
                                }
                                else if (PromoCode_textBox.Text != "")
                                {
                                    MessageBox.Show("Promo Code is not valid for this trip");
                                }
                                MessageBox.Show("Total Price is " + Total_Price.ToString());
                                Insert_Passenger_information p = new Insert_Passenger_information(this, (int)Seats_Numeric.Value, ID_B, Total_Price);
                                p.Show();
                            }
                            else
                            {
                                MessageBox.Show("Insertion failed");
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Sorry,There is no Trip available so You can't reserve for the passenger");
                    }
                }
            }
        }