예제 #1
0
 public static int GetWeekStepValue(BufferHours entity)
 {
     return((int)Math.Round(entity.Value * 60 / DateTimeHelper.GetCountWeekInYear(entity.Year)));
 }
예제 #2
0
 public static int GetWeekStepValue(BufferHours entity)
 {
     return (int)Math.Round(entity.Value * 60 / DateTimeHelper.GetCountWeekInYear(entity.Year));
 }
예제 #3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (StoreWorldId != -1)
            {
                if (Entity == null)
                {
                    BufferHours bh = new BufferHours();
                    bh.StoreWorldID = StoreWorldId;
                    bh.Year = Year;
                    bh.Value = Value;
                    bh.ValueWeek = BufferHours.GetWeekStepValue(bh);// Value / DateTimeHelper.GetCountWeekInYear(Year);
                    try
                    {
                       List<BufferHours> cols = ClientEnvironment.StoreService.BufferHoursService.GetBufferHoursFiltered(_store.ID, Year, Year);
                        if (cols == null || cols.Count == 0 || !CheckExistStoreWorldID(bh.StoreWorldID, cols))
                        {
                            bh = ClientEnvironment.StoreService.BufferHoursService.ValidateAndUpdate(bh);

                            if (bh != null)
                            {
                                StoreToWorld sw = (StoreToWorld)lookUpWorlds.Properties.GetDataSourceRowByKeyValue(StoreWorldId);

                                if (sw != null) bh.WorldName = sw.WorldName;
                                _entity = bh;

                                DialogResult = DialogResult.OK;
                            }
                            else
                                throw new DBDuplicateKeyException();
                        }
                        else throw new DBDuplicateKeyException();

                    }
                    catch (DBDuplicateKeyException)
                    {
                        XtraMessageBox.Show(UILocalizer.Current["WorldYearBufferHoursExist"],
                            UILocalizer.Current["Attention"], MessageBoxButtons.OK, MessageBoxIcon.Error);
                        seYear.Focus();
                        return;
                    }
                }
                else
                {
                    BufferHours bh = new BufferHours();
                    bh.ID = Entity.ID;
                    bh.StoreWorldID = StoreWorldId;
                    bh.Year = Year;
                    bh.Value = Value;
                    bh.ValueWeek = BufferHours.GetWeekStepValue(bh);// Value / DateTimeHelper.GetCountWeekInYear(Year);
                    try
                    {
                        bh = ClientEnvironment.StoreService.BufferHoursService.ValidateAndUpdate(bh);

                        Entity.ID = bh.ID;
                        Entity.StoreWorldID = StoreWorldId;
                        Entity.Year = Year;
                        Entity.Value = Value;
                        Entity.ValueWeek = BufferHours.GetWeekStepValue (bh);
                        DialogResult = DialogResult.OK;
                    }
                    catch (ValidationException)
                    {
                        XtraMessageBox.Show(UILocalizer.Current["WorldYearBufferHoursExist"],
                                                    UILocalizer.Current["Attention"], MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    catch (EntityException)
                    {

                        XtraMessageBox.Show(UILocalizer.Current["BufferHoursNotExist"],
                            UILocalizer.Current["Attention"], MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }
            else
            {
                XtraMessageBox.Show(UILocalizer.Current["ErrorSelectWorld"]);
            }
        }