private void fld_btnAddUserGroup_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(fld_txtUserGroup.Text)) { MessageBox.Show("Tên nhóm không được bỏ trống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ADUserGroupsController objUserGroupsController = new ADUserGroupsController(); if (Mode == AddUserGroupMode.Add) { ADUserGroupsInfo objADUserGroupsInfo = new ADUserGroupsInfo(); objADUserGroupsInfo.ADUserGroupName = fld_txtUserGroup.Text; objADUserGroupsInfo.ADUserGroupDesc = fld_txtUserGroup.Text; objUserGroupsController.CreateObject(objADUserGroupsInfo); } else if (Mode == AddUserGroupMode.Edit) { ADUserGroupsInfo objADUserGroupsInfo = (ADUserGroupsInfo)objUserGroupsController.GetObjectByID(Convert.ToInt32(TreeList.FocusedNode.Tag)); objADUserGroupsInfo.ADUserGroupName = fld_txtUserGroup.Text; objADUserGroupsInfo.ADUserGroupDesc = fld_txtUserGroup.Text; objUserGroupsController.UpdateObject(objADUserGroupsInfo); } ((UserManagementModule)this.Module).InitializeTreeList(TreeList); this.Close(); }
private void DeleteUserGroup_Clicked(object sender, EventArgs e) { if (MessageBox.Show("Bạn có muốn xóa nhóm người dùng này không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { TreeListNode node = fld_treeUserGroup.FocusedNode; ADUserGroupsController objUserGroupsController = new ADUserGroupsController(); ADUserGroupsInfo objUserGroupsInfo = (ADUserGroupsInfo)objUserGroupsController.GetObjectByID((int)node.Tag); objUserGroupsController.DeleteObject(objUserGroupsInfo.ADUserGroupID); ((UserManagementModule)Module).InitializeTreeList(fld_treeUserGroup); } }
public void InitializeTreeList(TreeList fld_trlstUserGroup) { List <ADUserGroupsInfo> lstNode = new List <ADUserGroupsInfo>(); TreeListNode prevFocusedNode = fld_trlstUserGroup.FocusedNode; fld_trlstUserGroup.Nodes.Clear(); ADUserGroupsController objADUserGroupsController = new ADUserGroupsController(); DataSet dsADUserGroups = objADUserGroupsController.GetAllObjects(); if (dsADUserGroups != null) { foreach (DataRow row in dsADUserGroups.Tables[0].Rows) { ADUserGroupsInfo objADUserGroupsInfo = (ADUserGroupsInfo)objADUserGroupsController.GetObjectFromDataRow(row); if (objADUserGroupsInfo != null) { lstNode.Add(objADUserGroupsInfo); } } } CreateTreeView(fld_trlstUserGroup, lstNode, null); if (prevFocusedNode != null) { TreeListNode currentFocusedNode = fld_trlstUserGroup.FindNodeByID(prevFocusedNode.Id); while (currentFocusedNode != null) { if (currentFocusedNode.Level > 0) { currentFocusedNode.ExpandAll(); } else { currentFocusedNode.Expanded = true; } currentFocusedNode = currentFocusedNode.ParentNode; } } }
public Dictionary <List <STGridColumnsInfo>, DataSet> ShowModuleByJournal(String strSourceLeger, String strDocumentNo, ADInboxItemsInfo objInbox, STFieldsInfo objOldField) { STModulesController ModuleCtrl = new STModulesController(); STModuleTablesController ModuleTableCtrl = new STModuleTablesController(); int iMainObjectID = -1; String strTable = String.Empty; String strTablePrefix = String.Empty; String strPrimaryKey = String.Empty; Object MainObj = null; int iModuleID = 0; List <DataRow> dr = GetLocalDataSet("STModuleID,STModuleName", "STModules", string.Format("STModuleName = '{0}'", strSourceLeger)); if (dr.Count > 0) { iModuleID = Convert.ToInt32(dr.First()["STModuleID"]); } dr = GetLocalDataSet("STModuleTableID,STModuleTableName,STModuleID,STModuleTableLevelIndex", "STModuleTables", string.Format("STModuleID = {0} AND STModuleTableLevelIndex = 0", iModuleID)); if (dr.Count > 0) { strTable = dr.First()["STModuleTableName"].ToString(); } if (String.IsNullOrEmpty(strTable) == false) { strTablePrefix = strTable.Substring(0, strTable.Length - 1); strPrimaryKey = strTablePrefix + "ID"; } BaseBusinessController Ctrl = BusinessControllerFactory.GetBusinessController(strTable + "Controller"); if (Ctrl != null) { MainObj = Ctrl.GetObjectByNo(strDocumentNo); } if (MainObj != null) { iMainObjectID = Convert.ToInt32(GMCDbUtil.GetPropertyValue(MainObj, strPrimaryKey)); if (GMCDbUtil.GetPropertyValue(MainObj, "FK_HREmployeeID") != null) { int iEmployeeID = Convert.ToInt32(GMCDbUtil.GetPropertyValue(MainObj, "FK_HREmployeeID")); objInbox.FK_HRFromEmployeeID = iEmployeeID; } if (GMCDbUtil.GetPropertyValue(MainObj, strTable.TrimEnd('s') + "Desc") != null) { //TextEdit txtRemark = (TextEdit)GetControlByName("fld_medADInboxItemRemark1"); //if (txtRemark != null) //{ // txtRemark.EditValue = GMCDbUtil.GetPropertyValue(MainObj, strTable.TrimEnd('s') + "Desc"); //} objInbox.ADInboxItemMessage = Convert.ToString(GMCDbUtil.GetPropertyValue(MainObj, strTable.TrimEnd('s') + "Desc")); } } //ShowModuleByJournal(strSourceLeger, iMainObjectID, false); //Thang - edit 26/4/2016 hiển thị chi tiêt chứng từ ADUserGroupsInfo objUserGroup = AuthConfig.CurrenUserGroupInfo; dr = GetLocalDataSet("STScreenID,STScreenNumber,STModuleID,STUserGroupID,STScreenSortOrder", "STScreens", string.Format(@"STModuleID = {0} AND STUserGroupID = {1} AND STScreenNumber like 'DM%' AND STScreenSortOrder > 0 AND STScreenSortOrder <= 1", iModuleID, objUserGroup.ADUserGroupID)); int iScreenID = 0; if (dr.Count > 0) { iScreenID = Convert.ToInt32(dr.First()["STScreenID"]); } //Thang edit - 8/2/2017 Chỉnh sửa nếu 1 user group không có giao diện riêng thì sẽ lấy mặc định giao diện admin if (iScreenID == 0) { int iUserGroupDefaultID = new ADUserGroupsController().GetObjectIDByName("ADMIN"); dr = GetLocalDataSet("STScreenID,STScreenNumber,STModuleID,STUserGroupID,STScreenSortOrder", "STScreens", string.Format(@"STModuleID = {0} AND STUserGroupID = {1} AND STScreenNumber like 'DM%' AND STScreenSortOrder > 0 AND STScreenSortOrder <= 1", iModuleID, iUserGroupDefaultID)); if (dr.Count > 0) { iScreenID = Convert.ToInt32(dr.First()["STScreenID"]); } } dr = GetLocalDataSet("*", "STFields", string.Format(@"STScreenID = {0} AND STFieldType = 'GMCGridControl' AND(STFieldDataSource like '%Items' OR STFieldDataSource like '%Details') AND STFieldGroup <> ''", iScreenID)); if (dr.Count == 0) { return(null); } STFieldsInfo objField = (STFieldsInfo) new STFieldsController().GetObjectFromDataRow(dr[0]); if (objField == null) { return(null); } BaseBusinessController itemCtrl = BusinessControllerFactory.GetBusinessController(objField.STFieldDataSource + "Controller"); DataSet ds = new DataSet(); if (itemCtrl != null) { ds = itemCtrl.GetAllDataByForeignColumn("FK_" + strPrimaryKey, iMainObjectID); } List <STGridColumnsInfo> lstGridColumns = new List <STGridColumnsInfo>(); if (objOldField == null || !objOldField.STFieldID.Equals(objField.STFieldID)) { objOldField = objField; dr = GetLocalDataSet("*", "STGridColumns", string.Format("FK_STFieldID = {0}", objField.STFieldID)); STGridColumnsController GridColCtrl = new STGridColumnsController(); dr.Distinct().ToList().ForEach(x => { STGridColumnsInfo colInfo = (STGridColumnsInfo)GridColCtrl.GetObjectFromDataRow(x); lstGridColumns.Add(colInfo); }); } return(new Dictionary <List <STGridColumnsInfo>, DataSet>() { { lstGridColumns, ds } }); }