Пример #1
0
        public MainWindow()
        {
            InitializeComponent();

            p = new Presenter(this);

            //Initialize cbDepList
            ObservableCollection <Department> depList = p.GetDepList();

            foreach (var dep in depList)
            {
                cbDepartmentsList.Items.Add($"{dep.Name}, {dep.Location}, {dep.Salary}");
            }

            ////Dep
            btnNewDep.Click    += delegate { p.AddDepartment(); };
            btnDeleteDep.Click += delegate { p.DeleteDepartment(); };


            ////Emp
            btnNewEmp.Click             += delegate { p.AddEmployee(); };
            btnDeleteEmp.Click          += delegate { p.DeleteEmployee(); };
            lvEmployee.SelectionChanged += delegate { p.RefreshDepartmentsListOnEMP(); };
            btnAddDepToEMP.Click        += delegate { p.AddDepartmentToEMP(); };
            btnDelDepFromEMP.Click      += delegate { p.DeleteDepartmentFromEMP(); };
        }
Пример #2
0
        private void btnAddEmployee_Click(object sender, EventArgs e)
        {
            if (IdNbr != "")
            {
                try {
                    presenter.AddEmployee();
                    if (notifyUpdate != null)
                    {
                        notifyUpdate();
                    }
                    this.Close();
                }

                catch (SqlException e1)
                {
                    lblError.Text = ErrorHandler.GetErrorMessage(e1.Number);
                }

                catch (Exception)
                {
                    lblError.Text = ErrorHandler.GetGenericErrorMessage();
                }
            }
            else
            {
                lblError.Text = "Please enter an Employee Id.";
            }
        }
 public HttpResponseMessage Post([FromBody] Employee value)
 {
     if (pr.AddEmployee(value))
     {
         return(Request.CreateResponse(HttpStatusCode.Created));
     }
     else
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest));
     }
 }