private void ApplyBtn_Click(object sender, EventArgs e) { foreach (FactStaff fcSt in KadrController.Instance.Model.FactStaffs) { if (fcSt.MonthHourCount > 0) { FactStaffMonthHour hour = new FactStaffMonthHour(); hour.MonthNumber = cbMonth.SelectedIndex + 1; hour.YearNumber = Convert.ToInt32(cbYear.SelectedItem); hour.HourCount = Convert.ToDecimal(fcSt.MonthHourCount); hour.FactStaff = fcSt; fcSt.MonthHourCount = null; KadrController.Instance.Model.FactStaffMonthHours.InsertOnSubmit(hour); KadrController.Instance.SubmitChanges(); //назначаем надбавку, если почасовик работает по договору if (fcSt.IsContractHourStaff) { Bonus bonus = new Bonus(); BonusHistory bonusHistory = new BonusHistory(); try { bonus.DateEnd = Convert.ToDateTime("01." + (cbMonth.SelectedIndex + 2).ToString() + '.' + cbYear.SelectedItem.ToString()).AddDays(-1); bonusHistory.DateBegin = Convert.ToDateTime("01." + (cbMonth.SelectedIndex + 1).ToString() + '.' + cbYear.SelectedItem.ToString()); } catch { bonus.DateEnd = null; } bonus.BonusType = BonusType.HourBonus; bonus.Comment = tbComment.Text; bonusHistory.BonusCount = hour.BonusSum.Value; bonusHistory.Prikaz = cbPrikazBegin.SelectedItem as Prikaz; if (cbFinancingSource.Text == "") bonusHistory.FinancingSource = fcSt.FinancingSource; else bonusHistory.FinancingSource = cbFinancingSource.SelectedItem as FinancingSource; bonusHistory.Bonus = bonus; BonusFactStaff bonusFcSt = new BonusFactStaff(); bonusFcSt.FactStaff = fcSt.MainFactStaff; bonusFcSt.Bonus = bonus; KadrController.Instance.Model.Bonus.InsertOnSubmit(bonus); KadrController.Instance.Model.BonusHistories.InsertOnSubmit(bonusHistory); KadrController.Instance.Model.BonusFactStaffs.InsertOnSubmit(bonusFcSt); KadrController.Instance.SubmitChanges(); } } } }
private void ApplyBtn_Click(object sender, EventArgs e) { foreach (FactStaff fcSt in KadrController.Instance.Model.FactStaffs) { if (fcSt.BonusCount > 0) { Bonus bonus = new Bonus(); try { bonus.DateEnd = Convert.ToDateTime(mtbDateEnd.Text); } catch { bonus.DateEnd = null; } if (cbPrikazIntermEnd.Text != "") bonus.IntermediateEndPrikaz = cbPrikazIntermEnd.SelectedItem as Prikaz; if (cbPrikazEnd.Text != "") bonus.EndPrikaz = cbPrikazEnd.SelectedItem as Prikaz; bonus.BonusType = cbBonusType.SelectedItem as BonusType; bonus.Comment = tbComment.Text; BonusHistory bonusHistory = new BonusHistory(); bonusHistory.BonusCount = fcSt.BonusCount.Value; if (fcSt.BonusFinancingSourceName != null) bonusHistory.FinancingSource = FinancingSource.GetFinancingSourceByName(fcSt.BonusFinancingSourceName); else { if (cbFinancingSource.Text == "") bonusHistory.FinancingSource = fcSt.FinancingSource; else bonusHistory.FinancingSource = cbFinancingSource.SelectedItem as FinancingSource; } if (fcSt.BonusDateBegin != null) bonusHistory.DateBegin = fcSt.BonusDateBegin.Value; else bonusHistory.DateBegin = dtDateBegin.Value; bonusHistory.Prikaz = cbPrikazBegin.SelectedItem as Prikaz; bonusHistory.Bonus = bonus; BonusFactStaff bonusFcSt = new BonusFactStaff(); bonusFcSt.FactStaff = fcSt; bonusFcSt.Bonus = bonus; fcSt.BonusCount = null; KadrController.Instance.SubmitChanges(); } } }
public BonusDecorator(Bonus bonus) { this.bonus = bonus; }
public void EditBonus(Bonus bonus) { LinqActionsController<Bonus>.Instance.EditObject(bonus, true); }
public void DeleteBonus(BindingSource bonusBindingSource, Bonus CurrentBonus = null) { if (CurrentBonus == null) CurrentBonus = bonusBindingSource.Current as Bonus; if (CurrentBonus == null) { MessageBox.Show("Не выбрана удаляемая надбавка.", "АИС \"Штатное расписание\""); return; } //если уже задана история (более одной записи), то нельзя удалить надбавку if (CurrentBonus.BonusHistories.Count > 1) { MessageBox.Show("У заданной надбавки есть история изменений. Сначала необходимо удалить историю.", "АИС \"Штатное расписание\""); return; } if (MessageBox.Show("Удалить надбавку?", "АИС Штатное расписание", MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } KadrController.Instance.Model.BonusHistories.DeleteAllOnSubmit(KadrController.Instance.Model.BonusHistories.Where(bonHist => bonHist.Bonus == CurrentBonus)); if (CurrentBonus.BonusFactStaff != null) KadrController.Instance.Model.BonusFactStaffs.DeleteOnSubmit(CurrentBonus.BonusFactStaff); if (CurrentBonus.BonusPlanStaff != null) KadrController.Instance.Model.BonusPlanStaffs.DeleteOnSubmit(CurrentBonus.BonusPlanStaff); if (CurrentBonus.BonusPost != null) KadrController.Instance.Model.BonusPosts.DeleteOnSubmit(CurrentBonus.BonusPost); LinqActionsController<Bonus>.Instance.DeleteObject(CurrentBonus, KadrController.Instance.Model.Bonus, bonusBindingSource); }
/// <summary> /// Создает новое изменение для надбавки /// </summary> /// <param name="currentBonus">Надбавка</param> public void CreateBonusChange(Bonus currentBonus) { if (currentBonus == null) { MessageBox.Show("Не выбран редактируемый объект.", "АИС \"Штатное расписание\""); return; } using (Kadr.UI.Common.PropertyGridDialogAdding<BonusHistory> dlg = new Kadr.UI.Common.PropertyGridDialogAdding<BonusHistory>()) { dlg.UseInternalCommandManager = true; dlg.ObjectList = KadrController.Instance.Model.BonusHistories; //dlg.BindingSource = planStaffBindingSource; dlg.PrikazButtonVisible = true; dlg.oneObjectCreated = true; dlg.InitializeNewObject = (x) => { dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<BonusHistory, decimal>(x, "BonusCount", currentBonus.LastBonusCount, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<BonusHistory, Prikaz>(x, "Prikaz", NullPrikaz.Instance, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<BonusHistory, FinancingSource>(x, "FinancingSource", currentBonus.LastFinancingSource, null), this); dlg.CommandManager.Execute(new UIX.Commands.GenericPropertyCommand<BonusHistory, Bonus>(x, "Bonus", currentBonus, null), this); }; dlg.UpdateObjectList = () => { dlg.ObjectList = KadrController.Instance.Model.BonusHistories; }; dlg.ShowDialog(); } }
partial void DeleteBonus(Bonus instance);
partial void UpdateBonus(Bonus instance);
partial void InsertBonus(Bonus instance);
private void detach_Bonus(Bonus entity) { this.SendPropertyChanging(); entity.BonusType = null; }
private void attach_Bonus(Bonus entity) { this.SendPropertyChanging(); entity.BonusType = this; }
private void detach_Bonus(Bonus entity) { this.SendPropertyChanging(); entity.FactStaff = null; }
private void attach_Bonus(Bonus entity) { this.SendPropertyChanging(); entity.FactStaff = this; }