protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SetPageRibbon(StandardModuleRibbons.SetupRibbon()); } //MasterPage.RequiredPermission = PERMISSIONID; MasterPage.IsSecure = true; MasterPage.PageTitle = string.Format("{0}", "Background/Coloring Page Edit"); if (!IsPostBack) { if (Request["MGID"] != null) { lblMGID.Text = Request["MGID"]; lblHPID.Text = Request["HPID"]; var o = Minigame.FetchObject(int.Parse(lblMGID.Text)); AdminName.Text = o.AdminName; var obj = new MGHiddenPicBk(); obj.HPID = int.Parse(lblHPID.Text); obj.MGID = int.Parse(lblMGID.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.Insert(); lblPK.Text = obj.HPBID.ToString(); dv.ChangeMode(DetailsViewMode.Edit); } else { lblPK.Text = Request["PK"]; var o1 = MGHiddenPicBk.FetchObject(int.Parse(lblPK.Text)); lblMGID.Text = o1.MGID.ToString(); lblHPID.Text = o1.HPID.ToString(); var o = Minigame.FetchObject(int.Parse(lblMGID.Text)); AdminName.Text = o.AdminName; dv.ChangeMode(DetailsViewMode.Edit); } Page.DataBind(); } }
protected void GvRowCommand(object sender, GridViewCommandEventArgs e) { string editpage = "~/ControlRoom/Modules/Setup/MGHiddenPicBkAddEdit.aspx"; if (e.CommandName.ToLower() == "addrecord") { Response.Redirect(String.Format("{0}?MGID={1}&HPID={2}", editpage, lblMGID.Text, lblHPID.Text)); } if (e.CommandName.ToLower() == "editrecord") { int key = Convert.ToInt32(e.CommandArgument); Response.Redirect(String.Format("{0}?PK={1}", editpage, key)); } if (e.CommandName.ToLower() == "back") { Response.Redirect(String.Format("~/ControlRoom/Modules/Setup/MGHiddenPicAddEdit.aspx?PK={0}", lblMGID.Text)); } if (e.CommandName.ToLower() == "deleterecord") { var key = Convert.ToInt32(e.CommandArgument); try { var obj = new MGHiddenPicBk(); if (obj.IsValid(BusinessRulesValidationMode.DELETE)) { MGHiddenPicBk.FetchObject(key).Delete(); 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); } } } }