public FactStaffHistoryReplacementDecorator(FactStaffHistory factStaffHistory) { this.factStaffHistory = factStaffHistory; }
public FactStaffHistoryDecorator(FactStaffHistory factStaffHistory) { this.factStaffHistory = factStaffHistory; }
private void AddReplacementBtn_Click(object sender, EventArgs e) { if (factStaffBindingSource.Current == null) { MessageBox.Show("Выберите сотрудника, которого нужно заместить.", "АИС Штатное расписание", MessageBoxButtons.OK); return; } if ((factStaffBindingSource.Current as FactStaff).Prikaz!=null) { MessageBox.Show("Совмещаемый сотрудник уже уволен!", "АИС Штатное расписание", MessageBoxButtons.OK); return; } FactStaff currentFactStaff = factStaffBindingSource.Current as FactStaff; using (Kadr.UI.Common.PropertyGridDialogAdding<FactStaffReplacement> dlg = new Kadr.UI.Common.PropertyGridDialogAdding<FactStaffReplacement>()) { dlg.ObjectList = KadrController.Instance.Model.FactStaffReplacements; dlg.BindingSource = null; dlg.UseInternalCommandManager = true; dlg.InitializeNewObject = (x) => { FactStaff factStaff = new FactStaff(); FactStaffHistory fcStHistory = new FactStaffHistory(); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, PlanStaff>(factStaff, "PlanStaff", currentFactStaff.PlanStaff, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffHistory, WorkType>(fcStHistory, "WorkType", KadrController.Instance.Model.WorkTypes.Where(wtp => wtp.IsReplacement).FirstOrDefault(), null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, Employee>(factStaff, "Employee", NullEmployee.Instance, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffHistory, Prikaz>(fcStHistory, "Prikaz", NullPrikaz.Instance, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, bool>(factStaff, "IsReplacement", true, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffHistory, FactStaff>(fcStHistory, "FactStaff", factStaff, null), this); //вычисляем то кол-во ставок, которое еще не замещено decimal ReplStaffCount = currentFactStaff.StaffCount; foreach (FactStaffReplacement repl in currentFactStaff.FactStaffReplacements) { if (repl.FactStaff1.Prikaz == null) ReplStaffCount -= repl.FactStaff1.StaffCount; } dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffHistory, decimal>(fcStHistory, "StaffCount", ReplStaffCount, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffReplacement, FactStaff>(x, "FactStaff1", factStaff, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffReplacement, FactStaff>(x, "FactStaff", currentFactStaff, null), this); if ((dlg.SelectedObjects != null) && (dlg.SelectedObjects.Length == 1)) { FactStaffReplacement prev = dlg.SelectedObjects[0] as FactStaffReplacement; dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffReplacement, FactStaffReplacementReason>(x, "FactStaffReplacementReason", prev.FactStaffReplacementReason, null), this); } else { dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffReplacement, FactStaffReplacementReason>(x, "FactStaffReplacementReason", NullFactStaffReplacementReason.Instance, null), this); } }; dlg.ShowDialog(); } LoadFactStaff(); }
private void AddFactStaffBtn_Click(object sender, EventArgs e) { using (Kadr.UI.Common.PropertyGridDialogAdding<FactStaff> dlg = new Kadr.UI.Common.PropertyGridDialogAdding<FactStaff>()) { dlg.ObjectList = KadrController.Instance.Model.FactStaffs; dlg.BindingSource = factStaffBindingSource; dlg.UseInternalCommandManager = true; dlg.PrikazButtonVisible = true; dlg.InitializeNewObject = (x) => { FactStaffHistory fcStHistory = new FactStaffHistory(); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, PlanStaff>(x, "PlanStaff", planStaffBindingSource.Current as PlanStaff, null), this); if ((dlg.SelectedObjects != null) && (dlg.SelectedObjects.Length == 1)) { FactStaff prev = dlg.SelectedObjects[0] as FactStaff; //dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffHistory, DateTime?>(fcStHistory, "DateBegin", prev.LastChange.DateBegin, null), this); //dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffHistory, Prikaz>(fcStHistory, "Prikaz", prev.PrikazBegin, null), this); //dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffHistory, WorkType>(fcStHistory, "WorkType", prev.WorkType, null), this); //dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffHistory, decimal>(fcStHistory, "StaffCount", prev.StaffCount, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, DateTime?>(x, "DateBegin", prev.DateBegin, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, Prikaz>(x, "PrikazBegin", prev.PrikazBegin, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, WorkType>(x, "WorkType", prev.WorkType, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, decimal>(x, "StaffCount", prev.StaffCount, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, Employee>(x, "Employee", NullEmployee.Instance, null), this); } else { dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffHistory, Prikaz>(fcStHistory, "Prikaz", NullPrikaz.Instance, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffHistory, WorkType>(fcStHistory, "WorkType", NullWorkType.Instance, null), this); //dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, Prikaz>(x, "PrikazBegin", NullPrikaz.Instance, null), this); //dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, WorkType>(x, "WorkType", NullWorkType.Instance, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, Employee>(x, "Employee", NullEmployee.Instance, null), this); } dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, bool>(x, "IsReplacement", false, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffHistory, FactStaff>(fcStHistory, "FactStaff", x, null), this); }; dlg.UpdateObjectList = () => { dlg.ObjectList = KadrController.Instance.Model.FactStaffs; }; dlg.ShowDialog(); LoadFactStaff(); } }
private void AddHourFactStaffBtn_Click(object sender, EventArgs e) { /*KadrController.Instance.AddFactStaff(hourFactStaffBindingSource, null, Department, Kadr.Data.WorkType.hourWorkType);*/ using (Kadr.UI.Common.PropertyGridDialogAdding<FactStaffHour> dlg = new Kadr.UI.Common.PropertyGridDialogAdding<FactStaffHour>()) { dlg.ObjectList = null; dlg.BindingSource = hourFactStaffBindingSource; dlg.UseInternalCommandManager = true; dlg.PrikazButtonVisible = true; dlg.InitializeNewObject = (x) => { FactStaffHistory fcStHistory = new FactStaffHistory(); //dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, Dep>(x, "Dep", (planStaffBindingSource.Current as PlanStaff).Dep, null), this); if ((dlg.SelectedObjects != null) && (dlg.SelectedObjects.Length == 1)) { FactStaff prev = (dlg.SelectedObjects[0] as FactStaffHour).FactStaff; //dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffHistory, DateTime?>(fcStHistory, "DateBegin", prev.LastChange.DateBegin, null), this); //dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffHistory, Prikaz>(fcStHistory, "Prikaz", prev.PrikazBegin, null), this); //dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffHistory, WorkType>(fcStHistory, "WorkType", prev.WorkType, null), this); //dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffHistory, decimal>(fcStHistory, "StaffCount", prev.StaffCount, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, DateTime?>(x.FactStaff, "DateBegin", prev.DateBegin, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, Prikaz>(x.FactStaff, "PrikazBegin", prev.PrikazBegin, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, decimal>(x.FactStaff, "StaffCount", prev.StaffCount, null), this); } else { dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffHistory, Prikaz>(fcStHistory, "Prikaz", NullPrikaz.Instance, null), this); //dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, Prikaz>(x, "PrikazBegin", NullPrikaz.Instance, null), this); //dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, WorkType>(x, "WorkType", NullWorkType.Instance, null), this); } dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, bool>(x.FactStaff, "IsReplacement", false, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, Employee>(x.FactStaff, "Employee", NullEmployee.Instance, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffHistory, WorkType>(fcStHistory, "WorkType", Kadr.Data.WorkType.hourWorkType, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, Dep>(x.FactStaff, "Dep", Department, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, FundingCenter>(x.FactStaff, "FundingCenter", NullFundingCenter.Instance, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaff, FinancingSource>(x.FactStaff, "FinancingSource", Kadr.Data.FinancingSource.budgetFinancingSource, null), this); //dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffHistory, decimal>(fcStHistory, "SalaryKoeff", 1, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<FactStaffHistory, FactStaff>(fcStHistory, "FactStaff", x.FactStaff, null), this); }; /*dlg.UpdateObjectList = () => { dlg.ObjectList = KadrController.Instance.Model.FactStaffs; };*/ dlg.ShowDialog(); } LoadHourFactStaff(); //tcDepartment_SelectedIndexChanged(null, null); }