示例#1
0
 private void gridView_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
 {
     if (m_isHwgr)
     {
         WorldToHwgr row = gridView.GetRow(e.RowHandle) as WorldToHwgr;
         if (e.IsGetData && row != null)
         {
             if (e.Column == gc_Parent)
             {
                 e.Value = m_context.TakeStoreStructure.GetWorld(row.WorldID).Name;
             }
         }
     }
     else
     {
         HwgrToWgr row = gridView.GetRow(e.RowHandle) as HwgrToWgr;
         if (e.IsGetData && row != null)
         {
             if (e.Column == gc_Parent)
             {
                 e.Value = m_context.TakeStoreStructure.GetHwgr(row).Name;
             }
         }
     }
 }
示例#2
0
 public _HwgrToWorld(WorldToHwgr entity)
 {
     _entity = entity;
     if (!_entity.IsNew)
     {
         _state = RecordState.UnModified;
     }
 }
示例#3
0
            public _HwgrToWorld CreateCopy()
            {
                WorldToHwgr wth = new WorldToHwgr();

                BaseEntity.CopyTo(_entity, wth);
                wth.ID = 0;
                return(new _HwgrToWorld(wth));
            }
示例#4
0
        public AssignResult HWGRToWorldAssign(long storeID, long world_id, long hwgr_id, DateTime beginTime,
                                              DateTime endTime)
        {
            AssignResult result = new AssignResult();

            result.Result = AResult.Error;
            using (IDbCommand command = CreateCommand())
            {
                command.CommandText = "spHWGR_World_Assign";
                command.CommandType = CommandType.StoredProcedure;
                SqlParameter p1 = new SqlParameter("@StoreID", SqlDbType.BigInt, 8);
                p1.Value = storeID;
                command.Parameters.Add(p1);
                SqlParameter p2 = new SqlParameter("@World_ID", SqlDbType.BigInt, 8);
                p2.Value = world_id;
                command.Parameters.Add(p2);
                SqlParameter p3 = new SqlParameter("@HWGR_ID", SqlDbType.BigInt, 8);
                p3.Value = hwgr_id;
                command.Parameters.Add(p3);
                SqlParameter p4 = new SqlParameter("@BeginTime", SqlDbType.SmallDateTime, 4);
                p4.Value = beginTime;
                command.Parameters.Add(p4);
                SqlParameter p5 = new SqlParameter("@EndTime", SqlDbType.SmallDateTime, 4);
                p5.Value = endTime;
                command.Parameters.Add(p5);
                SqlParameter importResult = new SqlParameter("@result", SqlDbType.Int, 4);
                importResult.Direction = ParameterDirection.Output;
                command.Parameters.Add(importResult);
                using (IDataReader reader = command.ExecuteReader(CommandBehavior.SequentialAccess))
                {
                    List <WorldToHwgr> list = new List <WorldToHwgr>();
                    while (reader.Read())
                    {
                        WorldToHwgr value = new WorldToHwgr();
                        value.ID        = reader.GetInt64(0);
                        value.StoreID   = reader.GetInt64(1);
                        value.WorldID   = reader.GetInt64(2);
                        value.HWGR_ID   = reader.GetInt64(3);
                        value.BeginTime = reader.GetDateTime(4);
                        value.EndTime   = reader.GetDateTime(5);
                        value.Import    = reader.GetBoolean(6);
                        list.Add(value);
                    }
                    reader.NextResult();
                    int res = (int)importResult.Value;
                    if (res < 0)
                    {
                        result.Result = AResult.Error;
                    }
                    result.Data = list;
                }
            }
            _WorldToHwgrDao.OnDaoInvalidateWholeCache();
            return(result);
        }
示例#5
0
        public override bool Commit()
        {
            long        worldID = (long)edWorld.EditValue;
            WorldToHwgr attach  = ClientEnvironment.WorldToHWGRService.CreateEntity();

            attach.BeginTime = uc.BeginTime;
            attach.EndTime   = uc.EndTime;
            attach.HWGR_ID   = (long)EditHWGR.EditValue;
            attach.Import    = false;
            attach.StoreID   = worldID;
            m_entityName     = EditHWGR.Text;
            m_attached       = attach = ClientEnvironment.WorldToHWGRService.Save(attach);

            return(true);
        }
示例#6
0
        internal static HWGR GetHwgrEntity(WorldToHwgr hwgr)
        {
            HWGR entity = GetHWGRByID(hwgr.HWGR_ID);

            if (entity == null)
            {
                foreach (HWGR var in Instance.m_diction.Values)
                {
                    if (var.ID == hwgr.HWGR_ID)
                    {
                        entity = var;
                        break;
                    }
                }
            }
            return(entity);
        }
示例#7
0
        public WorldToHwgr GetEntityByHwgrAndDate(long worldid, long hwgrid, DateTime date)
        {
            WorldToHwgr wth = null;

            for (int i = 0; i < _innerlist.Count; i++)
            {
                wth = _innerlist[i];
                if (wth.WorldID == worldid && wth.HWGR_ID == hwgrid)
                {
                    if (wth.BeginTime.Date <= date && date <= wth.EndTime.Date)
                    {
                        return(wth);
                    }
                }
            }
            return(null);
        }
示例#8
0
        public void ReBuildByHwgr(long hwgrid, BindingTemplate <BaseTreeItem> lst)
        {
            if (lst != null && lst.Count > 0)
            {
                WorldToHwgr entity = hwgrList.GetEntityByHwgrAndDate(WorldID, hwgrid, m_filterDate);

                for (int i = 0; i < lst.Count; i++)
                {
                    if (lst[i].IsHwgr)
                    {
                        HwgrTreeItem item = (lst[i] as HwgrTreeItem);
                        if (item.Hwgr.HWGR_ID == hwgrid)
                        {
                            if (entity != null)
                            {
                                item.Hwgr = entity;
                            }
                            else
                            {
                                RemoveChilds(item.ID, lst);
                                lst.Remove(item);
                                lst.ClearRemoveList();
                            }
                            return;
                        }
                    }
                }
                // new item
                if (entity != null)
                {
                    HwgrTreeItem item = new HwgrTreeItem(entity, 0);
                    lst.Add(item);
                    foreach (HwgrToWgr htw in wgrList)
                    {
                        if (htw.HWGR_ID == hwgrid)
                        {
                            if (htw.BeginTime.Date <= m_filterDate && m_filterDate <= htw.EndTime.Date)
                            {
                                lst.Add(new WgrTreeItem(htw, item.ID));
                            }
                        }
                    }
                }
            }
        }
示例#9
0
        public List <WorldToHwgr> GetHwgrByWorldAndDate(long worldid, DateTime date)
        {
            List <WorldToHwgr> resultList = new List <WorldToHwgr>(10);
            WorldToHwgr        wth        = null;

            for (int i = 0; i < _innerlist.Count; i++)
            {
                wth = _innerlist[i];
                if (wth.WorldID == worldid)
                {
                    if (wth.BeginTime.Date <= date && date <= wth.EndTime.Date)
                    {
                        resultList.Add(wth);
                    }
                }
            }
            return(resultList);
        }
示例#10
0
        protected void StopWorkingHwgr()
        {
            dragHWGR.EndTime = DateTime.Now;

            try
            {
                WorldToHwgr first = ClientEnvironment.WorldToHWGRService.FindById(dragHWGR.ID);
                if (first != null)
                {
                    first.EndTime = DateTime.Now;
                    ClientEnvironment.WorldToHWGRService.SaveOrUpdate(first);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, ex.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#11
0
        protected override void EntityChanged()
        {
            WorldToHwgr hwgr = Entity as WorldToHwgr;
            HwgrToWgr   wgr  = Entity as HwgrToWgr;

            if (hwgr != null)
            {
                List <WorldToHwgr> list = ClientEnvironment.WorldToHWGRService
                                          .GetWorldToHwgrFiltered(hwgr.StoreID, hwgr.WorldID, hwgr.HWGR_ID);
                gridControl.DataSource = list;

                lbCaption.Text = string.Format("{0} -> {1} -> {2}",
                                               ClientEnvironment.StoreService.FindById(hwgr.StoreID).Name,
                                               ClientEnvironment.WorldService.FindById(hwgr.WorldID).Name,
                                               ClientEnvironment.HWGRService.FindById(hwgr.HWGR_ID).Name);
            }
            else if (wgr != null)
            {
            }
        }
示例#12
0
        public void NewAssignHwgrToWorld()
        {
            HwgrTreeItem item = null;

            if (IsHwgrFocused)
            {
                item = FocusedEntity as HwgrTreeItem;
            }

            WorldToHwgr newitem = new WorldToHwgr();

            newitem.StoreID = m_context.Store.ID;
            if (item != null)
            {
                newitem.HWGR_ID   = item.Hwgr.HWGR_ID;
                newitem.WorldID   = item.Hwgr.WorldID;
                newitem.BeginTime = DateTimeHelper.GetNextMonday(DateTime.Today);
                newitem.EndTime   = DateTimeSql.SmallDatetimeMax;
            }
            else
            {
                newitem.BeginTime = DateTime.Today;
                newitem.EndTime   = DateTimeSql.SmallDatetimeMax;
                newitem.HWGR_ID   = m_context.WorldToHwgr.HWGR_ID;
                newitem.WorldID   = m_context.WorldToHwgr.WorldID;
            }

            using (FormAssignHwgrToWorld form = new FormAssignHwgrToWorld())
            {
                form.Context = m_context;
                form.Entity  = newitem;

                if (form.ShowDialog() == DialogResult.OK)
                {
                    treeList.BeginUpdate();
                    m_context.TakeStoreStructure.ReBuildByHwgr(newitem.HWGR_ID, (treeList.DataSource as BindingTemplate <BaseTreeItem>));
                    EntityChanged();
                    treeList.EndUpdate();
                }
            }
        }
示例#13
0
        /* private void CopyEntity(WorldToHwgr source, WorldToHwgr dest)
         * {
         *
         *   dest.ID = source.ID;
         *   dest.HWGR_ID = source.HWGR_ID;
         *   dest.HwgrName = source.HwgrName;
         *   dest.Import = source.Import;
         *   dest.StoreID = source.StoreID;
         *   dest.WorldID = source.WorldID;
         *   dest.BeginTime = source.BeginTime;
         *   dest.EndTime = source.EndTime;
         *
         * }
         */
        public override bool Commit()
        {
            if (IsValid())
            {
                if (IsModified())
                {
                    WorldToHwgr entity = new WorldToHwgr();
                    WorldToHwgr.CopyTo(EntityWorldToHwgr, entity);
                    //CopyEntity(EntityWorldToHwgr, entity);
                    entity.ID        = 0;
                    entity.WorldID   = WorldId;
                    entity.HWGR_ID   = HwgrId;
                    entity.BeginTime = BeginTime;
                    entity.EndTime   = EndTime;
                    try
                    {
                        List <WorldToHwgr> lst = ClientEnvironment.WorldToHWGRService.InsertRelation(entity);
                        if (lst != null)
                        {
                            Context.TakeStoreStructure.MergeWorldToHwgr(lst);
                        }

                        //CopyEntity(entity, EntityWorldToHwgr);
                        WorldToHwgr.CopyTo(entity, EntityWorldToHwgr);
                        EntityWorldToHwgr.HwgrName = hwgrLookUpCtrl.Text;
                        Modified = true;
                        return(base.Commit());
                    }
                    catch (ValidationException)
                    {
                        ErrorMessage(GetLocalized("ErrorDateRangeIntersect"));
                        return(false);
                    }
                }
                else
                {
                    return(base.Commit());
                }
            }
            return(false);
        }
示例#14
0
 public HWGR GetHwgr(WorldToHwgr hwgr)
 {
     return(HwgrManager.GetHwgrEntity(hwgr));
 }
示例#15
0
        public override bool Commit()
        {
            try
            {
                DateTime begin = BeginTime, end = EndTime;
                Utility.AssignWeek(ref begin, ref end);
                BeginTime = begin;
                EndTime   = end;
                switch (m_assignEnum)
                {
                case AssignEnum.ThisHwgrToWgr:
                case AssignEnum.ThisWgrToHWGR:
                    HwgrToWgr assign = ClientEnvironment.HwgrToWgrService.CreateEntity();
                    assign.BeginTime = BeginTime;
                    assign.EndTime   = EndTime;
                    assign.HWGR_ID   = (long)edParent.EditValue;
                    assign.Import    = false;
                    assign.StoreID   = m_storeID;
                    assign.WGR_ID    = (long)edChild.EditValue;
                    ClientEnvironment.HwgrToWgrService.Save(assign);
                    m_assigned = new WgrTreeItem(assign, assign.HWGR_ID);
                    break;

                case AssignEnum.ThisHwgrToWorld:
                    WorldToHwgr assign2 = ClientEnvironment.WorldToHWGRService.CreateEntity();
                    assign2.BeginTime = BeginTime;
                    assign2.EndTime   = EndTime;
                    assign2.HWGR_ID   = (long)edChild.EditValue;
                    assign2.Import    = false;
                    assign2.StoreID   = m_storeID;
                    assign2.WorldID   = (Entity as WorldToHwgr).WorldID;
                    ClientEnvironment.WorldToHWGRService.Save(assign2);
                    m_assigned = new HwgrTreeItem(assign2, 0);
                    break;

                case AssignEnum.WorldHwgrDisable:
                    DateTime t1 = timeRange.BeginTime,
                             t2 = timeRange.EndTime;
                    Utility.AssignWeek(ref begin, ref end);
                    timeRange.BeginTime = t1;
                    timeRange.EndTime   = t2;

                    WorldToHwgr vice  = Entity as WorldToHwgr;
                    WorldToHwgr first = ClientEnvironment.WorldToHWGRService.FindById(vice.ID);
                    first.BeginTime = timeRange.BeginTime;
                    first.EndTime   = timeRange.EndTime;

                    ClientEnvironment.WorldToHWGRService.Update(first);
                    break;

                case AssignEnum.HwgrWgrDisable:
                    HwgrToWgr        vice2  = Entity as HwgrToWgr;
                    Domain.HwgrToWgr first2 = ClientEnvironment.HwgrToWgrService.FindById(vice2.ID);
                    first2.EndTime   = timeRange.EndTime;
                    first2.BeginTime = timeRange.BeginTime;

                    ClientEnvironment.HwgrToWgrService.Update(first2);
                    break;
                }
            }
            catch (ValidationException)
            {
                XtraMessageBox.Show(Baumax.Localization.Localizer.GetLocalized("InvalidTimeRange"));
                return(false);
            }/*
              * catch (Exception ex)
              * {
              * XtraMessageBox.Show (ex.Message);
              * return false;
              * }*/
            return(true);
        }
示例#16
0
        public override bool Commit()
        {
            try
            {
                DateTime begin = timeRange.BeginTime,
                         end   = timeRange.EndTime;
                Utility.AssignWeek(ref begin, ref end);
                timeRange.BeginTime = begin;
                timeRange.EndTime   = end;


                if (m_vice is HwgrTreeItem)
                {
                    HwgrTreeItem vice = m_vice as HwgrTreeItem;

                    List <WorldToHwgr> saveList = new List <WorldToHwgr>();
                    WorldToHwgr        first    = ClientEnvironment.WorldToHWGRService.FindById(vice.Hwgr.ID);

                    saveList.Add(first);

                    if (first.Import)
                    {
                        first.EndTime = DateTime.Now;
                        WorldToHwgr second = ClientEnvironment.WorldToHWGRService.CreateEntity();
                        second.Import    = false;
                        second.BeginTime = timeRange.BeginTime;
                        second.EndTime   = timeRange.EndTime;
                        second.HWGR_ID   = vice.Hwgr.HWGR_ID;
                        second.WorldID   = vice.Hwgr.WorldID;
                        second.StoreID   = m_storeID;
                        saveList.Add(second);

                        if (vice.EndTime > timeRange.EndTime)
                        {
                            WorldToHwgr third = ClientEnvironment.WorldToHWGRService.CreateEntity();
                            third.Import    = true;
                            third.BeginTime = timeRange.EndTime + m_oneSecond;
                            third.EndTime   = m_endTime;
                            third.HWGR_ID   = vice.Hwgr.HWGR_ID;
                            third.WorldID   = vice.Hwgr.WorldID;
                            third.StoreID   = m_storeID;
                            saveList.Add(third);
                        }
                    }
                    else
                    {
                        first.BeginTime = timeRange.BeginTime;
                        first.EndTime   = timeRange.EndTime;
                    }
                    ClientEnvironment.WorldToHWGRService.SaveOrUpdateList(saveList);
                }
                else
                {
                    WgrTreeItem vice = m_vice as WgrTreeItem;

                    List <Domain.HwgrToWgr> saveList = new List <HwgrToWgr>();
                    Domain.HwgrToWgr        first    = ClientEnvironment.HwgrToWgrService.FindById(vice.Wgr.ID);

                    saveList.Add(first);

                    if (first.Import)
                    {
                        first.EndTime = DateTime.Now;
                        Domain.HwgrToWgr second = ClientEnvironment.HwgrToWgrService.CreateEntity();
                        second.Import    = false;
                        second.BeginTime = timeRange.BeginTime;
                        second.EndTime   = timeRange.EndTime;
                        second.WGR_ID    = vice.Wgr.WGR_ID;
                        second.HWGR_ID   = vice.Wgr.HWGR_ID;
                        second.StoreID   = m_storeID;
                        saveList.Add(second);

                        if (vice.EndTime > timeRange.EndTime)
                        {
                            Domain.HwgrToWgr third = ClientEnvironment.HwgrToWgrService.CreateEntity();
                            third.Import    = true;
                            third.BeginTime = timeRange.EndTime + m_oneSecond;
                            third.EndTime   = m_endTime;
                            third.WGR_ID    = vice.Wgr.WGR_ID;
                            third.HWGR_ID   = vice.Wgr.HWGR_ID;
                            third.StoreID   = m_storeID;
                            saveList.Add(third);
                        }
                    }
                    else
                    {
                        first.EndTime   = timeRange.EndTime;
                        first.BeginTime = timeRange.BeginTime;
                    }
                    ClientEnvironment.HwgrToWgrService.SaveOrUpdateList(saveList);
                }
            }
            catch
            {
                return(false);
            }
            return(true);
        }
示例#17
0
 public static void FillWorldToHwgr(WorldToHwgr entity)
 {
     entity.HwgrName = Instance.GetHwgrName(entity.HWGR_ID);
 }
示例#18
0
 public HwgrTreeItem(WorldToHwgr entity, long parentID)
     : base(entity, parentID)
 {
     ID = _nextID++;
 }
示例#19
0
 public HwgrDateRangeManager(IWorldToHwgrDao dao, WorldToHwgr newentity)
     : this(dao)
 {
     _entity = newentity;
 }