Пример #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            #region Проверка ошибок
            if (LoginTextBox.Text == "")
            {
                return;
            }

            List <string> existUser = SQLClass.Select(
                "SELECT * FROM users WHERE login = '******'");
            if (existUser.Count > 0)
            {
                MessageBox.Show("Пользователь с таким логином существует");
                return;
            }
            #endregion

            SQLClass.Update("UPDATE users SET" +
                            " name = '" + textBox2.Text + "'," +
                            " city = '" + CityComboBox.Text + "'," +
                            " age = '" + textBox1.Text + "'," +
                            " login = '******'," +
                            " password = '******'" +
                            " WHERE login = '******'");

            SQLClass.Update("UPDATE booking SET" +
                            " user = '******'" +
                            " WHERE user = '******'");

            SQLClass.Update("UPDATE rating SET" +
                            " user = '******'" +
                            " WHERE user = '******'");

            MainForm.Login = LoginTextBox.Text;
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            #region Провера ошибок
            if (MainForm.Login == "")
            {
                MessageBox.Show("Вы не авторизованы");
                return;
            }

            DateTime dt = dateTimePicker1.Value;
            while (dt <= dateTimePicker2.Value.AddDays(0.5))
            {
                List <string> existBooking = SQLClass.Select("SELECT COUNT(*) FROM booking " +
                                                             "WHERE dateFrom <= '" + dt.ToString("yyyy-MM-dd") + "'" +
                                                             "AND dateTo >= '" + dt.ToString("yyyy-MM-dd") + "'");

                if (Convert.ToInt32(existBooking[0]) >= qty)
                {
                    MessageBox.Show("Все забронировано. Выберите другие даты!");
                    return;
                }

                dt = dt.AddDays(1);
            }
            #endregion

            SQLClass.Update("INSERT INTO booking(user, datefrom, dateto, room_id) VALUES(" +
                            "'" + MainForm.Login + "', " +
                            "'" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + "'," +
                            "'" + dateTimePicker2.Value.ToString("yyyy-MM-dd") + "'," +
                            id + ")");
            MessageBox.Show("Успешно");
        }
Пример #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     SQLClass.Update(
         "UPDATE  " + SQLClass.HOTELS +
         " SET name = '" + textBox2.Text + "', " +
         " description = '" + textBox3.Text + "'" +
         " WHERE id = '" + id + "'");
 }
Пример #4
0
 private void button1_Click(object sender, EventArgs e)
 {
     SQLClass.Update(
         "INSERT INTO  " + SQLClass.HOTELS + " (Name, City, Rating, Image)" +
         " VALUES('" + textBox1.Text + "', '" + textBox2.Text + "', '" +
         textBox3.Text + "', '" + address + "')");
     MessageBox.Show("Сохранено");
 }
Пример #5
0
 private void OpinionCLick(object sender, EventArgs e)
 {
     SQLClass.Update("INSERT INTO rating(user, hotel_id, rate, comment) VALUES(" +
                     "'" + MainForm.Login + "', " +
                     "'" + id + "', " +
                     "'" + numericUpDown1.Value.ToString() + "', " +
                     "'" + textBox1.Text + "')");
     MessageBox.Show("Спасибо");
 }
Пример #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            string[] parts = comboBox1.Text.Split(new char[] { '(', ')' }, StringSplitOptions.RemoveEmptyEntries);

            SQLClass.Update(
                "INSERT INTO room(Name, hotel, hotel_id, price, Image)" +
                " VALUES('" + textBox1.Text + "', '" + parts[0] + "', '" + parts[1] + "', '" +
                textBox3.Text + "', '" + address + "')");
            MessageBox.Show("Сохранено");
            AdminRoomsForm_Load(sender, e);
        }
Пример #7
0
        private void textBox4_KeyDown(object sender, KeyEventArgs e)
        {
            TextBox tb = (TextBox)sender;

            if (e.KeyCode == Keys.Enter)
            {
                SQLClass.Update(
                    "UPDATE room" +
                    " SET quantity = '" + tb.Text.Replace("штук", "") + "'" +
                    " WHERE id = '" + tb.Tag.ToString() + "'");
            }
        }
Пример #8
0
        private void DeleteRoom(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            int    y   = btn.Location.Y;

            foreach (Control control in panel2.Controls)
            {
                if (control.Location == new Point(0, y))
                {
                    SQLClass.Update(
                        "DELETE FROM room WHERE id = '" + control.Tag.ToString() + "'");

                    AdminRoomsForm_Load(sender, e);
                    return;
                }
            }
        }
Пример #9
0
        private void DeleteHotel(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            int    y   = btn.Location.Y;

            foreach (Control control in panel2.Controls)
            {
                if (control.Location == new Point(0, y))
                {
                    SQLClass.Update(
                        "DELETE FROM " + SQLClass.HOTELS + " WHERE Name = '" + control.Text + "'");

                    AdminHotelsForm_Load(sender, e);
                    return;
                }
            }
        }
Пример #10
0
        private void button3_Click(object sender, EventArgs e)
        {
            List <string> exist = SQLClass.Select("SELECT Login FROM users WHERE login = '******'");

            if (exist.Count > 0)
            {
                MessageBox.Show("Вы уже зарегистрированы");
            }
            else
            {
                SQLClass.Update("INSERT INTO users(login, password, name, age, city) VALUES(" +
                                "'" + LoginTextBox.Text + "'," +
                                "'" + PasswordTextBox.Text + "'," +
                                "'" + textBox1.Text + "'," +
                                "'" + textBox2.Text + "'," +
                                "'" + CityComboBox.Text + "')");
            }
        }