예제 #1
0
파일: AdminForm.cs 프로젝트: hong1975/wats
        void AdminForm_onUpdateRegionSuccessfully(UpdateRegionResult result, object context)
        {
            DataCenter.Instance().GlobalRegion.Version = result.NewVer;
            if (UpdateRegionType.AddRegion.ToString().Equals(result.Type))
            {
                if (DataCenter.Instance().GlobalRegion.Root.Sub == null)
                    DataCenter.Instance().GlobalRegion.Root.Sub = new List<SubRegion>();

                DataCenter.Instance().GlobalRegion.Root.Sub.Add(result.Region);
                TreeNode regionNode = mGlobalNode.Nodes.Add(result.Region.Name);
                regionNode.SelectedImageIndex = regionNode.ImageIndex = PIC_REGION;
                regionNode.Tag = result.Region;

                TreeNode managersNode = regionNode.Nodes.Add("Managers");
                managersNode.Tag = new UsersModel();
                managersNode.SelectedImageIndex = managersNode.ImageIndex = PIC_MANAGERS;

                RegionTreeView.SelectedNode = regionNode;
                regionNode.ExpandAll();
            }
            else if (UpdateRegionType.RenameRegion.ToString().Equals(result.Type))
            {
                TreeNode regionNode = (TreeNode)context;
                regionNode.Text = result.Region.Name;
                ((SubRegion)regionNode.Tag).Name = result.Region.Name;
            }
            else if (UpdateRegionType.RemoveRegion.ToString().Equals(result.Type))
            {
                TreeNode regionNode = (TreeNode)context;
                SubRegion removedRegion = (SubRegion)regionNode.Tag;
                ((SubRegion)regionNode.Parent.Tag).Sub.Remove(removedRegion);
                regionNode.Remove();
            }
            else if (UpdateRegionType.AddManager.ToString().Equals(result.Type))
            {
                TreeNode managersNode = (TreeNode)context;
                SubRegion region = (SubRegion)managersNode.Parent.Tag;
                TreeNode managerNode;
                foreach (string manager in result.Region.Manager)
                {
                    managerNode = managersNode.Nodes.Add(manager);
                    managerNode.SelectedImageIndex = managerNode.ImageIndex = PIC_MANAGER;

                    ((UsersModel)managersNode.Tag).Add(manager);
                    region.Manager.Add(manager);
                }
            }
            else if (UpdateRegionType.RemoveManager.ToString().Equals(result.Type))
            {
                TreeNode managerNode = (TreeNode)context;
                TreeNode managersNode = managerNode.Parent;
                SubRegion region = (SubRegion)managersNode.Parent.Tag;

                string removedManager = result.Region.Manager[0];
                ((UsersModel)managersNode.Tag).Remove(removedManager);
                region.Manager.Remove(removedManager);
                managerNode.Remove();
            }
        }
예제 #2
0
        void MoveTaskAlertForm_onUpdateRegionSuccessfully(UpdateRegionResult result, object context)
        {
            if (!UpdateRegionType.MoveTasksToNewRegion.ToString().Equals(result.Type))
                return;

            mSuccess = true;
            Close();
        }