Exemplo n.º 1
0
        private void FireChangedFocusedTreeNode()
        {
            BaseTreeItem item = treeList.GetDataRecordByNode(treeList.FocusedNode) as BaseTreeItem;

            if (item != null)
            {
                HwgrTreeItem hw = item as HwgrTreeItem;
                if (hw != null)
                {
                    m_context.WorldToHwgr = hw.Hwgr;
                }
                else
                {
                    WgrTreeItem w = item as WgrTreeItem;
                    if (w != null)
                    {
                        foreach (BaseTreeItem parent in treeList.DataSource as BindingTemplate <BaseTreeItem> )
                        {
                            if (parent.ID == w.ParentID)
                            {
                                m_context.WorldToHwgr = (parent as HwgrTreeItem).Hwgr;
                                break;
                            }
                        }
                        m_context.HwgrToWgr = w.Wgr;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void NewAssignWgrToHwgr()
        {
            WgrTreeItem item = null;

            if (IsWgrFocused)
            {
                item = FocusedEntity as WgrTreeItem;
            }

            HwgrToWgr newitem = new HwgrToWgr();

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

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

                if (form.ShowDialog() == DialogResult.OK)
                {
                    treeList.BeginUpdate();
                    m_context.TakeStoreStructure.ReBuildByWgr(newitem, (treeList.DataSource as BindingTemplate <BaseTreeItem>));
                    EntityChanged();
                    treeList.EndUpdate();
                }
            }
        }
Exemplo n.º 3
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);
        }