protected void GvRowCommand(object sender, GridViewCommandEventArgs e) { string editpage = "~/ControlRoom/Modules/Setup/ProgramGameLevelAddEdit.aspx"; if (e.CommandName.ToLower() == "moveup") { var key = Convert.ToInt32(e.CommandArgument); DAL.ProgramGameLevel.MoveUp(key); var masterPage = (IControlRoomMaster)Master; masterPage.PageMessage = "Level Moved Up!"; LoadData(); } if (e.CommandName.ToLower() == "movedn") { var key = Convert.ToInt32(e.CommandArgument); DAL.ProgramGameLevel.MoveDn(key); var masterPage = (IControlRoomMaster)Master; masterPage.PageMessage = "Level Moved Down"; LoadData(); } if (e.CommandName.ToLower() == "addrecord") { Response.Redirect(editpage + "?PK2=" + PGID.SelectedValue); } if (e.CommandName.ToLower() == "editrecord") { int key = Convert.ToInt32(e.CommandArgument); Response.Redirect(String.Format("{0}?PK={1}", editpage, key)); } if (e.CommandName.ToLower() == "deleterecord") { var key = Convert.ToInt32(e.CommandArgument); try { var obj = new ProgramGameLevel(); if (obj.IsValid(BusinessRulesValidationMode.DELETE)) { ProgramGameLevel.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); } } }
protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e) { string returnURL = "~/ControlRoom/Modules/Setup/ProgramGameLevelList.aspx?PGID=" + PGID.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() == "add" || e.CommandName.ToLower() == "addandback") { try { var obj = new ProgramGameLevel(); obj.PGID = FormatHelper.SafeToInt(PGID.Text); obj.LevelNumber = -1;// FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("LevelNumber")).Text); obj.LocationX = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("LocationX")).Text); obj.LocationY = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("LocationY")).Text); obj.PointNumber = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("PointNumber")).Text); obj.Minigame1ID = FormatHelper.SafeToInt(((DropDownList) ((DetailsView) sender).FindControl("Minigame1ID")).SelectedValue); obj.Minigame2ID = FormatHelper.SafeToInt(((DropDownList) ((DetailsView) sender).FindControl("Minigame2ID")).SelectedValue); obj.AwardBadgeID = FormatHelper.SafeToInt(((DropDownList) ((DetailsView) sender).FindControl("AwardBadgeID")).SelectedValue); obj.LocationXBonus = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("LocationXBonus")).Text); obj.LocationYBonus = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("LocationYBonus")).Text); obj.Minigame1IDBonus = FormatHelper.SafeToInt(((DropDownList)((DetailsView)sender).FindControl("Minigame1IDBonus")).SelectedValue); obj.Minigame2IDBonus = FormatHelper.SafeToInt(((DropDownList)((DetailsView)sender).FindControl("Minigame2IDBonus")).SelectedValue); obj.AwardBadgeIDBonus = FormatHelper.SafeToInt(((DropDownList)((DetailsView)sender).FindControl("AwardBadgeIDBonus")).SelectedValue); 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; if (obj.IsValid(BusinessRulesValidationMode.INSERT)) { obj.Insert(); if (e.CommandName.ToLower() == "addandback") { Response.Redirect(returnURL); } lblPK.Text = obj.PGLID.ToString(); odsData.DataBind(); dv.DataBind(); dv.ChangeMode(DetailsViewMode.Edit); var masterPage = (IControlRoomMaster)Master; masterPage.PageMessage = SRPResources.AddedOK; } 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); } } if (e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback") { try { var obj = new ProgramGameLevel(); int pk = int.Parse(lblPK.Text); obj.Fetch(pk); //obj.PGID = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("PGID")).Text); //obj.LevelNumber = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("LevelNumber")).Text); obj.LocationX = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("LocationX")).Text); obj.LocationY = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("LocationY")).Text); obj.PointNumber = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("PointNumber")).Text); obj.Minigame1ID = FormatHelper.SafeToInt(((DropDownList) ((DetailsView) sender).FindControl("Minigame1ID")).SelectedValue); obj.Minigame2ID = FormatHelper.SafeToInt(((DropDownList) ((DetailsView) sender).FindControl("Minigame2ID")).SelectedValue); obj.AwardBadgeID = FormatHelper.SafeToInt(((DropDownList) ((DetailsView) sender).FindControl("AwardBadgeID")).SelectedValue); obj.LocationXBonus = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("LocationXBonus")).Text); obj.LocationYBonus = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("LocationYBonus")).Text); obj.Minigame1IDBonus = FormatHelper.SafeToInt(((DropDownList)((DetailsView)sender).FindControl("Minigame1IDBonus")).SelectedValue); obj.Minigame2IDBonus = FormatHelper.SafeToInt(((DropDownList)((DetailsView)sender).FindControl("Minigame2IDBonus")).SelectedValue); obj.AwardBadgeIDBonus = FormatHelper.SafeToInt(((DropDownList)((DetailsView)sender).FindControl("AwardBadgeIDBonus")).SelectedValue); 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); } } }