Beispiel #1
0
        public AddVoucher(HomeForm hf)
        {
            Form = hf;
            InitializeComponent();

            c.Open();
            string          sql1     = "SELECT Name FROM Country ";
            MySqlCommand    command1 = new MySqlCommand(sql1, c);
            MySqlDataReader reader1  = command1.ExecuteReader();

            while (reader1.Read())
            {
                comboBox7.Items.Add(reader1[0].ToString());
                comboBox2.Items.Add(reader1[0].ToString());
            }
            c.Close();
            c.Open();
            string          sql2     = "SELECT Name FROM Agency ";
            MySqlCommand    command2 = new MySqlCommand(sql2, c);
            MySqlDataReader reader2  = command2.ExecuteReader();

            while (reader2.Read())
            {
                comboBox8.Items.Add(reader2[0].ToString());
            }
            c.Close();
            c.Open();
            string          sql3     = "SELECT Max(ID) FROM  Voucher ";
            MySqlCommand    command3 = new MySqlCommand(sql3, c);
            MySqlDataReader reader3  = command3.ExecuteReader();

            reader3.Read();
            textBox2.Text = (Convert.ToInt32(reader3[0]) + 1) + "";
            c.Close();
        }
Beispiel #2
0
        public FilterRoute(HomeForm frm)
        {
            Form = frm;
            InitializeComponent();
            string SQL1 = "SELECT Country.Name FROM Country";

            c.Open();
            MySqlCommand    command = new MySqlCommand(SQL1, c);
            MySqlDataReader reader  = command.ExecuteReader();

            while (reader.Read())
            {
                comboBox2.Items.Add(reader[0].ToString());
                comboBox3.Items.Add(reader[0].ToString());
            }
            c.Close();
            string SQL2 = "SELECT Airline.Name FROM Airline";

            c.Open();
            MySqlCommand    command1 = new MySqlCommand(SQL2, c);
            MySqlDataReader reader1  = command1.ExecuteReader();

            while (reader1.Read())
            {
                comboBox6.Items.Add(reader1[0].ToString());
            }
            c.Close();
        }
Beispiel #3
0
 public SearchVouchers(HomeForm hf)
 {
     DateA = DateTime.Now;
     DateB = DateTime.Now;
     Form  = hf;
     InitializeComponent();
     pictureBox2.Visible = false;
 }
Beispiel #4
0
 public SQLQuery(HomeForm hf)
 {
     Form = hf;
     InitializeComponent();
     for (int i = 0; i < Form.panel2.Controls.Count; i++)
     {
         Form.panel2.Controls[i].Visible = false;
     }
     Form.Help.Visible  = true;
     Form.Clear.Visible = true;
     Form.Play.Visible  = true;
 }
Beispiel #5
0
        public OneHotel(HomeForm hf, Hotel h)
        {
            Hotel = h;
            Form  = hf;
            InitializeComponent();
            label1.Text = Hotel.Name + " " + Hotel.Stars + "★";
            label2.Text = Hotel.Country;
            label4.Text = Hotel.City;
            string str = Hotel.Food;

            switch (str)
            {
            case "RO":
                str = "RO - Room Only";
                break;

            case "BB":
                str = "BB - Bed & Breakfast";
                break;

            case "HB":
                str = "HB - Half Board";
                break;

            case "FB":
                str = "FB - Full Board";
                break;

            case "AI":
                str = "AI - All Inclusive";
                break;

            case "UAI":
                str = "UAI - Ultra All Inclusive";
                break;
            }
            label3.Text = str;
            c.Open();
            string          sql1     = $"SELECT TypeRoom, NumPerson, Price, id FROM Room WHERE idHotel = {Hotel.ID}";
            MySqlCommand    command1 = new MySqlCommand(sql1, c);
            MySqlDataReader reader1  = command1.ExecuteReader();

            f.CreateDataGridView(dataGridView1, reader1);
            c.Close();
            for (int i = 0; i < Form.panel2.Controls.Count; i++)
            {
                Form.panel2.Controls[i].Visible = false;
            }
            Form.Add.Visible = true;
        }
Beispiel #6
0
        public OneVoucher(HomeForm hf)
        {
            Form = hf;
            InitializeComponent();
            DataGridViewCellCollection co = ((Vouchers)Form.State).dataGridView1.SelectedRows[0].Cells;

            ID           = Convert.ToInt32(co[0].Value);
            label1.Text += co[0].Value.ToString();
            label2.Text += co[1].Value.ToString();
            label4.Text += co[2].Value.ToString();
            label3.Text += co[3].Value.ToString();
            label8.Text += co[4].Value.ToString() + "$";
            label7.Text += co[5].Value.ToString();
            string sql = $"SELECT Room.TypeRoom FROM Room, Voucher WHERE Voucher.idTypeRoom = Room.ID AND Voucher.ID = {co[0].Value.ToString()}";

            c.Open();
            MySqlCommand    comm   = new MySqlCommand(sql, c);
            MySqlDataReader reader = comm.ExecuteReader();

            reader.Read();
            label6.Text += reader[0].ToString();
            c.Close();
            string sql1 = $"SELECT People.Surname, People.Name, People.Passport, People.Birthday, People.Sex, Country.Name " +
                          $"FROM People, Voucherpeople, Country " +
                          $"WHERE People.IdNational=Country.ID AND People.Passport = Voucherpeople.passport AND Voucherpeople.idVoucher ='{co[0].Value.ToString()}' ";

            c.Open();
            MySqlCommand    comm1   = new MySqlCommand(sql1, c);
            MySqlDataReader reader1 = comm1.ExecuteReader();

            f.CreateDataGridView(dataGridView1, reader1);
            c.Close();
            string sql2 = $"SELECT Route.RouteNum, Route.CodeAirportDeparture, Route.CodeAirportArrive, Flight.dateTime, Flight.ID " +
                          $"FROM Route, Flight, Voucherflight, Voucher " +
                          $"WHERE Voucher.ID ={co[0].Value.ToString()} AND VoucherFlight.idVoucher = Voucher.ID AND " +
                          $"Flight.ID = VoucherFlight.idFlight AND Flight.NumRoute = Route.RouteNum";

            c.Open();
            MySqlCommand    comm2   = new MySqlCommand(sql2, c);
            MySqlDataReader reader2 = comm2.ExecuteReader();

            f.CreateDataGridView(dataGridView2, reader2);
            c.Close();
            for (int i = 0; i < Form.panel2.Controls.Count; i++)
            {
                Form.panel2.Controls[i].Visible = false;
            }
            Form.Report.Visible = true;
        }
Beispiel #7
0
        public AddTouragency(HomeForm Frm)
        {
            Form = Frm;
            InitializeComponent();
            c.Open();
            string          sql     = "SELECT login FROM Account WHERE isAdmin=0 AND login NOT IN (SELECT login FROM agency)";
            MySqlCommand    command = new MySqlCommand(sql, c);
            MySqlDataReader reader  = command.ExecuteReader();

            while (reader.Read())
            {
                comboBox1.Items.Add(reader[0].ToString());
            }
            c.Close();
        }
Beispiel #8
0
        public AddPeople(HomeForm hf, int id)
        {
            ID   = id;
            Form = hf;
            InitializeComponent();
            c.Open();
            string          sql1     = "SELECT Name FROM Country ";
            MySqlCommand    command1 = new MySqlCommand(sql1, c);
            MySqlDataReader reader1  = command1.ExecuteReader();

            while (reader1.Read())
            {
                comboBox2.Items.Add(reader1[0].ToString());
            }
            c.Close();
        }
Beispiel #9
0
        public AddFlight(HomeForm frm)
        {
            Form = frm;
            InitializeComponent();
            string SQL1 = "SELECT Country.Name FROM Country";

            c.Open();
            MySqlCommand    command = new MySqlCommand(SQL1, c);
            MySqlDataReader reader  = command.ExecuteReader();

            while (reader.Read())
            {
                comboBox2.Items.Add(reader[0].ToString());
                comboBox3.Items.Add(reader[0].ToString());
            }
            c.Close();
        }
Beispiel #10
0
 public AddHotel(HomeForm frm)
 {
     FromAddAirport = false;
     Form           = frm;
     InitializeComponent();
     if (label4.Text == "Add Hotel")
     {
         int i = 1;
         c.Open();
         string          sql     = "SELECT ID FROM Hotel ORDER BY ID ASC";
         MySqlCommand    command = new MySqlCommand(sql, c);
         MySqlDataReader reader  = command.ExecuteReader();
         while (reader.Read())
         {
             if (i != Convert.ToInt32(reader[0]))
             {
                 break;
             }
             i++;
         }
         c.Close();
         ID = i;
         c.Open();
         string          sql1     = "SELECT Name FROM Country ";
         MySqlCommand    command1 = new MySqlCommand(sql1, c);
         MySqlDataReader reader1  = command1.ExecuteReader();
         while (reader1.Read())
         {
             comboBox2.Items.Add(reader1[0].ToString());
         }
         c.Close();
     }
     else
     {
         c.Open();
         string          sql1     = "SELECT Name FROM Country ";
         MySqlCommand    command1 = new MySqlCommand(sql1, c);
         MySqlDataReader reader1  = command1.ExecuteReader();
         while (reader1.Read())
         {
             comboBox2.Items.Add(reader1[0].ToString());
         }
         c.Close();
     }
 }
Beispiel #11
0
        public Hotels(HomeForm frm)
        {
            Form = frm;
            InitializeComponent();
            c.Open();
            string          sql     = "SELECT Hotel.Name, Hotel.Stars, Hotel.Food, City.Name, Country.Name, Hotel.ID FROM Hotel, City, Country WHERE Hotel.IdCity = City.ID AND City.IdCountry = Country.ID";
            MySqlCommand    command = new MySqlCommand(sql, c);
            MySqlDataReader reader  = command.ExecuteReader();

            f.CreateDataGridView(dataGridView1, reader);
            c.Close();
            for (int i = 0; i < Form.panel2.Controls.Count; i++)
            {
                Form.panel2.Controls[i].Visible = false;
            }
            Form.Add.Visible    = true;
            Form.Filter.Visible = true;
        }
Beispiel #12
0
        public Agencies(HomeForm hf)
        {
            InitializeComponent();
            Form = hf;
            c.Open();
            string          sql     = "SELECT Name, Director,Login, DateLicense, Comission FROM Agency";
            MySqlCommand    command = new MySqlCommand(sql, c);
            MySqlDataReader reader  = command.ExecuteReader();

            f.CreateDataGridView(dataGridView1, reader);
            c.Close();
            for (int i = 0; i < Form.panel2.Controls.Count; i++)
            {
                Form.panel2.Controls[i].Visible = false;
            }
            Form.Add.Visible    = true;
            Form.Filter.Visible = true;
            Form.Update.Visible = true;
        }
Beispiel #13
0
        public Routes(HomeForm frm)
        {
            Form = frm;
            InitializeComponent();
            c.Open();
            string          sql     = "SELECT Route.RouteNum, Airline.Name , Route.CodeAirportDeparture, Route.CodeAirportArrive, Route.TimeDeparture, Route.days, Route.Price FROM Route, Airline WHERE Route.CodeAirline = Airline.Code";
            MySqlCommand    command = new MySqlCommand(sql, c);
            MySqlDataReader reader  = command.ExecuteReader();

            f.CreateDataGridView(dataGridView1, reader);
            c.Close();
            for (int i = 0; i < Form.panel2.Controls.Count; i++)
            {
                Form.panel2.Controls[i].Visible = false;
            }
            Form.Add.Visible    = true;
            Form.Filter.Visible = true;
            Form.Update.Visible = true;
        }
Beispiel #14
0
 public MyMessageBox(HomeForm frm, string name, string message, string but1, string but2, string met1, string met2)
 {
     InitializeComponent();
     Frm         = frm;
     label4.Text = name;
     label1.Text = message;
     Yes.Text    = but1;
     if (but2 != "")
     {
         No.Text = but2;
     }
     else
     {
         No.Visible    = false;
         Yes.BackColor = Color.CornflowerBlue;
     }
     Met1 = met1;
     Met2 = met2;
 }
Beispiel #15
0
        public UpdateRoutes(HomeForm hf, int i)
        {
            I    = i;
            Form = hf;
            InitializeComponent();
            string[] R   = new string[0];
            string   sql = "SELECT Login FROM Agency";

            c.Open();
            MySqlCommand    com    = new MySqlCommand(sql, c);
            MySqlDataReader reader = com.ExecuteReader();

            while (reader.Read())
            {
                Array.Resize(ref R, R.Length + 1);
                R[R.Length - 1] = reader[0].ToString();
            }
            Logins = R;
            progressBar1.Maximum = R.Length + 2;
            progressBar1.Minimum = 0;
            c.Close();
        }
Beispiel #16
0
        public Accounts(HomeForm frm)
        {
            Form = frm;
            InitializeComponent();
            c.Open();
            string          sql     = "SELECT Agency.Name, Account.Login, Account.Password FROM Agency, Account WHERE Account.Login = Agency.Login UNION SELECT '-', Account.Login, Account.Password FROM Account WHERE Account.Login NOT IN(SELECT Login From Agency) AND Account.IsAdmin = 0";
            MySqlCommand    command = new MySqlCommand(sql, c);
            MySqlDataReader reader  = command.ExecuteReader();

            f.CreateDataGridView(dataGridView1, reader);
            c.Close();
            c.Open();
            string          sql1     = "SELECT Account.Login, Account.Password FROM Account WHERE Account.IsAdmin = 1";
            MySqlCommand    command1 = new MySqlCommand(sql1, c);
            MySqlDataReader reader1  = command1.ExecuteReader();

            f.CreateDataGridView(dataGridView2, reader1);
            c.Close();
            for (int i = 0; i < Form.panel2.Controls.Count; i++)
            {
                Form.panel2.Controls[i].Visible = false;
            }
            Form.Add.Visible = true;
        }
Beispiel #17
0
 public AddHotel(HomeForm frm, AddAirport ar) : this(frm)
 {
     FromAddAirport = true;
     addairport     = ar;
 }
Beispiel #18
0
 public AddRoom(HomeForm frm)
 {
     Form = frm;
     InitializeComponent();
     textBox0.Text = ((OneHotel)Form.State).Hotel.Name;
 }
Beispiel #19
0
 public FilterAgency(HomeForm frm)
 {
     Form = frm;
     InitializeComponent();
 }
Beispiel #20
0
        public Vouchers(HomeForm frm)
        {
            Form = frm;
            InitializeComponent();
            string sql = "";

            if (Form.User.IsAdmin)
            {
                sql = "SELECT Voucher.ID, Agency.Name, Hotel.Name, minimal.miin, " +
                      "Round((Room.Price * Voucher.NumNights + PairSummaVoucher.Summa * Countpeople.c) * 120 * (Agency.Comission + 100) / 10000, 0), " +
                      "Voucher.Status " +
                      "FROM Voucher, Agency, Hotel, Room, " +
                      "(SELECT Min(datetimeflight) AS miin, voucherid " +
                      "FROM " +
                      "(SELECT flight.datetime AS datetimeflight, voucher.ID AS voucherid " +
                      "FROM flight, voucher, voucherflight " +
                      " WHERE flight.ID = voucherflight.idFlight AND voucher.ID = voucherflight.idVoucher " +
                      " ) AS PairVoucherData " +
                      "GROUP BY voucherid " +
                      ") AS minimal, " +
                      "(SELECT Sum(Flights.price) AS Summa, Flights.voucherid " +
                      "FROM " +
                      "(SELECT Voucherflight.idVoucher as voucherid, Route.Price AS price " +
                      "FROM Voucherflight, Route, Flight " +
                      "WHERE Voucherflight.idFlight = Flight.ID AND Flight.NumRoute = Route.RouteNum " +
                      ") AS Flights " +
                      "GROUP BY Flights.voucherid " +
                      ") AS PairSummaVoucher, " +
                      "(SELECT voucher.ID AS id, Count(voucherpeople.idVoucher) as c " +
                      "FROM voucher " +
                      "LEFT JOIN voucherpeople " +
                      "ON voucherpeople.idVoucher = voucher.Id " +
                      "GROUP BY voucher.ID) AS CountPeople " +
                      "WHERE Agency.Login = Voucher.Login AND Voucher.IdTypeRoom = Room.ID AND Room.IdHotel = Hotel.ID AND " +
                      "minimal.voucherid = Voucher.ID AND PairSummaVoucher.voucherid = Voucher.ID AND CountPeople.id = Voucher.ID " +
                      "UNION " +
                      "SELECT Voucher.ID, Agency.Name, Hotel.Name, Voucher.DateHotel , " +
                      "Round((Room.Price * Voucher.NumNights) * 120 * (Agency.Comission + 100) / 10000, 0), " +
                      "Voucher.Status " +
                      "FROM Voucher, Agency, Hotel, Room, Voucherflight, " +
                      "(SELECT voucher.ID AS id, Count(voucherpeople.idVoucher) as c " +
                      "FROM voucher " +
                      "LEFT JOIN voucherpeople " +
                      "ON voucherpeople.idVoucher = voucher.Id " +
                      "GROUP BY voucher.ID) AS CountPeople  " +
                      "WHERE Agency.Login = Voucher.Login AND Voucher.IdTypeRoom = Room.ID AND Room.IdHotel = Hotel.ID " +
                      " AND Voucher.ID NOT IN (SELECT idVoucher FROM Voucherflight) AND Countpeople.id = Voucher.ID";
            }
            else
            {
                sql = "SELECT Voucher.ID, Agency.Name, Hotel.Name, minimal.miin, " +
                      "Round((Room.Price * Voucher.NumNights + PairSummaVoucher.Summa * Countpeople.c) * 120 * (Agency.Comission + 100) / 10000, 0), " +
                      "Voucher.Status " +
                      "FROM Voucher, Agency, Hotel, Room, " +
                      "(SELECT Min(datetimeflight) AS miin, voucherid " +
                      "FROM " +
                      "(SELECT flight.datetime AS datetimeflight, voucher.ID AS voucherid " +
                      "FROM flight, voucher, voucherflight " +
                      " WHERE flight.ID = voucherflight.idFlight AND voucher.ID = voucherflight.idVoucher " +
                      " ) AS PairVoucherData " +
                      "GROUP BY voucherid " +
                      ") AS minimal, " +
                      "(SELECT Sum(Flights.price) AS Summa, Flights.voucherid " +
                      "FROM " +
                      "(SELECT Voucherflight.idVoucher as voucherid, Route.Price AS price " +
                      "FROM Voucherflight, Route, Flight " +
                      "WHERE Voucherflight.idFlight = Flight.ID AND Flight.NumRoute = Route.RouteNum " +
                      ") AS Flights " +
                      "GROUP BY Flights.voucherid " +
                      ") AS PairSummaVoucher, " +
                      "(SELECT voucher.ID AS id, Count(voucherpeople.idVoucher) as c " +
                      "FROM voucher " +
                      "LEFT JOIN voucherpeople " +
                      "ON voucherpeople.idVoucher = voucher.Id " +
                      "GROUP BY voucher.ID) AS CountPeople " +
                      "WHERE Agency.Login = Voucher.Login AND Voucher.IdTypeRoom = Room.ID AND Room.IdHotel = Hotel.ID AND " +
                      "minimal.voucherid = Voucher.ID AND PairSummaVoucher.voucherid = Voucher.ID AND CountPeople.id = Voucher.ID " +
                      "AND Agency.Login = '******' " +
                      "UNION " +
                      "SELECT Voucher.ID, Agency.Name, Hotel.Name, Voucher.DateHotel , " +
                      "Round((Room.Price * Voucher.NumNights) * 120 * (Agency.Comission + 100) / 10000, 0), " +
                      "Voucher.Status " +
                      "FROM Voucher, Agency, Hotel, Room, Voucherflight, " +
                      "(SELECT voucher.ID AS id, Count(voucherpeople.idVoucher) as c " +
                      "FROM voucher " +
                      "LEFT JOIN voucherpeople " +
                      "ON voucherpeople.idVoucher = voucher.Id " +
                      "GROUP BY voucher.ID) AS CountPeople  " +
                      "WHERE Agency.Login = Voucher.Login AND Voucher.IdTypeRoom = Room.ID AND Room.IdHotel = Hotel.ID " +
                      $"  AND Countpeople.id = Voucher.ID AND Agency.Login = '******' ";
            }
            c.Open();
            MySqlCommand    command1 = new MySqlCommand(sql, c);
            MySqlDataReader reader1  = command1.ExecuteReader();

            f.CreateDataGridView(dataGridView1, reader1);
            c.Close();
            for (int i = 0; i < Form.panel2.Controls.Count; i++)
            {
                Form.panel2.Controls[i].Visible = false;
            }
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                switch (dataGridView1.Rows[i].Cells[5].Value.ToString())
                {
                case "Выполнено":
                    dataGridView1.Rows[i].Cells[5].Style.ForeColor = Color.SeaGreen;
                    break;

                case "Отменено":
                    dataGridView1.Rows[i].Cells[5].Style.ForeColor = Color.Red;
                    break;
                    //case "Забронировано":
                    //    dataGridView1.Rows[i].Cells[5].Style.ForeColor = Color.Red;
                    //    break;
                    //case "В процессе":
                    //    dataGridView1.Rows[i].Cells[5].Style.ForeColor = Color.LightSalmon;
                    //    break;
                    //case "Оплачено":
                    //    dataGridView1.Rows[i].Cells[5].Style.ForeColor = Color.Gold;
                    //    break;
                }
            }
            Form.Add.Visible = true;
        }
Beispiel #21
0
        public OneAgency(HomeForm hf, Touragency t)
        {
            Form       = hf;
            Touragency = t;
            InitializeComponent();
            label1.Text = Touragency.Name;
            label2.Text = "Логин: " + Touragency.Account.Login;
            label4.Text = "Директор: " + Touragency.Director;
            label3.Text = "Дата получения лицензии: " + Touragency.Date.ToShortDateString();
            label6.Text = "Комиссия: " + Touragency.Comission + "";
            string sql = "SELECT Voucher.ID, Hotel.Name, minimal.miin, " +
                         "Round((Room.Price * Voucher.NumNights + PairSummaVoucher.Summa * Countpeople.c) * 120 * (Agency.Comission + 100) / 10000, 0), " +
                         "Voucher.Status " +
                         "FROM Voucher, Agency, Hotel, Room, " +
                         "(SELECT Min(datetimeflight) AS miin, voucherid " +
                         "FROM " +
                         "(SELECT flight.datetime AS datetimeflight, voucher.ID AS voucherid " +
                         "FROM flight, voucher, voucherflight " +
                         " WHERE flight.ID = voucherflight.idFlight AND voucher.ID = voucherflight.idVoucher " +
                         " ) AS PairVoucherData " +
                         "GROUP BY voucherid " +
                         ") AS minimal, " +
                         "(SELECT Sum(Flights.price) AS Summa, Flights.voucherid " +
                         "FROM " +
                         "(SELECT Voucherflight.idVoucher as voucherid, Route.Price AS price " +
                         "FROM Voucherflight, Route, Flight " +
                         "WHERE Voucherflight.idFlight = Flight.ID AND Flight.NumRoute = Route.RouteNum " +
                         ") AS Flights " +
                         "GROUP BY Flights.voucherid " +
                         ") AS PairSummaVoucher, " +
                         "(SELECT voucher.ID AS id, Count(voucherpeople.idVoucher) as c " +
                         "FROM voucher " +
                         "LEFT JOIN voucherpeople " +
                         "ON voucherpeople.idVoucher = voucher.Id " +
                         "GROUP BY voucher.ID) AS CountPeople " +
                         $"WHERE Agency.Login='******' AND Agency.Login = Voucher.Login AND Voucher.IdTypeRoom = Room.ID AND Room.IdHotel = Hotel.ID AND " +
                         "minimal.voucherid = Voucher.ID AND PairSummaVoucher.voucherid = Voucher.ID AND CountPeople.id = Voucher.ID " +
                         "UNION " +
                         "SELECT Voucher.ID, Hotel.Name, Voucher.DateHotel , " +
                         "Round((Room.Price * Voucher.NumNights) * 120 * (Agency.Comission + 100) / 10000, 0), " +
                         "Voucher.Status " +
                         "FROM Voucher, Agency, Hotel, Room, Voucherflight, " +
                         "(SELECT voucher.ID AS id, Count(voucherpeople.idVoucher) as c " +
                         "FROM voucher " +
                         "LEFT JOIN voucherpeople " +
                         "ON voucherpeople.idVoucher = voucher.Id " +
                         "GROUP BY voucher.ID) AS CountPeople  " +
                         $"WHERE Agency.Login='******' AND Agency.Login = Voucher.Login AND Voucher.IdTypeRoom = Room.ID AND Room.IdHotel = Hotel.ID " +
                         " AND Voucher.ID NOT IN(Voucherflight.idVoucher) AND Countpeople.id = Voucher.ID";

            c.Open();
            MySqlCommand    command1 = new MySqlCommand(sql, c);
            MySqlDataReader reader1  = command1.ExecuteReader();

            f.CreateDataGridView(dataGridView1, reader1);
            c.Close();
            for (int i = 0; i < Form.panel2.Controls.Count; i++)
            {
                Form.panel2.Controls[i].Visible = false;
            }
            Form.Report.Visible = true;
        }
Beispiel #22
0
 public AddRoute(HomeForm frm, bool t) : this(frm)
 {
     label4.Text = "Edit Route";
     Yes.Text    = "Изменить";
     Routes cur = (Routes)frm.State;
     string sql = $"SELECT Country.Name, Airport.Name, Airport.Code FROM Airport, Country, City WHERE Airport.idCity = City.Id AND City.IdCountry = Country.ID AND Airport.Code='{cur.dataGridView1.SelectedRows[0].Cells[2].Value.ToString()}'";
     c.Open();
     MySqlCommand    command = new MySqlCommand(sql, c);
     MySqlDataReader reader  = command.ExecuteReader();
     reader.Read();
     string[] arr = { reader[0].ToString(), reader[1].ToString(), reader[2].ToString() };
     c.Close();
     comboBox2.SelectedItem = arr[0];
     comboBox4.SelectedItem = arr[2] + " (" + arr[1] + ")";
     string sql1 = $"SELECT Country.Name, Airport.Name, Airport.Code FROM Airport, Country, City WHERE Airport.idCity = City.Id AND City.IdCountry = Country.ID AND Airport.Code='{cur.dataGridView1.SelectedRows[0].Cells[3].Value.ToString()}'";
     c.Open();
     MySqlCommand    command1 = new MySqlCommand(sql1, c);
     MySqlDataReader reader1  = command1.ExecuteReader();
     reader1.Read();
     string[] arr1 = { reader1[0].ToString(), reader1[1].ToString(), reader1[2].ToString() };
     c.Close();
     comboBox3.SelectedItem = arr1[0];
     comboBox1.SelectedItem = arr1[2] + " (" + arr1[1] + ")";
     comboBox6.SelectedItem = cur.dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
     string sql2 = $"SELECT TimeFlight, NumPlace, Price, Plane, Days FROM Route WHERE Route.RouteNum ='{cur.dataGridView1.SelectedRows[0].Cells[0].Value.ToString()}'";
     c.Open();
     MySqlCommand    command2 = new MySqlCommand(sql2, c);
     MySqlDataReader reader2  = command2.ExecuteReader();
     reader2.Read();
     string   strr = reader2[0].ToString();
     DateTime d    = Convert.ToDateTime(strr);
     textBox1.Text = reader2[3].ToString();
     textBox2.Text = reader2[1].ToString();
     textBox3.Text = reader2[2].ToString();
     string[] array = reader2[4].ToString().Split(',');
     for (int i = 0; i < array.Length; i++)
     {
         if (array[i] == "1")
         {
             checkBox3.Checked = true;
         }
         if (array[i] == "2")
         {
             checkBox1.Checked = true;
         }
         if (array[i] == "3")
         {
             checkBox2.Checked = true;
         }
         if (array[i] == "4")
         {
             checkBox4.Checked = true;
         }
         if (array[i] == "5")
         {
             checkBox5.Checked = true;
         }
         if (array[i] == "6")
         {
             checkBox6.Checked = true;
         }
         if (array[i] == "7")
         {
             checkBox7.Checked = true;
         }
     }
     c.Close();
     numericUpDown2.Value = Convert.ToInt32(cur.dataGridView1.SelectedRows[0].Cells[4].Value.ToString().Substring(0, 2));
     numericUpDown1.Value = Convert.ToInt32(cur.dataGridView1.SelectedRows[0].Cells[4].Value.ToString().Substring(3, 2));
     numericUpDown3.Value = d.Hour;
     numericUpDown4.Value = d.Minute;
     textBox0.Text        = cur.dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
     textBox0.ReadOnly    = true;
     textBox0.BorderStyle = BorderStyle.None;
 }