public static CustomList<Group> doSearch(string whereClause) { ConnectionManager conManager = new ConnectionManager(ConnectionName.SysMan); CustomList<Group> GroupCollection = new CustomList<Group>(); String sql = string.Format("Select * From [Group] Where 1=1 {0}", whereClause); IDataReader reader = null; ; try { conManager.OpenDataReader(sql, out reader); while (reader.Read()) { Group newGroup = new Group(); newGroup.SetData(reader); GroupCollection.Add(newGroup); } reader.Close(); GroupCollection.SelectSpName = "spSelectGroup"; GroupCollection.InsertSpName = "spInsertGroup"; GroupCollection.UpdateSpName = "spUpdateGroup"; GroupCollection.SelectSpName = "spDeleteGroup"; return GroupCollection; } catch (Exception ex) { throw (ex); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } }
private void PopulateGroupInformation(Group group) { try { SetDataInControls(group); groupSecurityRuleList = new CustomList<GroupRule>(); SecurityRuleList = new CustomList<SECURITY.DAO.SecurityRule>(); SecurityRuleList = manager.GetAlltblSecurityRule(); groupSecurityRuleList = manager.GetAllGroupSecurityRule(group.GroupCode); SearchGroupSecurityRuleList = groupSecurityRuleList; foreach (SECURITY.DAO.SecurityRule sR in SecurityRuleList) { CustomList<GroupRule> gSRList = groupSecurityRuleList.FindAll(f => f.SecurityRuleCode == sR.SecurityRuleCode); foreach (GroupRule gSR in gSRList) { sR.IsSaved = true; } } //PopulateMenuItem(); UserGroupList = new CustomList<UserGroup>(); UserGroupList = manager.GetAllUser(); CustomList<UserGroup> SelectedUser = manager.GetAllUserGroup(group.GroupCode); foreach (UserGroup uG in UserGroupList) { UserGroup user = SelectedUser.Find(f => f.UserCode == uG.UserCode); if (user.IsNotNull()) { uG.IsSaved = true; } } } catch (Exception ex) { throw (ex); } }
private void SetDataInControls(Group group) { try { txtGroupCode.Text = group.GroupCode; txtGroupName.Text = group.GroupName; } 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)); } }