private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            UserModel userModel = new UserModel(tbxFirstName.Text, tbxLastName.Text,
                                                tbxPasswordFirst.Password, tbxEmail.Text, tbxTele.Text);

            if (AddUser.ValidateAddUser(tbxFirstName, tbxLastName,
                                        tbxPasswordFirst, tbxPasswordSecond, tbxEmail, tbxTele))
            {
                if (cbxBoss.IsChecked == true)
                {
                    AddUser.AddBoss(userModel);
                    AddUser.ClearText(tbxFirstName, tbxLastName,
                                      tbxPasswordFirst, tbxPasswordSecond, tbxEmail, tbxTele, cbxBoss);
                    cbUser.Items.Clear();
                    HandleItems.FillUserList(cbUser);
                }
                else
                {
                    AddUser.AddNewUser(userModel);
                    AddUser.ClearText(tbxFirstName, tbxLastName,
                                      tbxPasswordFirst, tbxPasswordSecond, tbxEmail, tbxTele, cbxBoss);
                    cbUser.Items.Clear();
                    HandleItems.FillUserList(cbUser);
                }
            }
        }
Пример #2
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                var user = new User
                {
                    Name         = nameTextBox.Text,
                    Surname      = surnameTextBox.Text,
                    GarageNumber = Convert.ToInt32(garageTextBox.Text),
                    CarNumber    = carTextBox.Text,
                    Phone        = phoneTextBox.Text,
                    Birthday     = (DateTime) new DateTimeConverter().ConvertFromString(birthDayTextBox.Text)
                };

                AddUser.AddNewUser(user, cardTextBox.Text);
                DialogResult result = MessageBox.Show("Успех!", "Успех!", MessageBoxButtons.OK);
            }
            catch (Exception)
            {
                DialogResult result = MessageBox.Show("Ошибка!", "Ошибка!", MessageBoxButtons.OK);
            }
        }