Example #1
0
 public Form1()
 {
     InitializeComponent();
     try
     {
         conn.Open();
         MessageBox.Show("Connection successful!");
         conn.Close();
     }
     catch (Exception e)
     {
         MessageBox.Show("Error: " + e.Message);
     }
     ElementsSettings.SearchTextBoxSettings(searchTextBox);
     //ElementsSettings.DateTextBoxSettings(textBox7);
     OpenConnectionCorrect(conn);
     RequestsSQLT.GetTypesOfApartments(RequestsSQLT.comboElements, conn); // Получаем все реально имеющиеся типы номеров для данной гостинницы для последующего использоваия в ComboBox
     discount     = RequestsSQLT.GetCurrentDiscount(conn);
     label19.Text = discount.ToString() + " %";
     typeComboBox.Items.AddRange(admissibleTypesOfApartments);
     SetButtonsInactive0();
     SetButtonsInactive1();
     SetButtonsInactive2();
     SetButtonsInactive3();
 }
Example #2
0
 public void Refresh4()
 {
     OpenConnectionCorrect(conn);
     dataGridView4.DataSource = RequestsSQLT.SelectAllFromApartments(conn);
     ElementsSettings.SetDefaultSettingsToDGV(dataGridView4);
     ElementsSettings.RenameApartmentsDGV(dataGridView4);
 }
Example #3
0
 public void Refresh1()
 {
     OpenConnectionCorrect(conn);
     dataGridView1.DataSource = RequestsSQLT.SelectAllFromCustomer(conn);
     ElementsSettings.SetDefaultSettingsToDGV(dataGridView1);
     ElementsSettings.RenameCustomerDGV(dataGridView1);
 }
Example #4
0
 public AddingNewCustomer()
 {
     InitializeComponent();
     textBox1.Text = Form1.textBox2StaticValue;
     textBox2.Text = Form1.textBox3StaticValue;
     textBox3.Text = Form1.textBox4StaticValue;
     textBox4.Text = Form1.textBox5StaticValue;
     textBox5.Text = Form1.textBox6StaticValue;
     ancBirthdayDateTimePicker.Value = Form1.dateTimePicker1StaticValue.Value;
     textBox7.Text = Form1.textBox8StaticValue;
     Form1.OpenConnectionCorrect(Form1.conn);
     ElementsSettings.SetDefaultSettingsToDGV(dataGridViewANC);
     dataGridViewANC.DataSource = RequestsSQLT.SelectAllFromApartments(Form1.conn);
     for (int i = 0; i < RequestsSQLT.comboElements.Count; i++)
     {
         typeOfApartmentsComboBox.Items.Add(RequestsSQLT.comboElements[i]);
     }
     discountTextBox.Text = Form1.discount.ToString();
     if (Form1.cb == true)
     {
         ancSettlingDateTimePicker.Value = Convert.ToDateTime(Form1.bookingS[2]);
         ancEvictionDateTimePicker.Value = Convert.ToDateTime(Form1.bookingS[3]);
         textBox13.Text             = Form1.bookingS[5];
         textBox14.Text             = Form1.bookingS[6];
         dataGridViewANC.DataSource = RequestsSQLT.SelectAllFromApartmentsWhereNumberIsSet(Form1.conn, Convert.ToInt32(Form1.bookingS[4]));
     }
     ElementsSettings.RenameApartmentsDGV(dataGridViewANC);
     CheckAndAddCustomerData.Enabled = false;
     CheckAndAddВookingData.Enabled  = false;
 }
Example #5
0
 private void searchTextBox_Leave(object sender, EventArgs e)
 {
     if ((searchTextBox.Text == "") || (searchTextBox.Text == null))
     {
         ElementsSettings.SearchTextBoxSettings(searchTextBox);
     }
 }
Example #6
0
 private void moveToLivingsButton_Click(object sender, EventArgs e)
 {
     dataGridView2.DataSource = RequestsSQLT.SelectAllFromLivingByCustomerId(conn, idOfChosenRow1);
     ElementsSettings.SetDefaultSettingsToDGV(dataGridView2);
     ElementsSettings.HideFirstXColumns(dataGridView2, 2);
     ElementsSettings.HideLastXColumns(dataGridView2, 2);
     tabControl1.SelectedIndex = 1;
 }
Example #7
0
        public void CheckAndAddВookingData_Click(object sender, EventArgs e) //Регистрация бронирования
        {
            if (textBox13.Text != "" && textBox14.Text != "" && textBox3.Text != "" && textBox4.Text != "" && textBox5.Text != "")
            {
                SqlCommand command1 = new SqlCommand();
                SqlCommand command2 = new SqlCommand();
                Form1.OpenConnectionCorrect(Form1.conn);
                int idOfCurrentCustomer = 0;
                if (ElementsSettings.RowOfPassportSeriesConsistEnoughNumbers(textBox1) == true && ElementsSettings.RowOfPassportNumberConsistEnoughNumbers(textBox2) == true && ElementsSettings.ValuesOfGuestsAndKidsAreCorrect(textBox13, textBox14) == true && ElementsSettings.SettlingDateIsLessThenEvictionDate(ancSettlingDateTimePicker, ancEvictionDateTimePicker) == true) //Проверяем все ограничения ввода
                {
                    //SqlCommand command = new SqlCommand("INSERT INTO Customer (passport_series, passport_number, name, surname, patronymic, birthday, tel_number) values('"+textBox1.Text+"', '"+textBox2.Text+"', '"+textBox3.Text+"', '"+textBox4.Text+"', '"+textBox5.Text+"', '"+textBox6.Text+"', '"+textBox7.Text+"')", Form1.conn);
                    if (RequestsSQLT.SelectNthIdFromCustomerWherePassportDataDefinedToString(Form1.conn, Convert.ToInt32(textBox1.Text), Convert.ToInt32(textBox2.Text)) != "null") //Если клиент уже был постояльцем, то реистрируем проживание по его ID
                    {
                        idOfCurrentCustomer = Convert.ToInt32(RequestsSQLT.SelectNthIdFromCustomerWherePassportDataDefinedToString(Form1.conn, Convert.ToInt32(textBox1.Text), Convert.ToInt32(textBox2.Text)));
                        if (RequestsSQLT.ValueOfCustomerLivingsAndBookingsForToday(Form1.conn, idOfCurrentCustomer) < 5)
                        {
                            command2 = new SqlCommand("INSERT INTO Booking (number, settling, eviction, value_of_guests, value_of_kids, customer_id) VALUES (@number, @settling, @eviction, @value_of_guests, @value_of_kids, @customer_id)", Form1.conn);
                            command2.Parameters.AddWithValue("@number", selectedNumberOfApartments);
                            command2.Parameters.AddWithValue("@settling", ancSettlingDateTimePicker.Value);
                            command2.Parameters.AddWithValue("@eviction", ancEvictionDateTimePicker.Value);
                            command2.Parameters.AddWithValue("@value_of_guests", textBox13.Text);
                            command2.Parameters.AddWithValue("@value_of_kids", textBox14.Text);
                            command2.Parameters.AddWithValue("@customer_id", idOfCurrentCustomer);
                            command2.ExecuteNonQuery();
                            //Тут можно потом поставить MessageBox, предупреждающий о том, что ткоей клинет уже есть в базе данных
                        }
                    }
                    else //Если клиент ещё не был постояльцем в отеле, то добавляем его запись в таблицу клиентов и сразу регистрируем новое проживание
                    {
                        command1 = new SqlCommand("INSERT INTO Customer (passport_series, passport_number, name, surname, patronymic, birthday, tel_number) VALUES (@passport_series, @passport_number, @name, @surname, @patronymic, @birthday, @tel_number)", Form1.conn);
                        command1.Parameters.AddWithValue("@passport_series", textBox1.Text);
                        command1.Parameters.AddWithValue("@passport_number", textBox2.Text);
                        command1.Parameters.AddWithValue("@name", textBox3.Text);
                        command1.Parameters.AddWithValue("@surname", textBox4.Text);
                        command1.Parameters.AddWithValue("@patronymic", textBox5.Text);
                        command1.Parameters.AddWithValue("@birthday", ancBirthdayDateTimePicker.Value);
                        command1.Parameters.AddWithValue("@tel_number", textBox7.Text);
                        command1.ExecuteNonQuery();

                        string check = RequestsSQLT.SelectNthIdFromCustomerWherePassportDataDefinedToString(Form1.conn, Convert.ToInt32(textBox1.Text), Convert.ToInt32(textBox2.Text));
                        idOfCurrentCustomer = Convert.ToInt32(RequestsSQLT.SelectNthIdFromCustomerWherePassportDataDefinedToString(Form1.conn, Convert.ToInt32(textBox1.Text), Convert.ToInt32(textBox2.Text)));//Заного определяем ID только что добавленного клиента

                        command2 = new SqlCommand("INSERT INTO Booking (number, settling, eviction, value_of_guests, value_of_kids, customer_id) VALUES (@number, @settling, @eviction, @value_of_guests, @value_of_kids, @customer_id)", Form1.conn);
                        command2.Parameters.AddWithValue("@number", selectedNumberOfApartments);
                        command2.Parameters.AddWithValue("@settling", ancSettlingDateTimePicker.Value);
                        command2.Parameters.AddWithValue("@eviction", ancEvictionDateTimePicker);
                        command2.Parameters.AddWithValue("@value_of_guests", textBox13.Text);
                        command2.Parameters.AddWithValue("@value_of_kids", textBox14.Text);
                        command2.Parameters.AddWithValue("@customer_id", idOfCurrentCustomer);
                        command2.ExecuteNonQuery();
                    }
                }
            }
            else
            {
                MessageBox.Show("Поля \"Имя\", \"Фамилия\", \"Отчество\", \"Количество гостей\", \"Количество детей\" обязательны к заполению");
            }
        }
Example #8
0
 public void Refresh3()
 {
     OpenConnectionCorrect(conn);
     dataGridView3.DataSource = RequestsSQLT.SelectAllFromBooking(conn);
     ElementsSettings.SetDefaultSettingsToDGV(dataGridView3);
     ElementsSettings.HideFirstXColumns(dataGridView3, 2);
     ElementsSettings.HideLastXColumns(dataGridView3, 2);
     ElementsSettings.RenameLivingOrBookingDGV(dataGridView3);
 }
Example #9
0
 private void dataGridView4_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     SetButtonsActive3();
     try
     {
         bookingS           = ElementsSettings.SetDataFromApartmentsDGVToTextBoxes(dataGridView4, e);
         numberOfChosenRow  = Convert.ToInt32(bookingS[0]);
         numberTextBox.Text = bookingS[0];
         typeComboBox.Text  = bookingS[1];
         priceTextBox.Text  = bookingS[2];
     } catch { }
 }
Example #10
0
 private void dataGridViewANC_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     CheckAndAddCustomerData.Enabled = true;
     CheckAndAddВookingData.Enabled  = true;
     selectedNumberOfApartments      = ElementsSettings.SelectNumberOfSelectedApartments(dataGridViewANC, e);
     if (textBox13.Text != "" && textBox14.Text != "" && ancSettlingDateTimePicker.Value < ancEvictionDateTimePicker.Value)
     {
         TimeSpan ts = ancEvictionDateTimePicker.Value - ancSettlingDateTimePicker.Value;
         resultPriceTextBox.Text = ((ts.Days + 1) * ElementsSettings.SelectPriceOfSelectedApartments(dataGridViewANC, e) * (Convert.ToInt32(textBox13.Text) - Convert.ToInt32(textBox14.Text)) + (ts.Days + 1) * Convert.ToInt32(textBox14.Text) * (ElementsSettings.SelectPriceOfSelectedApartments(dataGridViewANC, e) - (ElementsSettings.SelectPriceOfSelectedApartments(dataGridViewANC, e) / 100 * Convert.ToInt32(discountTextBox.Text)))).ToString();
     }
     else
     {
         resultPriceTextBox.Text = "<некорректные данные>";
     }
 }
Example #11
0
 private void dataGridView3_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     SetButtonsActive2();
     try
     {
         bookingS       = ElementsSettings.SetDataFromLivingOrBookingDGVToTextBoxes(dataGridView3, e);
         idOfChosenRow3 = Convert.ToInt32(RequestsSQLT.SelectNthIdFromCustomerWherePassportDataDefinedToString(conn, Convert.ToInt32(bookingS[0]), Convert.ToInt32(bookingS[1])));
         textBox17.Text = bookingS[5];
         textBox16.Text = bookingS[6];
         if (bookingS[7] != "")
         {
             idOfChosenRowBooking = Convert.ToInt32(bookingS[8]);
         }
     } catch { }
 }
Example #12
0
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     SetButtonsActive0();
     try
     {
         string[] s = ElementsSettings.SetDataFromCustomersDGVToTextBoxes(dataGridView1, e);
         idOfChosenRow1        = Convert.ToInt32(RequestsSQLT.SelectNthIdFromCustomerWherePassportDataDefinedToString(conn, Convert.ToInt32(s[0]), Convert.ToInt32(s[1])));
         textBox2.Text         = s[0];
         textBox3.Text         = s[1];
         textBox4.Text         = s[2];
         textBox5.Text         = s[3];
         textBox6.Text         = s[4];
         dateTimePicker1.Value = Convert.ToDateTime(s[5]);
         //textBox7.Text = s[6];
         textBox8.Text = s[6];
     } catch { }
 }
Example #13
0
 private void dataGridView2_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     SetButtonsActive1();
     try
     {
         string[] s = ElementsSettings.SetDataFromLivingOrBookingDGVToTextBoxes(dataGridView2, e);
         idOfChosenRow2 = Convert.ToInt32(RequestsSQLT.SelectNthIdFromCustomerWherePassportDataDefinedToString(conn, Convert.ToInt32(s[0]), Convert.ToInt32(s[1])));
         textBox12.Text = s[5];
         textBox11.Text = s[6];
         if (s[7] != "")
         {
             idOfChosenRowAS = Convert.ToInt32(s[7]);
         }
         if (s[8] != "")
         {
             idOfChosenRowLiving = Convert.ToInt32(s[8]);
         }
     } catch { }
 }
Example #14
0
        private void changeBookingDataButton_Click(object sender, EventArgs e)
        {
            var dResult = MessageBox.Show("Вы уверены, что хотите применить изменения в базе данных?", "", MessageBoxButtons.YesNo);

            if (dResult == DialogResult.Yes)
            {
                if (ElementsSettings.ValuesOfGuestsAndKidsAreCorrect(textBox12, textBox11) == true) //Проверяем все ограничения ввода для таблицы клиентов
                {
                    SqlCommand command = new SqlCommand();
                    command = new SqlCommand($"UPDATE Booking SET value_of_guests = {Convert.ToInt32(textBox12.Text)}, value_of_kids = {Convert.ToInt32(textBox11.Text)} WHERE booking_id = {idOfChosenRowBooking}", conn);
                    command.ExecuteNonQuery();
                    Refresh3();
                }
                else
                {
                    MessageBox.Show("Введены недопустимые значения");
                }
            }
        }
Example #15
0
        private void changeCustomerDataButton_Click(object sender, EventArgs e)
        {
            var dResult = MessageBox.Show("Вы уверены, что хотите применить изменения в базе данных?", "", MessageBoxButtons.YesNo);

            if (dResult == DialogResult.Yes)
            {
                if (ElementsSettings.RowOfPassportSeriesConsistEnoughNumbers(textBox2) == true && ElementsSettings.RowOfPassportNumberConsistEnoughNumbers(textBox3) == true) //Проверяем все ограничения ввода для таблицы клиетов
                {
                    SqlCommand command = new SqlCommand();
                    command = new SqlCommand($"UPDATE Customer SET passport_series = {Convert.ToInt32(textBox2.Text)}, passport_number = {Convert.ToInt32(textBox3.Text)}, name = '{textBox4.Text}', surname = '{textBox5.Text}', patronymic = '{textBox6.Text}', birthday = '{dateTimePicker1.Value}', tel_number = '{textBox8.Text}' WHERE customer_id = {idOfChosenRow1}", conn);
                    command.ExecuteNonQuery();
                    Refresh1();
                }
                else
                {
                    MessageBox.Show("Серия или номер паспорта заданы некорректно");
                }
            }
        }
Example #16
0
        private void changeDiscountButton_Click(object sender, EventArgs e)
        {
            var dResult = MessageBox.Show("Вы уверены, что хотите обновить значение скидки?", "", MessageBoxButtons.YesNo);

            if (dResult == DialogResult.Yes)
            {
                if (ElementsSettings.NewDiscountIsInPercentage(newDiscountTextBox) == true)
                {
                    RequestsSQLT.SetNewDiscount(conn, Convert.ToInt32(newDiscountTextBox.Text));
                }
                else
                {
                    MessageBox.Show("Введено недопустимое значение.");
                }
            }
            newDiscountTextBox.Clear();
            discount     = RequestsSQLT.GetCurrentDiscount(conn);
            label19.Text = discount.ToString() + " %";
        }
Example #17
0
 private void clothesWashingTextBox_KeyPress(object sender, KeyPressEventArgs e)
 {
     ElementsSettings.RowWithNoLetters(clothesWashingTextBox, e);
 }
Example #18
0
 private void textBox11_KeyPress(object sender, KeyPressEventArgs e)
 {
     ElementsSettings.RowWithNoLetters(textBox11, e);
 }
Example #19
0
 private void eatTextBox_KeyPress(object sender, KeyPressEventArgs e)
 {
     ElementsSettings.RowWithNoLetters(eatTextBox, e);
 }
Example #20
0
 private void textBox6_KeyPress(object sender, KeyPressEventArgs e)
 {
     ElementsSettings.RowWithNoDigits(textBox6, e);
 }
Example #21
0
 private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
 {
     ElementsSettings.RowOfPassportNumberIsCorrect(textBox3, e);
 }
Example #22
0
 private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
 {
     //e.Handled = ElementsSettings.RowOfPassportSeriesIsCorrect(textBox2, e);
     ElementsSettings.RowOfPassportSeriesIsCorrect(textBox2, e);
 }
Example #23
0
 private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
 {
     ElementsSettings.RowOfPassportSeriesIsCorrect(textBox1, e);
 }
Example #24
0
 private void searchTextBox_Enter(object sender, EventArgs e)
 {
     ElementsSettings.DefaultTextBoxSettings(searchTextBox);
 }
Example #25
0
 private void intercityTelephoneTextBox_KeyPress(object sender, KeyPressEventArgs e)
 {
     ElementsSettings.RowWithNoLetters(intercityTelephoneTextBox, e);
 }