コード例 #1
0
        private void OpenFmEmployeeEdit()
        {
            int indexRow   = view.DGVEmployees.SelectedRowIndex;
            int EmployeeID = view.DGVEmployees.GetEmployeeID(indexRow);

            Data.EmployeeInfo employeeInfo = connection.GetEmployeeByID(EmployeeID);

            //Если этого сотрудника нет в базе
            if (employeeInfo == null)
            {
                view.DGVEmployees.RemoveAt(indexRow);
                Class.Messages.NotFound();
                return;
            }

            //Обновить редактируему запись
            model.UpdateEmployeeInfo(view.DGVEmployees.SelectedRow, employeeInfo);

            IEmployeeCardView employeeCardView
                = new FmEmployeeCard();
            EmployeeCardPresenter employeeCardPresenter
                = new EmployeeCardPresenter(employeeCardView, employeeInfo);

            if (employeeCardPresenter.ShowDialog()
                == DialogResult.OK)
            {
                if (connection.UpdateEmployee(employeeInfo, view.TVDepartment.SelectedNodeID)
                    == Class.CommandStatus.NotFound)
                {
                    Class.Messages.NotFound();
                    view.DGVEmployees.RemoveAt(indexRow);
                }
                else if (connection.UpdateEmployee(employeeInfo, view.TVDepartment.SelectedNodeID)
                         == Class.CommandStatus.Updated)
                {
                    model.UpdateEmployeeInfo(view.DGVEmployees.SelectedRow, employeeInfo);
                }
            }
        }