protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e) { string returnURL = "~/ControlRoom/Modules/Setup/MGChooseAdvSlidesList.aspx?L=" + lblDiff.Text + "&MGID=" + lblMGID.Text; if (e.CommandName.ToLower() == "back") { Response.Redirect(returnURL); } if (e.CommandName.ToLower() == "refresh") { try { odsData.DataBind(); dv.DataBind(); dv.ChangeMode(DetailsViewMode.Edit); var masterPage = (IControlRoomMaster)Master; if (masterPage != null) { masterPage.PageMessage = SRPResources.RefreshOK; } } catch (Exception ex) { var masterPage = (IControlRoomMaster)Master; masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } } if (e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback") { try { var obj = new MGChooseAdvSlides(); var pk = int.Parse(((TextBox)((DetailsView)sender).FindControl("CASID")).Text); obj.Fetch(pk); obj.CAID = FormatHelper.SafeToInt(lblCAID.Text); obj.MGID = FormatHelper.SafeToInt(lblMGID.Text); //obj.Difficulty = FormatHelper.SafeToInt(lblDiff.Text); //obj.StepNumber = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("StepNumber")).Text); obj.SlideText = ((HtmlTextArea)((DetailsView)sender).FindControl("SlideText")).InnerHtml; obj.FirstImageGoToStep = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("FirstImageGoToStep")).Text); obj.SecondImageGoToStep = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("SecondImageGoToStep")).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(); if (e.CommandName.ToLower() == "saveandback") { Response.Redirect(returnURL); } odsData.DataBind(); dv.DataBind(); dv.ChangeMode(DetailsViewMode.Edit); var masterPage = (IControlRoomMaster)Master; masterPage.PageMessage = SRPResources.SaveOK; } 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); masterPage.PageError = message; } } catch (Exception ex) { var masterPage = (IControlRoomMaster)Master; masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } } }
protected void GvRowCommand(object sender, GridViewCommandEventArgs e) { string editpage = "~/ControlRoom/Modules/Setup/MGChooseAdvSlidesAddEdit.aspx"; if (e.CommandName.ToLower() == "addrecord") { //Response.Redirect(String.Format("{0}?MGID={1}&CAID={2}&L={3}", editpage, lblMGID.Text, lblCAID.Text, lblDiff.Text)); Response.Redirect(String.Format("{0}?CAID={1}&L={2}", editpage, lblCAID.Text, lblDiff.Text)); } if (e.CommandName.ToLower() == "editrecord") { int key = Convert.ToInt32(e.CommandArgument); Response.Redirect(String.Format("{0}?PK={1}&L={2}", editpage, key, lblDiff.Text)); } if (e.CommandName.ToLower() == "back") { Response.Redirect(String.Format("~/ControlRoom/Modules/Setup/MGChooseAdvAddEdit.aspx?PK={0}", lblMGID.Text)); } if (e.CommandName.ToLower() == "moveup") { var key = Convert.ToInt32(e.CommandArgument); DAL.MGChooseAdvSlides.MoveUp(key); var masterPage = (IControlRoomMaster)Master; masterPage.PageMessage = "Step Moved Up!"; LoadData(); } if (e.CommandName.ToLower() == "movedn") { var key = Convert.ToInt32(e.CommandArgument); DAL.MGChooseAdvSlides.MoveDn(key); var masterPage = (IControlRoomMaster)Master; masterPage.PageMessage = "Step Moved Down"; LoadData(); } if (e.CommandName.ToLower() == "deleterecord") { var key = Convert.ToInt32(e.CommandArgument); try { var obj = new MGChooseAdvSlides(); if (obj.IsValid(BusinessRulesValidationMode.DELETE)) { MGChooseAdvSlides.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); } } } }