Пример #1
0
        public void EditEntity(AvgAmount amount)
        {
            AvgAmount am = amount;

            if (amount == null && FocusedEntity == null)
            {
                return;
            }

            if (am == null)
            {
                am = FocusedEntity;
            }
            if (am == null)
            {
                return;            // paranoik check
            }
            using (YearlyAppearanceForm form = new YearlyAppearanceForm())
            {
                form.Amount = am;

                if (form.ShowDialog() == DialogResult.OK)
                {
                    _bindingWeeks.ResetItemById(am.ID);
                }
            }
        }
Пример #2
0
        public void DeleteEntity(AvgAmount amount)
        {
            AvgAmount am = amount;

            if (am == null && FocusedEntity == null)
            {
                return;
            }
            am = FocusedEntity;

            if (QuestionMessageYes(GetLocalized("SureToRemoveYearAppearance") + String.Format(" ({0})", am.Year)))
            {
                try
                {
                    ClientEnvironment.CountryService.AvgAmountService.DeleteByID(am.ID);

                    AvgAmount removing = _bindingWeeks.GetItemByID(am.ID);
                    if (removing != null)
                    {
                        _bindingWeeks.Remove(removing);
                        UpdateButtonEnable();
                    }
                }
                catch (ValidationException)
                {
                    ErrorMessage("CantDeleteYearlyAppearance");
                    return;
                }
                catch (EntityException ex)
                {
                    ProcessEntityException(ex);
                    return;
                }
            }
        }
        private void FillCommonInfoForWorld(WorldPlanningInfo worldinfo, StoreToWorld storeworld, DateTime begin, DateTime end)
        {
            short year = (short)DateTimeHelper.GetYearByDate(begin);

            PersonMinMax personMinMax = ExStoreToWorld.GetPersonMinMax(storeworld, year);

            WorldAvailableBufferHoursManager availBufferHours = new WorldAvailableBufferHoursManager(storeworld, begin);

            AvgAmount avgamount = _avgamountservice.GetAvgAmountByYear(CountryId, year);

            worldinfo.StoreWorldId = storeworld.ID;
            if (personMinMax != null)
            {
                worldinfo.MinimumPresence = personMinMax.Min;
                worldinfo.MaximumPresence = personMinMax.Max;
            }
            if (availBufferHours.BufferHours != null && availBufferHours.BufferHours.Value != 0)
            {
                worldinfo.AvailableWorldBufferHours = Convert.ToInt32(availBufferHours.GetPrevAvailableBufferForWeek(begin) +
                                                                      availBufferHours.BufferHoursPerWeek);
            }
            else
            {
                worldinfo.AvailableWorldBufferHours = Int32.MinValue;
            }

            if (!worldinfo.IsCashDesk)
            {
                Benchmark benchmark = ExStoreToWorld.GetBenchmark(storeworld, year);//_benchmarkservice.GetBenchmark(storeworld.ID, year);
                if (benchmark != null)
                {
                    worldinfo.Benchmark = benchmark.Value;
                }
            }
        }
Пример #4
0
        AvgAmount GetEntityByRowHandle(int rowHandle)
        {
            AvgAmount entity = null;

            if (gridViewYearly.IsDataRow(rowHandle))
            {
                entity = (AvgAmount)gridViewYearly.GetRow(rowHandle);
            }
            return(entity);
        }
Пример #5
0
        private void gridControl_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (!isUserWriteRight)
            {
                return;
            }
            GridHitInfo info = gridViewYearly.CalcHitInfo(e.X, e.Y);

            if (info.InRowCell && gridViewYearly.IsDataRow(info.RowHandle))
            {
                AvgAmount amount = GetEntityByRowHandle(info.RowHandle);
                if (amount != null && bi_EditYearlyAppearance.Enabled)
                {
                    EditEntity(amount);
                }
            }
        }
Пример #6
0
        public void NewEntity()
        {
            AvgAmount amount = ClientEnvironment.AvgAmountService.CreateEntity();

            amount.CountryID = EntityCountry.ID;

            using (YearlyAppearanceForm form = new YearlyAppearanceForm())
            {
                form.Amount = amount;

                if (form.ShowDialog() == DialogResult.OK)
                {
                    _bindingWeeks.Add(form.Amount);
                    UpdateButtonEnable();
                }
            }
        }
Пример #7
0
 public bool FileterByCountryAndYear(AvgAmount weeks)
 {
     return(CountryID == weeks.CountryID && Year == weeks.Year);
 }
Пример #8
0
 public bool FileterByCountry(AvgAmount weeks)
 {
     return(CountryID == weeks.CountryID);
 }
Пример #9
0
        public override bool Commit()
        {
            if (Amount == null)
            {
                return(false);
            }


            if (IsModified())
            {
                AvgAmount am = ClientEnvironment.CountryService.AvgAmountService.CreateEntity();

                AvgAmount.CopyTo(Amount, am);

                am.Year            = Year;
                am.AvgWeeks        = Weeks;
                am.AvgContractTime = AvgHoursPerDay;
                am.CashDeskAmount  = CashDeskAmount;
                am.AvgRestingTime  = AvgRestingTime;
                try
                {
                    if (Amount.IsNew)
                    {
                        if (!CheckExistingEntityByYear(am.Year, am.CountryID))
                        {
                            am = ClientEnvironment.AvgAmountService.Save(am);
                        }
                        else
                        {
                            ErrorMessage(GetLocalized("YearExist"));
                            return(false);
                        }
                    }
                    else
                    {
                        if (CheckExistingEntityByYear(am.Year, am.CountryID) && am.Year != Amount.Year)
                        {
                            ErrorMessage(GetLocalized("YearExist"));
                            return(false);
                        }

                        else
                        {
                            ClientEnvironment.AvgAmountService.SaveOrUpdate(am);
                        }
                    }


                    AvgAmount.CopyTo(am, Amount);

                    Modified = true;

                    return(base.Commit());
                }

                catch (ValidationException)
                {
                    ErrorMessage(GetLocalized("YearExist"));
                }

                catch (EntityException ex)
                {
                    ErrorMessage(GetLocalized("ErrorImportPropExistsForYear"));
                    ProcessEntityException(ex);
                }

                catch (Exception e)
                {
                    ErrorMessage(e.Message);
                }
            }
            return(false);
        }