Beispiel #1
0
 private void SaveButton_Click(object sender, EventArgs e)
 {
     if (!ValidValue())
     {
         StateLabel.Text = "Не корректные данные";
         return;
     }
     _selectedEmployee.DateOfBirth = BirthDayDateTimePicker.Value;
     _selectedEmployee.FirstName   = NameTextBox.Text;
     _selectedEmployee.SurName     = SurNameTextBox.Text;
     _selectedEmployee.Patronymic  = PatronymicTextBox.Text;
     _selectedEmployee.Position    = PositionTextBox.Text;
     _selectedEmployee.DocNumber   = DocNumberTextBox.Text;
     _selectedEmployee.DocSeries   = DocSeriesTextBox.Text;
     _db.SaveChanges();
     Changed?.Invoke();
     Close();
 }
Beispiel #2
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(NameTextBox.Text) || string.IsNullOrEmpty(CodeTextBox.Text))
            {
                return;
            }
            var newDepartment = new Department()
            {
                ID = Guid.NewGuid(),
                ParentDepartmentID = _perentDepartmentId,
                Name = NameTextBox.Text,
                Code = CodeTextBox.Text
            };

            _db.Department.Add(newDepartment);
            _db.SaveChanges();
            Added?.Invoke();
            Close();
        }