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(); } } } }
public FactStaffMonthHourDecorator(FactStaffMonthHour factStaffMonthHour) { this.factStaffMonthHour = factStaffMonthHour; }