Beispiel #1
0
        /// <summary>
        /// Обработчик редактирования сотрудника
        /// </summary>
        public void EditEmployee()
        {
            if (IMain.curEmp == null)
            {
                return;
            }
            EditEmp EditEmpWindow = new EditEmp();

            IEmp             = EditEmpWindow;
            IEmp.depsList    = db;
            IEmp.selectDep   = IMain.curDep;
            IEmp.NameEmp     = IMain.curEmp.name;
            IEmp.SurameEmp   = IMain.curEmp.surname;
            IEmp.PositionEmp = IMain.curEmp.position;
            IEmp.BirthdayEmp = IMain.curEmp.birthday;
            EditEmpWindow.ShowDialog();
            if (EditEmpWindow.DialogResult.Value)
            {
                Employee newEmp = new Employee
                {
                    name     = IEmp.NameEmp,
                    surname  = IEmp.SurameEmp,
                    position = IEmp.PositionEmp,
                    birthday = IEmp.BirthdayEmp,
                    //Deparments=IEmp.selectDep,
                    depId = IEmp.selectDep.Id
                };
                if (post <Employee>(ref newEmp, $"editemployee/{IMain.curEmp.Id}"))
                {
                    IMain.curDep.Employee.Remove(IMain.curEmp);
                    IEmp.selectDep.Employee.Add(newEmp);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Обработчик добавления сотрудника
        /// </summary>
        public void AddEmployee()
        {
            EditEmp EditEmpWindow = new EditEmp();

            IEmp           = EditEmpWindow;
            IEmp.depsList  = db;
            IEmp.selectDep = IMain.curDep;
            EditEmpWindow.ShowDialog();
            if (EditEmpWindow.DialogResult.Value)
            {
                Employee newEmp = new Employee
                {
                    name     = IEmp.NameEmp,
                    surname  = IEmp.SurameEmp,
                    position = IEmp.PositionEmp,
                    birthday = IEmp.BirthdayEmp,
                    //Deparments=IEmp.selectDep,
                    depId = IEmp.selectDep.Id
                };
                if (post <Employee>(ref newEmp, $"addemployee"))
                {
                    IEmp.selectDep.Employee.Add(newEmp);
                }
            }
        }