Inheritance: INotifyPropertyChanging, INotifyPropertyChanged
コード例 #1
0
        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();

                    }

                }

            }
        }
コード例 #2
0
        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();
                 }
            }
        }
コード例 #3
0
 public BonusDecorator(Bonus bonus)
 {
     this.bonus = bonus;
 }
コード例 #4
0
 public void EditBonus(Bonus bonus)
 {
     LinqActionsController<Bonus>.Instance.EditObject(bonus, true);
 }
コード例 #5
0
        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);
        }
コード例 #6
0
        /// <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();
            }
        }
コード例 #7
0
 partial void DeleteBonus(Bonus instance);
コード例 #8
0
 partial void UpdateBonus(Bonus instance);
コード例 #9
0
 partial void InsertBonus(Bonus instance);
コード例 #10
0
		private void detach_Bonus(Bonus entity)
		{
			this.SendPropertyChanging();
			entity.BonusType = null;
		}
コード例 #11
0
		private void attach_Bonus(Bonus entity)
		{
			this.SendPropertyChanging();
			entity.BonusType = this;
		}
コード例 #12
0
		private void detach_Bonus(Bonus entity)
		{
			this.SendPropertyChanging();
			entity.FactStaff = null;
		}
コード例 #13
0
		private void attach_Bonus(Bonus entity)
		{
			this.SendPropertyChanging();
			entity.FactStaff = this;
		}