Ejemplo n.º 1
0
        public DepartmentPresenter()
        {
            model = new Model.DepartmentModel();

            connection = new Class.Connection();
            ConnectionDB.FmConnectionDBView fmConnectionDBView
                = new ConnectionDB.FmConnectionDBView();
            ConnectionDBPresenter connectionDBPresenter
                = new ConnectionDBPresenter(fmConnectionDBView, connection);

            //Проверка на подключение к БД
            if (connectionDBPresenter.ShowDialog()
                == DialogResult.OK)
            {
                view = new FmDepartmentView();
            }
            else
            {
                view = null;
                return;
            }

            //Привязка событий
            view.LoadForm     += OnLoadForm;
            view.ChangingNode += OnChangingNode;
            view.DGVEmployees.DataSourceChanged += OnDataSourceChangeing;
            view.DGVEmployees.DataGridViewCellMouseDoubleClick += OnDataGridViewCellMouseDoubleClick;
            view.BtnEmployeeEdit.Click         += OnBtnEmployeeEditClick;
            view.BtnRefresh.Click              += OnBtnRefreshClick;
            view.DGVEmployees.SelectionChanged += OnSelectionChanged;
        }
Ejemplo n.º 2
0
        public override ResponseBase Handler(GetDepartmentRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException();
            }
            var service = ServiceProvider.GetService <IDepartmentService>();

            Model.DepartmentModel model = null;
            if (request.ID != 0)
            {
                model = service.Load(request.ID);
            }
            else if (!string.IsNullOrWhiteSpace(request.Name))
            {
                model = service.GetByName(request.Name);
            }
            return(new ResponseGeneric <Model.DepartmentModel>()
            {
                Result = 1, ResultInfo = "", Data = model
            });
        }