예제 #1
0
        /// <summary>
        /// Обработчик нажатия кнопки "Добавить" для добавления данных о покупателе в базу данных
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (Regex.IsMatch(richTextBoxName.Text, "^[A-Za-zА-Яа-я]+$") &&
                Regex.IsMatch(richTextBoxSurname.Text, "^[A-Za-zА-Яа-я]+$") &&
                (Regex.IsMatch(richTextBoxSecondName.Text, "^[A-Za-zА-Яа-я]+$") ||
                 richTextBoxSecondName.Text == null) &&
                Regex.IsMatch(richTextBoxPhoneNumber.Text, "^[0-9]+$") &&
                dateTimePicker1.Text != null)
            {
                if (SqlManager
                    .ExecuteCommand(
                        $"select * from Customer where[PhoneNumber] = {richTextBoxPhoneNumber.Text}").Count != 0)
                {
                    MessageBox.Show("Данный пользователь уже существует");
                    return;
                }

                SqlManager.InsertData("Customer",
                                      new[] { "Name", "Surname", "SecondName", "PhoneNumber", "BirthDate", "DateOfVisit" },
                                      new[]
                {
                    richTextBoxName.Text, richTextBoxSurname.Text, richTextBoxSecondName.Text,
                    richTextBoxPhoneNumber.Text, Convert.ToDateTime(dateTimePicker1.Text).ToString("yyyy-MM-dd"),
                    DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")
                });
                MessageBox.Show("Покупатель добавлен");
            }
            else
            {
                MessageBox.Show("Ошибка ввода данных");
            }
        }
예제 #2
0
 public EditContractor(string supplierId)
 {
     InitializeComponent();
     _supplierId       = supplierId;
     richTextBox1.Text =
         SqlManager.ExecuteCommand(
             $"select Imy_postavchika, Gorod_postavchika from Postavchik where Kod_postavchika = '{supplierId}'")
         [0];
     richTextBox2.Text =
         SqlManager.ExecuteCommand(
             $"select Imy_postavchika, Gorod_postavchika from Postavchik where Kod_postavchika = '{supplierId}'")
         [1];
 }
예제 #3
0
 /// <summary>
 /// Обработчик нажатия кнопки "Сохранить изменения" для сохранения изменений в базе данных
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonSave_Click(object sender, EventArgs e)
 {
     if (Regex.IsMatch(richTextBox1.Text, @"^[a-zA-ZА-Яа-я.0-9]+$") &&
         Regex.IsMatch(richTextBox2.Text, @"^[a-zA-ZА-Яа-я]+$"))
     {
         SqlManager.ExecuteCommand(
             $"update [Postavchik] set Imy_postavchika = N'{richTextBox1.Text}', Gorod_postavchika = N'{richTextBox2.Text}' where Kod_postavchika='{_supplierId}'");
         MessageBox.Show("Изменения сохранены");
     }
     else
     {
         MessageBox.Show("Ошибка ввода данных");
     }
 }
예제 #4
0
        public AdminTT()
        {
            InitializeComponent();
            _tableData =
                SqlManager.ExecuteCommand("select Surname, [Name], SecondName, BirthDate, PhoneNumber from Customer");
            if (_tableData.Count == 0)
            {
                return;
            }

            for (int i = 0; i < _tableData.Count; i += 5)
            {
                string date         = Convert.ToDateTime(_tableData[i + 3]).ToString("d");
                var    customerData = _tableData[i] + " " + _tableData[i + 1][0] + "." + _tableData[i + 2][0] + ". " +
                                      date +
                                      " " +
                                      _tableData[i + 4];
                comboBox1.Items.Add(customerData);
                _phoneNumbers.Add(_tableData[i + 4]);
            }
        }
예제 #5
0
        /// <summary>
        /// Обработчик нажатия кнопки "Авторизоваться" для авторизации и перехода на следующую страницу в соответствии с ролью сотрудника
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonEnter_Click(object sender, EventArgs e)
        {
            var result = SqlManager.ExecuteCommand(
                $"select Kod_dolznosty from Sotrudnik where Login = '******' and Parol = '{textBoxPassword.Text}'");

            if (result.Count == 0)
            {
                MessageBox.Show("Пользователь не найден");
                return;
            }

            var roleId = result[0];

            if (roleId == null)
            {
                MessageBox.Show("У данного пользователя нет должности");
                return;
            }

            string role = SqlManager.ExecuteCommand(
                $"select Nazvanie_dolznosty from Dolznosty where Kod_dolznosty = '{roleId}'")[0];

            switch (role)
            {
            case "Администратор БД":
            {
                AdminBD newForm = new AdminBD();
                newForm.Show();
                Hide();
                break;
            }

            case "Администратор торговой точки":
            {
                AdminTT newForm = new AdminTT();
                newForm.Show();
                Hide();
                break;
            }

            case "Кладовщик":
            {
                Storekeeper newForm = new Storekeeper();
                newForm.Show();
                Hide();
                break;
            }

            case "Продавец":
            {
                var myId = SqlManager.ExecuteCommand(
                    $" select Kod_sotrudnika from Sotrudnik where [Login] = '{richTextBoxLogin.Text}'")[0];
                var sectionIdResult =
                    SqlManager.ExecuteCommand(
                        $"select Id_Ceksii_torgovoy_tochki from Ceksiya_torgovoy_tochki_Sotrudnik where Id_Sotrudnik = {myId}");

                if (sectionIdResult.Count == 0)
                {
                    MessageBox.Show("Данный пользователь не работает ни на одной точке");
                    return;
                }
                Seller newForm = new Seller(myId, sectionIdResult[0]);
                newForm.Show();
                Hide();
                break;
            }

            case "Менеджер секций":
            {
                SectionManager newForm = new SectionManager();
                newForm.Show();
                Hide();
                break;
            }

            case "Бухгалтер":
            {
                Bookkeeper newForm = new Bookkeeper();
                newForm.Show();
                Hide();
                break;
            }
            }
        }