예제 #1
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();
        }
예제 #2
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;
                }
            }
        }