Beispiel #1
0
        private void DeleteEntity()
        {
            if (EntityStore == null)
            {
                return;
            }

            TrendCorrection trend = FocusedEntity;

            if (trend == null)
            {
                return;
            }

            if (QuestionMessageYes(GetLocalized("QuestionDeleteTrendCorrection")))
            {
                try
                {
                    ClientEnvironment.StoreService.TrendCorrectionService.DeleteByID(trend.ID);

                    _listTrends.RemoveEntityById(trend.ID);
                    UpdateButtonState();
                }
                catch (EntityException)
                {
                    ErrorMessage(GetLocalized("CantDeleteTrendCorrection"), GetLocalized("Attention"));
                    return;
                }
            }
        }
Beispiel #2
0
        bool InsertTrend()
        {
            if (ValidateEntity())
            {
                TrendCorrection trend = CreateEntity();

                try
                {
                    trend = ClientEnvironment.StoreService.TrendCorrectionService.Save(trend);

                    StoreToWorld sw = (StoreToWorld)lookUpWorlds.Properties.GetDataSourceRowByKeyValue(StoreWorldId);

                    if (sw != null)
                    {
                        trend.WorldName = sw.WorldName;
                    }

                    _entity   = trend;
                    _modified = true;
                    return(true);
                }
                catch (ValidationException)
                {
                    ErrorMessage(GetLocalized("ErrorTrendCorrectionRangeIntersect"), GetLocalized("Attention"));
                }
            }

            return(false);
        }
Beispiel #3
0
        private void EditEntity()
        {
            TrendCorrection bh = FocusedEntity;

            if (bh == null || SWController == null || EntityStore == null)
            {
                return;
            }

            // Edit can now trendcorrection, can't edit last EndTime < Today
            if (CanEditEntity())
            {
                using (FormTrendCorrection formEdit = new FormTrendCorrection())
                {
                    List <StoreToWorld> lst = SWController.GetListByStoreId(EntityStore.ID);

                    formEdit.SetStoreWorlds(lst);
                    formEdit.EntityStore = EntityStore;

                    formEdit.SetReadOnly();
                    formEdit.Entity = bh;

                    if (formEdit.ShowDialog() == DialogResult.OK)
                    {
                        TrendCorrectionList.ResetItemById(bh.ID);
                    }
                }
            }
        }
Beispiel #4
0
 void CopyEntity(TrendCorrection source, TrendCorrection dest)
 {
     dest.StoreWorldID = source.StoreWorldID;
     dest.Name         = source.Name;
     dest.BeginTime    = source.BeginTime;
     dest.EndTime      = source.EndTime;
     dest.Value        = source.Value;
     dest.ID           = source.ID;
 }
Beispiel #5
0
        TrendCorrection CreateEntity()
        {
            TrendCorrection trend = ClientEnvironment.StoreService.TrendCorrectionService.CreateEntity();

            trend.StoreWorldID = StoreWorldId;
            trend.BeginTime    = StartDate;
            trend.EndTime      = EndDate;
            trend.Name         = TrendCorrectionName;
            trend.Value        = Value;

            if (EntityTrend != null)
            {
                trend.ID = EntityTrend.ID;
            }
            return(trend);
        }
Beispiel #6
0
        private void gridControl_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (!EditEnabled)
            {
                return;
            }
            GridHitInfo info = gridViewEntities.CalcHitInfo(e.X, e.Y);

            if (info.InRowCell && gridViewEntities.IsDataRow(info.RowHandle))
            {
                TrendCorrection entity = EntityFromRowHandle(info.RowHandle);
                if (entity != null)
                {
                    EditEntity();
                }
            }
        }
Beispiel #7
0
        public double GetTrendCorrection(long storeworldid, DateTime date)
        {
            if (_listEntities == null || _listEntities.Count == 0)
            {
                return(1);
            }


            if (_cache_entity != null)
            {
                if (_cache_entity.StoreWorldID == storeworldid &&
                    DateTimeHelper.Between(date, _cache_entity.BeginTime, _cache_entity.EndTime))
                {
                    return(_cache_entity.Value);
                }

                _cache_entity = null;
            }

            TrendCorrection trend = _listEntities.Find(delegate(TrendCorrection trend1)
            {
                if (trend1.StoreWorldID == storeworldid)
                {
                    return(DateTimeHelper.Between(date, trend1.BeginTime, trend1.EndTime));
                }
                else
                {
                    return(false);
                }
            }
                                                       );

            _cache_entity = trend;
            //foreach (TrendCorrection trend in _listEntities)
            //{
            //    if (DateTimeHelper.IsHitInInterval(date, trend.BeginTime, trend.EndTime))
            //        return trend.Value;
            //}

            return((trend != null) ? trend.Value : 1);
        }
Beispiel #8
0
        bool UpdateTrend()
        {
            if (ValidateEntity())
            {
                TrendCorrection trend = CreateEntity();

                try
                {
                    trend = ClientEnvironment.StoreService.TrendCorrectionService.SaveOrUpdate(trend);

                    CopyEntity(trend, EntityTrend);
                    _modified = true;
                    return(true);
                }
                catch (ValidationException)
                {
                    ErrorMessage(GetLocalized("ErrorTrendCorrectionRangeIntersect"), GetLocalized("Attention"));
                }
            }
            return(false);
        }