public static void InitializeSecurity(SRPUser u, int TID, string newPassword) { var MTID = Core.Utilities.Tenant.GetMasterID(); u.TenID = TID; u.MustResetPassword = true; u.Insert(); var g = new SRPGroup(); g.GID = 0; g.GroupName = "Superuser group"; g.GroupDescription = "All permissions enabled."; g.TenID = TID; g.Insert(); var PermissionID_LIST = "1000,2000,2100,2200,3000,4000,4100,4200,4300,4400,4500,4600,4700,4800,4900,5000,5100,5200,5300,8000"; SRPGroup.UpdatePermissions(g.GID, PermissionID_LIST, ((SRPUser)HttpContext.Current.Session[SessionData.UserProfile.ToString()]).Username); SRPGroup.UpdateMemberUsers(g.GID, u.Uid.ToString(), ((SRPUser)HttpContext.Current.Session[SessionData.UserProfile.ToString()]).Username); var Message = "Summer Reading Program - Your account has been created"; // TODO security - this should not email the password in cleartext string baseUrl = WebTools.GetBaseUrl(HttpContext.Current.Request); var EmailBody = "<h1>Dear " + u.FirstName + ",</h1><br><br>Your account has been created and has full administrative access to your organization's reading rogram. <br>This is your current account information. Please make sure you reset your password as soon as you are able to log back in.<br><br>" + "Username: "******"<br>Password: "******"<br><br>If you have any questions regarding your account please contact " + SRPSettings.GetSettingValue("ContactName") + " at " + SRPSettings.GetSettingValue("ContactEmail") + "." + "<br><br><br><a href='" + baseUrl + "'>" + baseUrl + "</a> <br> "; new EmailService().SendEmail(u.EmailAddress, Message, EmailBody); }
public static bool Update(SRPGroup u) { if (u == null) { u.AddErrorCode("Group object", "N/A", "Group object is null.", BusinessRulesValidationCode.UNSPECIFIED); return(false); } var arrParams = new SqlParameter[14]; arrParams[0] = new SqlParameter("@GID", u.GID); arrParams[1] = new SqlParameter("@GroupName", u.GroupName); arrParams[2] = new SqlParameter("@GroupDescription", u.GroupDescription); arrParams[3] = new SqlParameter("@ActionUsername", ((SRPUser)HttpContext.Current.Session[SessionData.UserProfile.ToString()]).Username); arrParams[4] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.TenID, u.TenID.GetTypeCode())); arrParams[5] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldInt1, u.FldInt1.GetTypeCode())); arrParams[6] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldInt2, u.FldInt2.GetTypeCode())); arrParams[7] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldInt3, u.FldInt3.GetTypeCode())); arrParams[8] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldBit1, u.FldBit1.GetTypeCode())); arrParams[9] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldBit2, u.FldBit2.GetTypeCode())); arrParams[10] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldBit3, u.FldBit3.GetTypeCode())); arrParams[11] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldText1, u.FldText1.GetTypeCode())); arrParams[12] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldText2, u.FldText2.GetTypeCode())); arrParams[13] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldText3, u.FldText3.GetTypeCode())); SqlHelper.ExecuteScalar(conn, CommandType.StoredProcedure, "cbspSRPGroups_Update", arrParams); return(true); }
public static SRPGroup GetFromReader(SqlDataReader reader) { SRPGroup returnVal = null; if (reader.Read()) { returnVal = new SRPGroup(); returnVal.GID = (int)reader["GID"]; returnVal.GroupName = reader["GroupName"].ToString();; returnVal.GroupDescription = reader["GroupDescription"].ToString(); returnVal.LastModDate = reader.IsDBNull(reader.GetOrdinal("LastModDate")) ? null : (DateTime?)reader["LastModDate"]; returnVal.AddedDate = reader.IsDBNull(reader.GetOrdinal("AddedDate")) ? null : (DateTime?)reader["AddedDate"]; returnVal.LastModUser = reader["LastModUser"].ToString(); returnVal.AddedUser = reader["AddedUser"].ToString(); returnVal.TenID = (int)reader["TenID"]; returnVal.FldInt1 = (int)reader["FldInt1"]; returnVal.FldInt2 = (int)reader["FldInt2"]; returnVal.FldInt3 = (int)reader["FldInt3"]; returnVal.FldBit1 = (bool)reader["FldBit1"]; returnVal.FldBit2 = (bool)reader["FldBit2"]; returnVal.FldBit3 = (bool)reader["FldBit3"]; returnVal.FldText1 = reader["FldText1"].ToString(); returnVal.FldText2 = reader["FldText2"].ToString(); returnVal.FldText3 = reader["FldText3"].ToString(); } reader.Close(); return(returnVal); }
public static int Insert(SRPGroup u) { if (u == null) { return(-1); } var arrParams = new SqlParameter[14]; arrParams[0] = new SqlParameter("@GroupName", u.GroupName); arrParams[1] = new SqlParameter("@GroupDescription", u.GroupDescription); arrParams[2] = new SqlParameter("@ActionUsername", ((SRPUser)HttpContext.Current.Session[SessionData.UserProfile.ToString()]).Username); arrParams[3] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.TenID, u.TenID.GetTypeCode())); arrParams[4] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldInt1, u.FldInt1.GetTypeCode())); arrParams[5] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldInt2, u.FldInt2.GetTypeCode())); arrParams[6] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldInt3, u.FldInt3.GetTypeCode())); arrParams[7] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldBit1, u.FldBit1.GetTypeCode())); arrParams[8] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldBit2, u.FldBit2.GetTypeCode())); arrParams[9] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldBit3, u.FldBit3.GetTypeCode())); arrParams[10] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldText1, u.FldText1.GetTypeCode())); arrParams[11] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldText2, u.FldText2.GetTypeCode())); arrParams[12] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldText3, u.FldText3.GetTypeCode())); arrParams[13] = new SqlParameter("@Return_Value", -1); arrParams[13].Direction = ParameterDirection.ReturnValue; u.GID = Convert.ToInt32(SqlHelper.ExecuteScalar(conn, CommandType.StoredProcedure, "cbspSRPGroups_Insert", arrParams)); return((int)u.GID); }
public static SRPGroup Fetch(int gid) { var arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@GID", gid); var reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "cbspSRPGroups_Get", arrParams); SRPGroup u = GetFromReader(reader); return(u); }
public static List <SRPGroup> FetchAll(bool forCurrentTenantOnly = true) { var arrParams = new SqlParameter[1]; if (forCurrentTenantOnly) { arrParams[0] = new SqlParameter("@TenID", (HttpContext.Current.Session["TenantID"] == null || HttpContext.Current.Session["TenantID"].ToString() == "" ? -1 : (int)HttpContext.Current.Session["TenantID"]) ); } else { arrParams[0] = new SqlParameter("@TenID", DBNull.Value); } var reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "cbspSRPGroups_GetAll", arrParams); List <SRPGroup> retValue = new List <SRPGroup>(); while (reader.Read()) { SRPGroup aUser = new SRPGroup(); aUser.GID = (int)reader["GID"]; aUser.GroupName = reader["GroupName"].ToString();; aUser.GroupDescription = reader["GroupDescription"].ToString(); aUser.LastModDate = reader.IsDBNull(reader.GetOrdinal("LastModDate")) ? null : (DateTime?)reader["LastModDate"]; aUser.AddedDate = reader.IsDBNull(reader.GetOrdinal("AddedDate")) ? null : (DateTime?)reader["AddedDate"]; aUser.LastModUser = reader["LastModUser"].ToString(); aUser.AddedUser = reader["AddedUser"].ToString(); aUser.TenID = (int)reader["TenID"]; aUser.FldInt1 = (int)reader["FldInt1"]; aUser.FldInt2 = (int)reader["FldInt2"]; aUser.FldInt3 = (int)reader["FldInt3"]; aUser.FldBit1 = (bool)reader["FldBit1"]; aUser.FldBit2 = (bool)reader["FldBit2"]; aUser.FldBit3 = (bool)reader["FldBit3"]; aUser.FldText1 = reader["FldText1"].ToString(); aUser.FldText2 = reader["FldText2"].ToString(); aUser.FldText3 = reader["FldText3"].ToString(); retValue.Add(aUser); } return(retValue); }
protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e) { string returnURL = "~/ControlRoom/Modules/Security/GroupsList.aspx"; if (e.CommandName.ToLower() == "back") { Response.Redirect(returnURL); } if (e.CommandName.ToLower() == "refresh") { try { odsSRPGroups.DataBind(); dv.DataBind(); dv.ChangeMode(DetailsViewMode.Edit); MasterPage.PageMessage = SRPResources.RefreshOK; } catch (Exception ex) { MasterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } } if (e.CommandName.ToLower() == "add" || e.CommandName.ToLower() == "addandback") { try { SRPGroup obj = new SRPGroup(); //obj.GID = int.Parse( ((Label)((DetailsView)sender).FindControl(".GID")).Text ); obj.GroupName = ((TextBox)((DetailsView)sender).FindControl("GroupName")).Text; obj.GroupDescription = ((TextBox)((DetailsView)sender).FindControl("GroupDescription")).Text; obj.AddedDate = DateTime.Now; obj.AddedUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username; //"N/A"; // Get from session obj.LastModDate = obj.AddedDate; obj.LastModUser = obj.AddedUser; obj.TenID = (int)CRTenantID; if (obj.IsValid(BusinessRulesValidationMode.INSERT)) { obj.Insert(); if (e.CommandName.ToLower() == "addandback") { Response.Redirect(returnURL); } lblGID.Text = obj.GID.ToString(); odsSRPGroups.DataBind(); dv.DataBind(); dv.ChangeMode(DetailsViewMode.Edit); MasterPage.PageMessage = SRPResources.AddedOK; } else { string message = String.Format(SRPResources.ApplicationError1, "<ul>"); foreach (BusinessRulesValidationMessage m in obj.ErrorCodes) { message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage); } message = string.Format("{0}</ul>", message); MasterPage.PageError = message; } } catch(Exception ex) { MasterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } } if (e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback") { try { SRPGroup obj = new SRPGroup(); int pk = int.Parse(((DetailsView)sender).Rows[0].Cells[1].Text); obj = SRPGroup.Fetch(pk); obj.GroupName = ((TextBox)((DetailsView)sender).FindControl("GroupName")).Text; obj.GroupDescription = ((TextBox)((DetailsView)sender).FindControl("GroupDescription")).Text; obj.LastModDate = DateTime.Now; obj.LastModUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username; //"N/A"; // Get from session if (obj.IsValid(BusinessRulesValidationMode.UPDATE)) { obj.Update(); SaveUsers((DetailsView)sender, obj); SavePermissions((DetailsView)sender, obj); if (e.CommandName.ToLower() == "saveandback") { Response.Redirect(returnURL); } odsSRPGroups.DataBind(); dv.DataBind(); dv.ChangeMode(DetailsViewMode.Edit); MasterPage.PageMessage = SRPResources.SaveOK; MasterPage.PageMessage = SRPResources.AddedOK; } else { string message = String.Format(SRPResources.ApplicationError1, "<ul>"); foreach (BusinessRulesValidationMessage m in obj.ErrorCodes) { message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage); } message = string.Format("{0}</ul>", message); MasterPage.PageError = message; } } catch(Exception ex) { MasterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } } }
protected void SavePermissions(DetailsView dv, SRPGroup obj) { GridView gv = (GridView)dv.FindControl("gvGroupPermissions"); string groupPermissions= string.Empty; foreach (GridViewRow row in gv.Rows) { if (((CheckBox)row.FindControl("isChecked")).Checked) { groupPermissions = string.Format("{0},{1}", groupPermissions, ((Label)row.FindControl("PermissionID")).Text); } } if (groupPermissions.Length > 0) groupPermissions = groupPermissions.Substring(1, groupPermissions.Length - 1); SRPGroup.UpdatePermissions(obj.GID, groupPermissions, ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username); }
protected void SaveUsers(DetailsView dv, SRPGroup obj) { GridView gv = (GridView)dv.FindControl("gvGroupUsers"); string memberUsers= string.Empty; foreach (GridViewRow row in gv.Rows) { if (((CheckBox)row.FindControl("isMember")).Checked) { memberUsers = string.Format("{0},{1}", memberUsers, ((Label)row.FindControl("UID")).Text); } } if (memberUsers.Length > 0) memberUsers = memberUsers.Substring(1, memberUsers.Length - 1); SRPGroup.UpdateMemberUsers(obj.GID, memberUsers, ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username); }
public static bool Update(SRPGroup u) { if (u == null) { u.AddErrorCode("Group object", "N/A", "Group object is null.", BusinessRulesValidationCode.UNSPECIFIED); return false; } var arrParams = new SqlParameter[14]; arrParams[0] = new SqlParameter("@GID", u.GID); arrParams[1] = new SqlParameter("@GroupName", u.GroupName); arrParams[2] = new SqlParameter("@GroupDescription", u.GroupDescription); arrParams[3] = new SqlParameter("@ActionUsername", ((SRPUser)HttpContext.Current.Session[SessionData.UserProfile.ToString()]).Username); arrParams[4] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.TenID, u.TenID.GetTypeCode())); arrParams[5] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldInt1, u.FldInt1.GetTypeCode())); arrParams[6] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldInt2, u.FldInt2.GetTypeCode())); arrParams[7] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldInt3, u.FldInt3.GetTypeCode())); arrParams[8] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldBit1, u.FldBit1.GetTypeCode())); arrParams[9] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldBit2, u.FldBit2.GetTypeCode())); arrParams[10] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldBit3, u.FldBit3.GetTypeCode())); arrParams[11] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldText1, u.FldText1.GetTypeCode())); arrParams[12] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldText2, u.FldText2.GetTypeCode())); arrParams[13] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldText3, u.FldText3.GetTypeCode())); SqlHelper.ExecuteScalar(conn, CommandType.StoredProcedure, "cbspSRPGroups_Update", arrParams); return true; }
public static int Insert(SRPGroup u) { if (u == null) return -1; var arrParams = new SqlParameter[14]; arrParams[0] = new SqlParameter("@GroupName", u.GroupName); arrParams[1] = new SqlParameter("@GroupDescription", u.GroupDescription); arrParams[2] = new SqlParameter("@ActionUsername", ((SRPUser)HttpContext.Current.Session[SessionData.UserProfile.ToString()]).Username); arrParams[3] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.TenID, u.TenID.GetTypeCode())); arrParams[4] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldInt1, u.FldInt1.GetTypeCode())); arrParams[5] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldInt2, u.FldInt2.GetTypeCode())); arrParams[6] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldInt3, u.FldInt3.GetTypeCode())); arrParams[7] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldBit1, u.FldBit1.GetTypeCode())); arrParams[8] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldBit2, u.FldBit2.GetTypeCode())); arrParams[9] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldBit3, u.FldBit3.GetTypeCode())); arrParams[10] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldText1, u.FldText1.GetTypeCode())); arrParams[11] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldText2, u.FldText2.GetTypeCode())); arrParams[12] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(u.FldText3, u.FldText3.GetTypeCode())); arrParams[13] = new SqlParameter("@Return_Value", -1); arrParams[13].Direction = ParameterDirection.ReturnValue; u.GID = Convert.ToInt32(SqlHelper.ExecuteScalar(conn, CommandType.StoredProcedure, "cbspSRPGroups_Insert", arrParams)); return (int)u.GID; }
public static List<SRPGroup> FetchAll(bool forCurrentTenantOnly = true) { var arrParams = new SqlParameter[1]; if (forCurrentTenantOnly) { arrParams[0] = new SqlParameter("@TenID", (HttpContext.Current.Session["TenantID"] == null || HttpContext.Current.Session["TenantID"].ToString() == "" ? -1 : (int)HttpContext.Current.Session["TenantID"]) ); } else { arrParams[0] = new SqlParameter("@TenID", DBNull.Value); } var reader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "cbspSRPGroups_GetAll", arrParams); List<SRPGroup> retValue = new List<SRPGroup>(); while (reader.Read()) { SRPGroup aUser = new SRPGroup(); aUser.GID = (int)reader["GID"]; aUser.GroupName = reader["GroupName"].ToString(); ; aUser.GroupDescription = reader["GroupDescription"].ToString(); aUser.LastModDate = reader.IsDBNull(reader.GetOrdinal("LastModDate")) ? null : (DateTime?)reader["LastModDate"]; aUser.AddedDate = reader.IsDBNull(reader.GetOrdinal("AddedDate")) ? null : (DateTime?)reader["AddedDate"]; aUser.LastModUser = reader["LastModUser"].ToString(); aUser.AddedUser = reader["AddedUser"].ToString(); aUser.TenID = (int)reader["TenID"]; aUser.FldInt1 = (int)reader["FldInt1"]; aUser.FldInt2 = (int)reader["FldInt2"]; aUser.FldInt3 = (int)reader["FldInt3"]; aUser.FldBit1 = (bool)reader["FldBit1"]; aUser.FldBit2 = (bool)reader["FldBit2"]; aUser.FldBit3 = (bool)reader["FldBit3"]; aUser.FldText1 = reader["FldText1"].ToString(); aUser.FldText2 = reader["FldText2"].ToString(); aUser.FldText3 = reader["FldText3"].ToString(); retValue.Add(aUser); } return retValue; }
public static SRPGroup GetFromReader(SqlDataReader reader) { SRPGroup returnVal = null; if (reader.Read()) { returnVal = new SRPGroup(); returnVal.GID = (int)reader["GID"]; returnVal.GroupName = reader["GroupName"].ToString(); ; returnVal.GroupDescription = reader["GroupDescription"].ToString(); returnVal.LastModDate = reader.IsDBNull(reader.GetOrdinal("LastModDate")) ? null : (DateTime?)reader["LastModDate"]; returnVal.AddedDate = reader.IsDBNull(reader.GetOrdinal("AddedDate")) ? null : (DateTime?)reader["AddedDate"]; returnVal.LastModUser = reader["LastModUser"].ToString(); returnVal.AddedUser = reader["AddedUser"].ToString(); returnVal.TenID = (int)reader["TenID"]; returnVal.FldInt1 = (int)reader["FldInt1"]; returnVal.FldInt2 = (int)reader["FldInt2"]; returnVal.FldInt3 = (int)reader["FldInt3"]; returnVal.FldBit1 = (bool)reader["FldBit1"]; returnVal.FldBit2 = (bool)reader["FldBit2"]; returnVal.FldBit3 = (bool)reader["FldBit3"]; returnVal.FldText1 = reader["FldText1"].ToString(); returnVal.FldText2 = reader["FldText2"].ToString(); returnVal.FldText3 = reader["FldText3"].ToString(); } reader.Close(); return returnVal; }
protected void GvRowCommand(object sender, GridViewCommandEventArgs e) { string editpage = "~/ControlRoom/Modules/Security/GroupsAddEdit.aspx"; if (e.CommandName.ToLower() == "addrecord") { Session["GID"]= string.Empty; Response.Redirect(editpage); } if (e.CommandName.ToLower() == "editrecord") { int key = Convert.ToInt32(e.CommandArgument); Session["GID"] = key; Response.Redirect(editpage); } if (e.CommandName.ToLower() == "deleterecord") { int key = Convert.ToInt32(e.CommandArgument); try { var obj = new SRPGroup(key); if (obj.IsValid(BusinessRulesValidationMode.DELETE)) { SRPGroup.Delete(key); LoadData(); var masterPage = (IControlRoomMaster)Master; if (masterPage != null) masterPage.PageMessage = SRPResources.DeleteOK; } else { var masterPage = (IControlRoomMaster)Master; string message = String.Format(SRPResources.ApplicationError1, "<ul>"); foreach (BusinessRulesValidationMessage m in obj.ErrorCodes) { message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage); } message = string.Format("{0}</ul>", message); if (masterPage != null) masterPage.PageError = message; } } catch (Exception ex) { var masterPage = (IControlRoomMaster)Master; if (masterPage != null) masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } } }