Beispiel #1
0
        private void CreateEmployee_button_Click(object sender, EventArgs e)
        {
            var employeeInfo = new Employee
            {
                FirstName   = Name_textbox.Text,
                LastName    = Surnname_textbox.Text,
                Phone       = Phone_textbox.Text,
                Description = Details_textbox.Text
            };

            ;
            if (!EmployeeValidator.ValidateFirstOrSecondName(employeeInfo.FirstName))
            {
                NameErrorProvider.SetError(Name_textbox, "Name is not correct.");
            }
            if (!EmployeeValidator.ValidateFirstOrSecondName(employeeInfo.LastName))
            {
                SecondNameErrorProvider.SetError(Surnname_textbox, "Second name is not correct.");
            }
            if (!EmployeeValidator.ValidatePhoneNumber(employeeInfo.Phone, true))
            {
                PhoneNumberErrorProvider.SetError(Phone_textbox, $"Phone number is not correct.{Environment.NewLine}It should contain 10 digits.");
            }
            if (EmployeeValidator.IsValidClientInfo(employeeInfo))
            {
                EmployeeHelper.InsertEmployeeInfo(employeeInfo);
                ClearForm();
                MessageLabel.Show();
                MessageLabel.Text = "Client info was successfully saved!";
                //Thread.Sleep(2000);//queeck dummy way))) TODO: change!
                //MessageLabel.Text = string.Empty;
            }
        }
Beispiel #2
0
 private void ClearForm_button_Click(object sender, EventArgs e)
 {
     ClearForm();
     NameErrorProvider.Clear();
     SecondNameErrorProvider.Clear();
     PhoneNumberErrorProvider.Clear();
     MessageLabel.Hide();
 }