public Employee(DbEmployee employee, Action refreshTable, string depName)
        {
            this.employee     = employee;
            this.refreshTable = refreshTable;
            this.depName      = depName;

            InitializeComponent();

            if (employee == null)
            {
                this.Text             = "AddNewEmployee";
                EmployeeGroupBox.Text = "Добавить данные";
            }
            else
            {
                this.Text             = "EditEmployee";
                EmployeeGroupBox.Text = "Редактировать данные";
            }

            DepartmentComboBox.DataSource    = departmentRepository.GetAllDepartments();
            DepartmentComboBox.ValueMember   = "ID";
            DepartmentComboBox.DisplayMember = "Name";

            LineLengthSetting();
            InitializeTextBox();

            DepartmentComboBox.SelectedIndex = DepartmentComboBox.FindStringExact(depName);
        }
Example #2
0
        private bool isFormValid()
        {
            if (StudentNameTextBox.Text.Trim() == string.Empty)
            {
                SMSMessageBox.ShowErrorMessage("Name is required");
                StudentNameTextBox.Focus();
                return(false);
            }

            if (PhoneNumberTextBox.Text.Trim() == string.Empty)
            {
                SMSMessageBox.ShowErrorMessage("Phone number is required");
                PhoneNumberTextBox.Focus();
                return(false);
            }

            if (DepartmentComboBox.SelectedIndex == -1)
            {
                SMSMessageBox.ShowErrorMessage("Department is required");
                DepartmentComboBox.Focus();
                return(false);
            }

            return(true);
        }