Пример #1
0
        private void btn_add_garage_Click(object sender, EventArgs e)
        {
            string sql = null;



            sql = "Insert into Garage ([Garage Name],Contact,Place) values "
                  + "('" + txtBox_garage_name.Text + "','" + txtbox_contact.Text + "','" + txtBox_Place.Text + "');";
            methods m = new methods();

            m.single_tab_data_Insert(sql);

            string search_query = "Select * from ";
            string TableName    = "Garage order by Garage.G_id DESC;";

            m.show_table_element(TableName, search_query, dataGrid_Garage);
            //Select Garage.[Garage Name],Garage.Place,Garage.Contact from Garage order by Garage.G_id DESC;
        }
Пример #2
0
        private void btn_check_schedule_Click(object sender, EventArgs e)
        {
            string  sql = null, member = null, S_id = null, sql1 = null;
            methods m = new methods();

            //bool flag = false;
            listBox_avai_seat.Items.Clear();

            sql = "select [Bus Management System].dbo.Shedule.S_id from [Bus Management System].dbo.Shedule where"
                  + "[Bus Management System].dbo.Shedule.S_Time='" + combo_bustime1.Text + "' and"
                  + " [Bus Management System].dbo.Shedule.Ro_id=(select Road.Road_id from Road "
                  + "where Road.[Route Name]='" + combo_route1.Text + "')";
            member = "S_id";
            S_id   = m.id_sender(sql, member);
            if (S_id == null)
            {
                MessageBox.Show("Wrong Schedule");
            }
Tag:
            sql = "(select BS_id from [Bus Management System].dbo.Bus_Shedule_manage where "
                  + "[Bus Management System].dbo.Bus_Shedule_manage.Date='" + dateTimePicker_ticket1.Text + "' and "
                  + "[Bus Management System].dbo.Bus_Shedule_manage.S_id="
                  + "(select S_id from [Bus Management System].dbo.Shedule where "
                  + "[Bus Management System].dbo.Shedule.S_Time='" + combo_bustime1.Text + "' and "
                  + "[Bus Management System].dbo.Shedule.Ro_id="
                  + "(select Road.Road_id from Road where Road.[Route Name]='" + combo_route1.Text + "')))";
            member = "BS_id";

            string BS_id = m.id_sender(sql, member);

            if (m.flag_of_method)
            {
                string[] arr;

                Console.WriteLine("HMM:" + BS_id);
                sql    = "select  Ticket.[Name Of Seat] from Ticket where Ticket.BS_id='" + BS_id + "'";
                member = "Name Of Seat";
                arr    = m.sendarray(sql, member);
                arr.Reverse();
                for (int i = m.counter; i >= 0; i--)
                {
                    Console.WriteLine("" + arr[i]);
                }
                for (int j = 0; j < m.seat.Length; j++)
                {
                    bool bo = false;
                    for (int i = 0; i <= m.counter; i++)
                    {
                        if (arr[i] != m.seat[j])
                        {
                            bo = true;
                        }
                        if (arr[i] == m.seat[j])
                        {
                            bo = false;
                            break;
                        }
                    }
                    if (bo)
                    {
                        listBox_avai_seat.Items.Add(m.seat[j]);
                    }
                }
                if (m.counter == -1)
                {
                    for (int j = 0; j < m.seat.Length; j++)
                    {
                        listBox_avai_seat.Items.Add(m.seat[j]);
                    }
                }
            }
            else if (!m.flag_of_method)
            {
                bool insert_flag = false;
                sql = "select [Bus Management System].dbo.Shedule.S_id from [Bus Management System].dbo.Shedule where"
                      + "[Bus Management System].dbo.Shedule.S_Time='" + combo_bustime1.Text + "' and"
                      + " [Bus Management System].dbo.Shedule.Ro_id=(select Road.Road_id from Road "
                      + "where Road.[Route Name]='" + combo_route1.Text + "')";
                member = "S_id";
                //string tes_id = null;
                S_id = m.id_sender(sql, member);
                if (S_id == null)
                {
                    //MessageBox.Show("Wrong Schedule");
                    insert_flag = true;
                }
                if (!insert_flag)
                {
                    sql = "insert into Bus_Shedule_manage (S_id,Date) values ('" + S_id + "','" + dateTimePicker_ticket1.Text + "')";
                    m.single_tab_data_Insert(sql);
                    goto Tag;
                }

                //Console.WriteLine("S_id:" + S_id);
                //Console.WriteLine("\n" + dateTimePicker_ticket1.Text);


                // m.single_tab_data_Insert(sql);
            }
        }
Пример #3
0
        private void btn_submit_Click(object sender, EventArgs e)
        {
            int cou;

            bool    bo = true;
            string  sql = null, member = null, P_id = null, Ts_id = null, BS_id = null, S_id = null, name_of_seat = null;
            methods m = new methods();

            sql = "select [Bus Management System].dbo.Shedule.S_id from [Bus Management System].dbo.Shedule where"
                  + "[Bus Management System].dbo.Shedule.S_Time='" + combo_bustime.Text + "' and"
                  + " [Bus Management System].dbo.Shedule.Ro_id=(select Road.Road_id from Road "
                  + "where Road.[Route Name]='" + combo_route.Text + "')";
            member = "S_id";
            S_id   = m.id_sender(sql, member);
            cou    = checkedListBox_admin_Seat.SelectedItems.Count;
            if (cou == 0)
            {
                MessageBox.Show("No Seat Selected");
                bo = false;
            }
            if (S_id == null)
            {
                MessageBox.Show("Wrong Schedule");
                bo = false;
            }
            if (combo_Gender.Text == "------- Please Select -----")
            {
                MessageBox.Show("Please Select a Gender");
                bo = false;
            }
            if (bo)
            {
                sql = "insert into Passenger (Name,Gender,Contact) values ('" + txtbox_name_pass.Text + "','" + combo_Gender.Text + "','" + textBox_contact_pass.Text + "')";
                m.single_tab_data_Insert(sql);
                sql    = "select TOP 1 P_id from Passenger  order by P_id DESC ;";
                member = "P_id";
                P_id   = m.id_sender(sql, member);
                // Console.WriteLine("PID::" + P_id);
                sql    = "select Ts_id from Ticket_seller where Ticket_seller.[User ID]='" + Aid + "'";
                member = "Ts_id";
                Ts_id  = m.id_sender(sql, member);

                sql = "(select BS_id from [Bus Management System].dbo.Bus_Shedule_manage where "
                      + "[Bus Management System].dbo.Bus_Shedule_manage.Date='" + dateTimePicker_ticket.Text + "' and "
                      + "[Bus Management System].dbo.Bus_Shedule_manage.S_id="
                      + "(select S_id from [Bus Management System].dbo.Shedule where "
                      + "[Bus Management System].dbo.Shedule.S_Time='" + combo_bustime.Text + "' and "
                      + "[Bus Management System].dbo.Shedule.Ro_id="
                      + "(select Road.Road_id from Road where Road.[Route Name]='" + combo_route.Text + "')))";
                member       = "BS_id";
                BS_id        = m.id_sender(sql, member);
                name_of_seat = checkedListBox_admin_Seat.SelectedItem.ToString();
                sql          = "insert into Ticket (Ticket.BS_id,[Name Of Seat],[No of Seat],Ticket.P_id,[Total Fare],Ticket.Ts_id) "
                               + "values ('" + BS_id + "','" + name_of_seat + "','1','" + P_id + "','" + textBox_total_fare.Text + "','" + Ts_id + "')";
                m.single_tab_data_Insert(sql);
                sql = "select Ticket.T_id,Employee.[First Name] as Seller,Passenger.Name as [Passenger Name]"
                      + ",Passenger.Contact as [Passenger Contact],Passenger.Gender as [Passenger Gender] ,Ticket.[Name Of Seat]"
                      + ",Bus_Shedule_manage.Date as [Departure Date] ,Shedule.S_Time as [Schedule Time],Road.[Route Name] from ";
                string sql2 = "Ticket,Passenger,Bus_Shedule_manage,Shedule,Road,Ticket_seller,Employee "
                              + "where Ticket.P_id=Passenger.P_id and Ticket.Ts_id=Ticket_seller.Ts_id and "
                              + "Ticket_seller.E_id=Employee.E_id and Ticket.BS_id=Bus_Shedule_manage.BS_id and "
                              + "Bus_Shedule_manage.S_id=Shedule.S_id and Shedule.Ro_id=Road.Road_id order by T_id DESc";
                m.show_table_element(sql2, sql, dataGrid_admin_Ticket);
                load_new_ticket_ID();
                MessageBox.Show("Ticket Purchased Successfully");

                //Console.WriteLine("cou::" + cou);
            }
        }