Пример #1
0
        private async void ButtonAdd_Click(object sender, EventArgs e)
        {
            UsersGridWidthChange();
            if (!VerifyTextBoxes(out var fio, out var login, out var password, out var salary))
            {
                return;
            }

            var user = new Models.Worker()
            {
                FIO      = fio,
                Login    = login,
                Password = password,
                Role     = comboBoxRole.SelectedIndex == 0 ? "accountant" :
                           comboBoxRole.SelectedIndex == 1 ? "manager" :
                           comboBoxRole.SelectedIndex == 2 ? "archivarius" :
                           "admin",
                Salary = Convert.ToSingle(salary)
            };

            if (await _workersRepository.GetWorker(login) != null)
            {
                MessageBox.Show("Пользователь с таким логином уже существует.");
                return;
            }

            await _workersRepository.CreateWorker(user);

            await UpdateDataGridView();
        }