Пример #1
0
        private void CreateTreeView(TreeList fld_trlstUserGroup, List <ADUserGroupsInfo> lstNodeName, TreeListNode ParentNode)
        {
            fld_trlstUserGroup.BeginUnboundLoad();
            TreeListNode treeListNode;

            treeListNode = fld_trlstUserGroup.AppendNode(new object[] { "Nhóm người dùng", 0 }, ParentNode);
            for (int i = 0; i < lstNodeName.Count; i++)
            {
                treeListNode             = fld_trlstUserGroup.AppendNode(new object[] { lstNodeName[i].ADUserGroupName, 1 }, 0);
                treeListNode.Tag         = lstNodeName[i].ADUserGroupID;
                treeListNode.HasChildren = HasChild(lstNodeName[i].ADUserGroupID);

                if (treeListNode.HasChildren)
                {
                    ADUserGroupSectionsController objUserGroupSectionsController = new ADUserGroupSectionsController();
                    DataSet dsUserGroupChild = objUserGroupSectionsController.GetUserGroupSectionByUserGroupID(lstNodeName[i].ADUserGroupID);
                    if (dsUserGroupChild != null)
                    {
                        foreach (DataRow row in dsUserGroupChild.Tables[0].Rows)
                        {
                            ADUserGroupSectionsInfo objADUserGroupSectionsInfo = (ADUserGroupSectionsInfo)objUserGroupSectionsController.GetObjectFromDataRow(row);
                            if (objADUserGroupSectionsInfo != null)
                            {
                                TreeListNode treeListChildNode = fld_trlstUserGroup.AppendNode(new object[] { objADUserGroupSectionsInfo.ADUserGroupSectionName, treeListNode.Level + 1 }, treeListNode);
                                treeListChildNode.Tag = objADUserGroupSectionsInfo.ADUserGroupSectionID;
                                AddModuleNode(fld_trlstUserGroup, objADUserGroupSectionsInfo.ADUserGroupSectionID, treeListChildNode);
                            }
                        }
                    }
                }
            }
            fld_trlstUserGroup.EndUnboundLoad();
        }
Пример #2
0
        public void InitializeModuleSection()
        {
            TreeListNode node = treeList.FocusedNode;

            if (node != null)
            {
                ADUserGroupSectionsController objUserGroupSectionsController = new ADUserGroupSectionsController();
                ADUserGroupSectionsInfo       objADUserGroupSectionsInfo     = (ADUserGroupSectionsInfo)objUserGroupSectionsController.GetObjectByID(Convert.ToInt32(node.Tag));
                if (objADUserGroupSectionsInfo != null)
                {
                    STModuleToUserGroupSectionsController objModuleToUserGroupSectionsController = new STModuleToUserGroupSectionsController();
                    DataSet ds = objModuleToUserGroupSectionsController.GetAllModuleToUserGroupSectionByUserGroupSectionID(objADUserGroupSectionsInfo.ADUserGroupSectionID);
                    if (ds != null)
                    {
                        foreach (DataRow row in ds.Tables[0].Rows)
                        {
                            STModuleToUserGroupSectionsInfo objSTModuleToUserGroupSectionsInfo = (STModuleToUserGroupSectionsInfo) new STModuleToUserGroupSectionsController().GetObjectFromDataRow(row);
                            if (objADUserGroupSectionsInfo != null)
                            {
                                STModulesInfo objSTModulesInfo = (STModulesInfo) new STModulesController().GetObjectByID(objSTModuleToUserGroupSectionsInfo.FK_STModuleID);
                                if (objSTModulesInfo != null)
                                {
                                    lstModule.Add(objSTModulesInfo);
                                }
                            }
                        }
                    }
                }
            }
            fld_dgcModuleActivesGridControl.DataSource = lstModule;
            fld_dgcModuleActivesGridControl.RefreshDataSource();
        }
Пример #3
0
        private void fld_btnAddSection_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(fld_txtSection.Text))
            {
                MessageBox.Show("Tên nhóm module không được để trống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            ADUserGroupSectionsController objUserGroupSectionsController = new ADUserGroupSectionsController();

            if (Mode == AddSectionMode.Add)
            {
                ADUserGroupSectionsInfo objADUserGroupSectionsInfo = new ADUserGroupSectionsInfo();
                objADUserGroupSectionsInfo.FK_ADUserGroupID       = Convert.ToInt32(TreeList.FocusedNode.Tag);
                objADUserGroupSectionsInfo.ADUserGroupSectionName = fld_txtSection.Text;
                objADUserGroupSectionsInfo.ADUserGroupSectionDesc = objADUserGroupSectionsInfo.ADUserGroupSectionName;
                int maxOrder = objUserGroupSectionsController.GetMaxSortOrderSectionByUserGroupID(objADUserGroupSectionsInfo.FK_ADUserGroupID);
                objADUserGroupSectionsInfo.ADUserGroupSectionSortOrder = maxOrder + 1;
                objUserGroupSectionsController.CreateObject(objADUserGroupSectionsInfo);
            }
            else if (Mode == AddSectionMode.Edit)
            {
                ADUserGroupSectionsInfo objADUserGroupSectionsInfo = (ADUserGroupSectionsInfo)objUserGroupSectionsController.GetObjectByID(Convert.ToInt32(TreeList.FocusedNode.Tag));
                objADUserGroupSectionsInfo.ADUserGroupSectionName = fld_txtSection.Text;
                objADUserGroupSectionsInfo.ADUserGroupSectionDesc = fld_txtSection.Text;
                objUserGroupSectionsController.UpdateObject(objADUserGroupSectionsInfo);
            }
            ((UserManagementModule)this.Module).InitializeTreeList(TreeList);
            this.Close();
        }
Пример #4
0
        public bool HasChild(int iUserGroupID)
        {
            DataSet ds = new ADUserGroupSectionsController().GetAllDataByForeignColumn("ADUserGroupID", iUserGroupID);

            if (ds != null)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #5
0
        private void fld_trlstUserGroup_DragDrop(object sender, DragEventArgs e)
        {
            TreeListHitInfo hitInfo    = fld_treeUserGroup.CalcHitInfo(fld_treeUserGroup.PointToClient(new Point(e.X, e.Y)));
            TreeListNode    targetNode = hitInfo.Node;
            TreeListNode    sourceNode = downHitInfo.Node;

            if (targetNode != null)
            {
                if (targetNode.Level == 3 && sourceNode.Level == 3 && targetNode.ParentNode == sourceNode.ParentNode)
                {
                    STModuleToUserGroupSectionsController objSTModuleToUserGroupSectionController = new STModuleToUserGroupSectionsController();
                    STModuleToUserGroupSectionsInfo       objModuleToUserGroupSectionsInfoSource  = (STModuleToUserGroupSectionsInfo)objSTModuleToUserGroupSectionController.GetModuleToUserGroupSectionByUserGroupSectionIDAndModuleID((int)sourceNode.ParentNode.Tag, (int)sourceNode.Tag);
                    STModuleToUserGroupSectionsInfo       objModuleToUserGroupSectionsInfoTarget  = (STModuleToUserGroupSectionsInfo)objSTModuleToUserGroupSectionController.GetModuleToUserGroupSectionByUserGroupSectionIDAndModuleID((int)targetNode.ParentNode.Tag, (int)targetNode.Tag);

                    int sortOrderSrc = objModuleToUserGroupSectionsInfoSource.STModuleToUserGroupSectionSortOrder;
                    objModuleToUserGroupSectionsInfoSource.STModuleToUserGroupSectionSortOrder = objModuleToUserGroupSectionsInfoTarget.STModuleToUserGroupSectionSortOrder;
                    objModuleToUserGroupSectionsInfoTarget.STModuleToUserGroupSectionSortOrder = sortOrderSrc;

                    //Update
                    objSTModuleToUserGroupSectionController.UpdateObject(objModuleToUserGroupSectionsInfoSource);
                    objSTModuleToUserGroupSectionController.UpdateObject(objModuleToUserGroupSectionsInfoTarget);
                    ((UserManagementModule)Module).InitializeTreeList(fld_treeUserGroup);
                }
                else if (targetNode.Level == 2 && sourceNode.Level == 2 && targetNode.ParentNode == sourceNode.ParentNode)
                {
                    ADUserGroupSectionsController objUserGroupSectionsController = new ADUserGroupSectionsController();
                    ADUserGroupSectionsInfo       objUserGroupSectionsInfoSource = (ADUserGroupSectionsInfo)objUserGroupSectionsController.GetObjectByID((int)sourceNode.Tag);
                    ADUserGroupSectionsInfo       objUserGroupSectionsInfoTarget = (ADUserGroupSectionsInfo)objUserGroupSectionsController.GetObjectByID((int)targetNode.Tag);

                    int sortOrderSrc = objUserGroupSectionsInfoSource.ADUserGroupSectionSortOrder;
                    objUserGroupSectionsInfoSource.ADUserGroupSectionSortOrder = objUserGroupSectionsInfoTarget.ADUserGroupSectionSortOrder;
                    objUserGroupSectionsInfoTarget.ADUserGroupSectionSortOrder = sortOrderSrc;

                    //Update
                    objUserGroupSectionsController.UpdateObject(objUserGroupSectionsInfoSource);
                    objUserGroupSectionsController.UpdateObject(objUserGroupSectionsInfoTarget);
                    ((UserManagementModule)Module).InitializeTreeList(fld_treeUserGroup);
                }
                else
                {
                    return;
                }
            }
        }
Пример #6
0
        private void DeleteSection_Clicked(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có muốn xóa nhóm module này không", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                TreeListNode node = fld_treeUserGroup.FocusedNode;
                ADUserGroupSectionsController         objUserGroupSectionsController         = new ADUserGroupSectionsController();
                STModuleToUserGroupSectionsController objModuleToUserGroupSectionsController = new STModuleToUserGroupSectionsController();

                DataSet ds = objModuleToUserGroupSectionsController.GetAllModuleToUserGroupSectionByUserGroupSectionID((int)node.Tag);
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    STModuleToUserGroupSectionsInfo objModuleToUserGroupSectionsInfo = (STModuleToUserGroupSectionsInfo)objModuleToUserGroupSectionsController.GetObjectFromDataRow(row);
                    objModuleToUserGroupSectionsController.DeleteObject(objModuleToUserGroupSectionsInfo.STModuleToUserGroupSectionID);
                }

                objUserGroupSectionsController.DeleteObject((int)node.Tag);
                ((UserManagementModule)Module).InitializeTreeList(fld_treeUserGroup);
            }
        }