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(); }
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; } } }
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(); }