Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 4
0
        AvgAmount GetEntityByRowHandle(int rowHandle)
        {
            AvgAmount entity = null;

            if (gridViewYearly.IsDataRow(rowHandle))
            {
                entity = (AvgAmount)gridViewYearly.GetRow(rowHandle);
            }
            return(entity);
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 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();
                }
            }
        }
Ejemplo n.º 7
0
 public bool FileterByCountryAndYear(AvgAmount weeks)
 {
     return(CountryID == weeks.CountryID && Year == weeks.Year);
 }
Ejemplo n.º 8
0
 public bool FileterByCountry(AvgAmount weeks)
 {
     return(CountryID == weeks.CountryID);
 }
Ejemplo n.º 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);
        }