Exemplo n.º 1
0
 private void Yes_Click(object sender, EventArgs e)
 {
     if (comboBox4.Text != "" && comboBox9.Text != "" && comboBox5.Text != "" && comboBox8.Text != "")
     {
         string login = "";
         c.Open();
         string          sql1     = $"SELECT Login FROM Agency WHERE Agency.Name = '{comboBox8.Text}' ";
         MySqlCommand    command1 = new MySqlCommand(sql1, c);
         MySqlDataReader reader1  = command1.ExecuteReader();
         reader1.Read();
         login = reader1[0].ToString();
         c.Close();
         c.Open();
         string sql = "";
         if (Yes.Text == "Добавить")
         {
             sql = $"INSERT INTO Voucher (ID, idTypeRoom, NumNights, DateHotel, login, CodeAirport, Status) " +
                   $"VALUES ('{textBox2.Text}','{CurIDRomms[comboBox4.SelectedIndex]}','{textBox1.Text}' , " +
                   $"STR_TO_DATE('{dateTimePicker1.Value.ToShortDateString().Replace('.', '-')}','%d-%m-%Y'),'{login}'," +
                   $"'{comboBox9.Text.Split(' ')[0]}','{comboBox5.Text}')";
         }
         else
         {
             sql = $"UPDATE Voucher SET idTypeRoom = (SELECT Room.id FROM Room, Hotel WHERE Room.TypeRoom='{comboBox4.Text}' AND Hotel.Name = '{comboBox1.Text}' AND Room.IdHotel= Hotel.ID), NumNights = '{textBox1.Text}', " +
                   $"DateHotel = STR_TO_DATE('{dateTimePicker1.Value.ToShortDateString().Replace('.', '-')}','%d-%m-%Y'), " +
                   $"login = '******', CodeAirport ='{comboBox9.Text.Split(' ')[0]}' , Status ='{comboBox5.Text}' " +
                   $"WHERE ID = '{textBox2.Text}'";
         }
         MySqlCommand command = new MySqlCommand(sql, c);
         command.ExecuteNonQuery();
         c.Close();
         Close();
         Point p = ((Vouchers)Form.State).Location;
         Form.Controls.Remove(Form.State);
         Vouchers a = new Vouchers(Form);
         Form.State = a;
         Form.Controls.Add(a);
         a.Location = p;
         a.Visible  = true;
         a.Show();
         Form.panel12.Visible = true;
     }
     else
     {
         MyMessageBox mmb = new MyMessageBox(Form, "Ошибка", "Введите значение", "ОК", "", "ОК", "");
         mmb.Show();
     }
 }
Exemplo n.º 2
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();
                }
            }
        }