public FilterVoucher(SearchVouchers s) { Search = s; 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()); comboBox7.Items.Add(reader1[0].ToString()); } c.Close(); dateTimePicker2.Value = DateTime.Now.AddDays(14); comboBox7.SelectedItem = "Украина"; comboBox2.SelectedIndex = 0; }
private void ButtonHome1_Click(object sender, EventArgs e) { string name = ""; try { Panel p = (Panel)sender; name = f.GetNameOfButton(p); } catch { } try { Label l = (Label)sender; name = l.Text; } catch { } try { PictureBox pb = (PictureBox)sender; name = f.GetNameOfButton(panel1, pb); } catch { } if (name != "") { if (name != "Выход") { for (int i = 0; i < panel1.Controls.Count; i++) { if (panel1.Controls[i].GetType() == typeof(Panel)) { for (int j = 0; j < panel1.Controls[i].Controls.Count; j++) { if (panel1.Controls[i].Controls[j].GetType() == typeof(Panel)) { panel1.Controls[i].Controls[j].Visible = false; } } } } } if (name == "Турагентства") { Controls.Remove(State); Agencies ag = new Agencies(this); State = ag; this.Controls.Add(ag); ag.Location = new Point(panel3.Location.X + panel3.Size.Width, panel3.Location.Y + panel3.Size.Height + PanelForm.Size.Height); ag.Visible = true; ag.Show(); panel4.Visible = true; } if (name == "Турагентство") { Controls.Remove(State); OneAgency ag = new OneAgency(this, new Touragency(User.Login)); State = ag; this.Controls.Add(ag); ag.Location = new Point(panel3.Location.X + panel3.Size.Width, panel3.Location.Y + panel3.Size.Height + PanelForm.Size.Height); ag.Visible = true; ag.Show(); panel4.Visible = true; } if (name == "SQL запросы") { Controls.Remove(State); SQLQuery sq = new SQLQuery(this); State = sq; this.Controls.Add(sq); sq.Location = new Point(panel3.Location.X + panel3.Size.Width, panel3.Location.Y + panel3.Size.Height + PanelForm.Size.Height); sq.Visible = true; sq.Show(); panel17.Visible = true; } if (name == "Отели") { Controls.Remove(State); Hotels a = new Hotels(this); State = a; this.Controls.Add(a); a.Location = new Point(panel3.Location.X + panel3.Size.Width, panel3.Location.Y + panel3.Size.Height + PanelForm.Size.Height); a.Visible = true; a.Show(); panel14.Visible = true; } if (name == "Авиарейсы") { Controls.Remove(State); Routes a = new Routes(this); State = a; this.Controls.Add(a); a.Location = new Point(panel3.Location.X + panel3.Size.Width, panel3.Location.Y + panel3.Size.Height + PanelForm.Size.Height); a.Visible = true; a.Show(); panel15.Visible = true; } if (name == "Аккаунты") { Controls.Remove(State); Accounts a = new Accounts(this); State = a; this.Controls.Add(a); a.Location = new Point(panel3.Location.X + panel3.Size.Width, panel3.Location.Y + panel3.Size.Height + PanelForm.Size.Height); a.Visible = true; a.Show(); panel16.Visible = true; } if (name == "Путевки") { Controls.Remove(State); Vouchers a = new Vouchers(this); State = a; this.Controls.Add(a); a.Location = new Point(panel3.Location.X + panel3.Size.Width, panel3.Location.Y + panel3.Size.Height + PanelForm.Size.Height); a.Visible = true; a.Show(); panel12.Visible = true; } if (name == "Поиск") { Controls.Remove(State); SearchVouchers a = new SearchVouchers(this); State = a; this.Controls.Add(a); a.BringToFront(); a.Location = new Point(panel3.Location.X + panel3.Size.Width, panel3.Location.Y + panel3.Size.Height + PanelForm.Size.Height - 84); a.Visible = true; a.Show(); panel13.Visible = true; } if (name == "Выход") { MyMessageBox message = new MyMessageBox(this, "Предупреждение", "Выйти из аккаунта?", "Да", "Нет", "Выход_Да", "Выход_Нет"); message.Show(); } } }
public VariantsOfVoucher(SearchVouchers s) { Search = s; InitializeComponent(); label1.Text = Search.dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); string SQL = $"SELECT Room.TypeRoom FROM Room, Hotel WHERE Hotel.Id = Room.IdHotel AND Hotel.Name = '{Search.dataGridView1.SelectedRows[0].Cells[0].Value.ToString()}'"; c.Open(); MySqlCommand command1 = new MySqlCommand(SQL, c); MySqlDataReader reader1 = command1.ExecuteReader(); while (reader1.Read()) { comboBox2.Items.Add(reader1[0].ToString()); } c.Close(); int price = 0; string SQL1 = $"SELECT Min(Room.Price) FROM Room, Hotel " + $"WHERE Hotel.ID = Room.idHotel AND Hotel.Name = '{Search.dataGridView1.SelectedRows[0].Cells[0].Value.ToString()}' AND Room.NumPerson >={Search.CountPeople}"; c.Open(); MySqlCommand command2 = new MySqlCommand(SQL1, c); MySqlDataReader reader2 = command2.ExecuteReader(); reader2.Read(); try { price = Convert.ToInt32(reader2[0]); CurPrice = Convert.ToInt32(reader2[0]); } catch { } c.Close(); string SQLA = $"SELECT Room.TypeRoom FROM Room, Hotel WHERE Room.idHotel = Hotel.ID AND " + $"Hotel.Name = '{Search.dataGridView1.SelectedRows[0].Cells[0].Value.ToString()}' AND " + $"Room.Price =(SELECT Min(Room.Price) FROM Room, Hotel " + $"WHERE Hotel.ID = Room.idHotel AND Hotel.Name = '{Search.dataGridView1.SelectedRows[0].Cells[0].Value.ToString()}' AND Room.NumPerson >={Search.CountPeople})"; c.Open(); MySqlCommand command = new MySqlCommand(SQLA, c); MySqlDataReader reader = command.ExecuteReader(); reader.Read(); try { comboBox2.SelectedItem = reader[0]; } catch { } c.Close(); string[] arr = new string[0]; for (int i = 0; i < Search.Result.Length; i++) { if (Search.Result[i].Split('%')[1] == Search.dataGridView1.SelectedRows[0].Cells[0].Value.ToString()) { Array.Resize(ref arr, arr.Length + 1); arr[arr.Length - 1] = Search.Result[i]; } } for (int i = 0; i < arr.Length; i++) { string way1 = arr[i].Split('%')[0]; string way2 = arr[i].Split('%')[2]; int allprice = int.Parse(arr[i].Split('%')[3]); string SQL0 = $"SELECT Route.CodeAirportDeparture, Flight.DateTime FROM Route, Flight " + $"WHERE Flight.NumRoute = Route.RouteNum AND Flight.ID = '{way1.Split('-')[0]}' "; c.Open(); MySqlCommand command0 = new MySqlCommand(SQL0, c); MySqlDataReader reader0 = command0.ExecuteReader(); reader0.Read(); string airportstart = reader0[0].ToString(); DateTime datestart1 = Convert.ToDateTime(reader0[1].ToString()); c.Close(); SQL0 = $"SELECT Route.CodeAirportDeparture, Flight.DateTime FROM Route, Flight " + $"WHERE Flight.NumRoute = Route.RouteNum AND Flight.ID = '{way2.Split('-')[0]}' "; c.Open(); command0 = new MySqlCommand(SQL0, c); reader0 = command0.ExecuteReader(); reader0.Read(); string airportstart2 = reader0[0].ToString(); DateTime datestart2 = Convert.ToDateTime(reader0[1].ToString()); c.Close(); string marsh = airportstart + "-"; DateTime datefinish1 = new DateTime(); for (int j = 0; j < way1.Split('-').Length; j++) { string SQL3 = $"SELECT Route.CodeAirportArrive, Flight.Datetime, Route.TimeFlight FROM Route, Flight " + $"WHERE Flight.NumRoute = Route.RouteNum AND Flight.ID = '{way1.Split('-')[j]}' "; c.Open(); MySqlCommand command3 = new MySqlCommand(SQL3, c); MySqlDataReader reader3 = command3.ExecuteReader(); reader3.Read(); marsh += reader3[0].ToString() + "-"; if (j == way1.Split('-').Length - 1) { datefinish1 = Convert.ToDateTime(reader3[1]).AddHours(((TimeSpan)reader3[2]).Hours).AddMinutes(((TimeSpan)reader3[2]).Minutes); } c.Close(); } marsh = marsh.Substring(0, marsh.Length - 1); marsh += " / " + airportstart2 + "-"; DateTime datefinish2 = new DateTime(); for (int j = 0; j < way2.Split('-').Length; j++) { string SQL3 = $"SELECT Route.CodeAirportArrive, Flight.Datetime, Route.TimeFlight FROM Route, Flight " + $"WHERE Flight.NumRoute = Route.RouteNum AND Flight.ID = '{way2.Split('-')[j]}' "; c.Open(); MySqlCommand command3 = new MySqlCommand(SQL3, c); MySqlDataReader reader3 = command3.ExecuteReader(); reader3.Read(); marsh += reader3[0].ToString() + "-"; if (j == way2.Split('-').Length - 1) { datefinish2 = Convert.ToDateTime(reader3[1]).AddHours(((TimeSpan)reader3[2]).Hours).AddMinutes(((TimeSpan)reader3[2]).Minutes); } c.Close(); } string SQL30 = $"SELECT Room.Price FROM Room, Hotel WHERE Room.idHotel = Hotel.ID AND Hotel.Name = '{label1.Text}' AND Room.TypeRoom = '{comboBox2.Text}' "; c.Open(); MySqlCommand command30 = new MySqlCommand(SQL30, c); MySqlDataReader reader30 = command30.ExecuteReader(); reader30.Read(); int pricee = Convert.ToInt32(reader30[0]); c.Close(); marsh = marsh.Substring(0, marsh.Length - 1); int l = dataGridView1.Rows.Add(); dataGridView1.Rows[l].Cells[1].Value = datestart1.ToShortDateString(); dataGridView1.Rows[l].Cells[0].Value = marsh; dataGridView1.Rows[l].Cells[2].Value = (datefinish2 - datestart1).Days.ToString(); dataGridView1.Rows[l].Cells[3].Value = (datefinish1 - datestart1).ToString() + " / " + (datefinish2 - datestart2).ToString(); dataGridView1.Rows[l].Cells[4].Value = (allprice + pricee * int.Parse(dataGridView1.Rows[l].Cells[2].Value.ToString())).ToString(); } }