public static CustomList <GroupRule> GetAllGroupSecurityRule(string groupCode) { ConnectionManager conManager = new ConnectionManager(ConnectionName.SysMan); CustomList <GroupRule> GroupSecurityRuleCollection = new CustomList <GroupRule>(); String sql = "Select *from GroupRule where GroupCode='" + groupCode + "'"; IDataReader reader = null; try { conManager.OpenDataReader(sql, out reader); while (reader.Read()) { GroupRule newGroupSecurityRule = new GroupRule(); newGroupSecurityRule.SetData(reader); GroupSecurityRuleCollection.Add(newGroupSecurityRule); } reader.Close(); GroupSecurityRuleCollection.InsertSpName = "spInsertGroupRule"; GroupSecurityRuleCollection.SelectSpName = "spDeleteGroupRule"; return(GroupSecurityRuleCollection); } catch (Exception ex) { throw (ex); } finally { if (reader != null && !reader.IsClosed) { reader.Close(); } } }
public static CustomList<GroupRule> GetAllGroupSecurityRule(string groupCode) { ConnectionManager conManager = new ConnectionManager(ConnectionName.SysMan); CustomList<GroupRule> GroupSecurityRuleCollection = new CustomList<GroupRule>(); String sql = "Select *from GroupRule where GroupCode='" + groupCode + "'"; IDataReader reader = null; try { conManager.OpenDataReader(sql, out reader); while (reader.Read()) { GroupRule newGroupSecurityRule = new GroupRule(); newGroupSecurityRule.SetData(reader); GroupSecurityRuleCollection.Add(newGroupSecurityRule); } reader.Close(); GroupSecurityRuleCollection.InsertSpName = "spInsertGroupRule"; GroupSecurityRuleCollection.SelectSpName = "spDeleteGroupRule"; return GroupSecurityRuleCollection; } catch (Exception ex) { throw (ex); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }
private void SetDataFromControls(ref CustomList<Group> lstGroup) { try { #region Group Group group = lstGroup[0]; group.GroupCode = txtGroupCode.Text; group.GroupName = txtGroupName.Text; #endregion #region Group Security Rule #region Delete CustomList<GroupRule> TempGroupSecurityRule = manager.GetAllGroupSecurityRule(lstGroup[0].GroupCode); if (TempGroupSecurityRule.Count != 0) { foreach (GroupRule objGroupSecurityRule in TempGroupSecurityRule) { objGroupSecurityRule.Delete(); } manager.DeleteTempData(ref TempGroupSecurityRule); } #endregion CustomList<SECURITY.DAO.SecurityRule> SelectedSecurityRuleList = SecurityRuleList.FindAll(f => f.IsSaved); foreach (SECURITY.DAO.SecurityRule sR in SelectedSecurityRuleList) { GroupRule gSR = new GroupRule(); gSR.ApplicationID = "1"; gSR.GroupCode = txtGroupCode.Text; gSR.SecurityRuleCode = sR.SecurityRuleCode; //gSR.CompanyID = drpCompany.SelectedValue; groupSecurityRuleList.Add(gSR); } #endregion } catch (Exception ex) { throw ex; } }
protected void btnSave_Click(object sender, EventArgs e) { try { CustomList<Group> lstGroup = SearchGroupList; if (lstGroup.Count == 0) { Group newGroup = new Group(); lstGroup.Add(newGroup); } CustomList<GroupRule> lstGroupSecurityRule = SearchGroupSecurityRuleList; if (lstGroupSecurityRule.Count == 0) { GroupRule newGroupSecurityRule = new GroupRule(); lstGroupSecurityRule.Add(newGroupSecurityRule); } SetDataFromControls(ref lstGroup); objUserGroupList = UserGroupList.FindAll(f => f.IsSaved); foreach (UserGroup uG in objUserGroupList) { uG.SetAdded(); } if (groupList.IsNotNull()) { CustomList<UserGroup> TempUserGroup = manager.GetAllUserGroup(lstGroup[0].GroupCode); if (TempUserGroup.Count != 0) { foreach (UserGroup uG in TempUserGroup) { uG.Delete(); } } if (!CheckUserAuthentication(lstGroup, groupSecurityRuleList, objUserGroupList)) return; manager.SaveGroup(ref TempUserGroup, ref lstGroup, ref groupSecurityRuleList, ref objUserGroupList); txtGroupCode.Text = manager.GroupID; this.SuccessMessage = (StaticInfo.SavedSuccessfullyMsg); } } catch (SqlException ex) { this.ErrorMessage = (ExceptionHelper.getSqlExceptionMessage(ex)); } catch (Exception ex) { this.ErrorMessage = (ExceptionHelper.getExceptionMessage(ex)); } }