public static int Insert(ProgramGameLevel o) { SqlParameter[] arrParams = new SqlParameter[18]; arrParams[0] = new SqlParameter("@PGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PGID, o.PGID.GetTypeCode())); arrParams[1] = new SqlParameter("@LevelNumber", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LevelNumber, o.LevelNumber.GetTypeCode())); arrParams[2] = new SqlParameter("@LocationX", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LocationX, o.LocationX.GetTypeCode())); arrParams[3] = new SqlParameter("@LocationY", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LocationY, o.LocationY.GetTypeCode())); arrParams[4] = new SqlParameter("@PointNumber", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PointNumber, o.PointNumber.GetTypeCode())); arrParams[5] = new SqlParameter("@Minigame1ID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Minigame1ID, o.Minigame1ID.GetTypeCode())); arrParams[6] = new SqlParameter("@Minigame2ID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Minigame2ID, o.Minigame2ID.GetTypeCode())); arrParams[7] = new SqlParameter("@AwardBadgeID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AwardBadgeID, o.AwardBadgeID.GetTypeCode())); arrParams[8] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())); arrParams[9] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())); arrParams[10] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())); arrParams[11] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())); arrParams[12] = new SqlParameter("@LocationXBonus", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LocationXBonus, o.LocationXBonus.GetTypeCode())); arrParams[13] = new SqlParameter("@LocationYBonus", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LocationYBonus, o.LocationYBonus.GetTypeCode())); arrParams[14] = new SqlParameter("@Minigame1IDBonus", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Minigame1IDBonus, o.Minigame1IDBonus.GetTypeCode())); arrParams[15] = new SqlParameter("@Minigame2IDBonus", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Minigame2IDBonus, o.Minigame2IDBonus.GetTypeCode())); arrParams[16] = new SqlParameter("@AwardBadgeIDBonus", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AwardBadgeIDBonus, o.AwardBadgeIDBonus.GetTypeCode())); arrParams[17] = new SqlParameter("@PGLID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PGLID, o.PGLID.GetTypeCode())); arrParams[17].Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_ProgramGameLevel_Insert", arrParams); o.PGLID = int.Parse(arrParams[17].Value.ToString()); return o.PGLID; }
public static int Delete(ProgramGameLevel o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@PGLID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PGLID, o.PGLID.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_ProgramGameLevel_Delete", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return iReturn; }
public static ProgramGameLevel FetchObject(int PGLID) { // declare reader SqlDataReader dr; SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@PGLID", PGLID); dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_ProgramGameLevel_GetByID", arrParams); if (dr.Read()) { // declare return value ProgramGameLevel result = new ProgramGameLevel(); DateTime _datetime; int _int; //decimal _decimal; if (int.TryParse(dr["PGLID"].ToString(), out _int)) result.PGLID = _int; if (int.TryParse(dr["PGID"].ToString(), out _int)) result.PGID = _int; if (int.TryParse(dr["LevelNumber"].ToString(), out _int)) result.LevelNumber = _int; if (int.TryParse(dr["LocationX"].ToString(), out _int)) result.LocationX = _int; if (int.TryParse(dr["LocationY"].ToString(), out _int)) result.LocationY = _int; if (int.TryParse(dr["PointNumber"].ToString(), out _int)) result.PointNumber = _int; if (int.TryParse(dr["Minigame1ID"].ToString(), out _int)) result.Minigame1ID = _int; if (int.TryParse(dr["Minigame2ID"].ToString(), out _int)) result.Minigame2ID = _int; if (int.TryParse(dr["AwardBadgeID"].ToString(), out _int)) result.AwardBadgeID = _int; if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime)) result.LastModDate = _datetime; result.LastModUser = dr["LastModUser"].ToString(); if (DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime)) result.AddedDate = _datetime; result.AddedUser = dr["AddedUser"].ToString(); if (int.TryParse(dr["LocationXBonus"].ToString(), out _int)) result.LocationXBonus = _int; if (int.TryParse(dr["LocationYBonus"].ToString(), out _int)) result.LocationYBonus = _int; if (int.TryParse(dr["Minigame1IDBonus"].ToString(), out _int)) result.Minigame1IDBonus = _int; if (int.TryParse(dr["Minigame2IDBonus"].ToString(), out _int)) result.Minigame2IDBonus = _int; if (int.TryParse(dr["AwardBadgeIDBonus"].ToString(), out _int)) result.AwardBadgeIDBonus = _int; dr.Close(); return result; } dr.Close(); return null; }
public static int Update(ProgramGameLevel o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[18]; arrParams[0] = new SqlParameter("@PGLID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PGLID, o.PGLID.GetTypeCode())); arrParams[1] = new SqlParameter("@PGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PGID, o.PGID.GetTypeCode())); arrParams[2] = new SqlParameter("@LevelNumber", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LevelNumber, o.LevelNumber.GetTypeCode())); arrParams[3] = new SqlParameter("@LocationX", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LocationX, o.LocationX.GetTypeCode())); arrParams[4] = new SqlParameter("@LocationY", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LocationY, o.LocationY.GetTypeCode())); arrParams[5] = new SqlParameter("@PointNumber", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PointNumber, o.PointNumber.GetTypeCode())); arrParams[6] = new SqlParameter("@Minigame1ID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Minigame1ID, o.Minigame1ID.GetTypeCode())); arrParams[7] = new SqlParameter("@Minigame2ID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Minigame2ID, o.Minigame2ID.GetTypeCode())); arrParams[8] = new SqlParameter("@AwardBadgeID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AwardBadgeID, o.AwardBadgeID.GetTypeCode())); arrParams[9] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())); arrParams[10] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())); arrParams[11] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())); arrParams[12] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())); arrParams[13] = new SqlParameter("@LocationXBonus", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LocationXBonus, o.LocationXBonus.GetTypeCode())); arrParams[14] = new SqlParameter("@LocationYBonus", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LocationYBonus, o.LocationYBonus.GetTypeCode())); arrParams[15] = new SqlParameter("@Minigame1IDBonus", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Minigame1IDBonus, o.Minigame1IDBonus.GetTypeCode())); arrParams[16] = new SqlParameter("@Minigame2IDBonus", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Minigame2IDBonus, o.Minigame2IDBonus.GetTypeCode())); arrParams[17] = new SqlParameter("@AwardBadgeIDBonus", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AwardBadgeIDBonus, o.AwardBadgeIDBonus.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_ProgramGameLevel_Update", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return iReturn; }
public bool Fetch(int PGLID) { // declare reader SqlDataReader dr; SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@PGLID", PGLID); dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_ProgramGameLevel_GetByID", arrParams); if (dr.Read()) { // declare return value ProgramGameLevel result = new ProgramGameLevel(); DateTime _datetime; int _int; //decimal _decimal; if (int.TryParse(dr["PGLID"].ToString(), out _int)) this.PGLID = _int; if (int.TryParse(dr["PGID"].ToString(), out _int)) this.PGID = _int; if (int.TryParse(dr["LevelNumber"].ToString(), out _int)) this.LevelNumber = _int; if (int.TryParse(dr["LocationX"].ToString(), out _int)) this.LocationX = _int; if (int.TryParse(dr["LocationY"].ToString(), out _int)) this.LocationY = _int; if (int.TryParse(dr["PointNumber"].ToString(), out _int)) this.PointNumber = _int; if (int.TryParse(dr["Minigame1ID"].ToString(), out _int)) this.Minigame1ID = _int; if (int.TryParse(dr["Minigame2ID"].ToString(), out _int)) this.Minigame2ID = _int; if (int.TryParse(dr["AwardBadgeID"].ToString(), out _int)) this.AwardBadgeID = _int; if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime)) this.LastModDate = _datetime; this.LastModUser = dr["LastModUser"].ToString(); if (DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime)) this.AddedDate = _datetime; this.AddedUser = dr["AddedUser"].ToString(); if (int.TryParse(dr["LocationXBonus"].ToString(), out _int)) this.LocationXBonus = _int; if (int.TryParse(dr["LocationYBonus"].ToString(), out _int)) this.LocationYBonus = _int; if (int.TryParse(dr["Minigame1IDBonus"].ToString(), out _int)) this.Minigame1IDBonus = _int; if (int.TryParse(dr["Minigame2IDBonus"].ToString(), out _int)) this.Minigame2IDBonus = _int; if (int.TryParse(dr["AwardBadgeIDBonus"].ToString(), out _int)) this.AwardBadgeIDBonus = _int; dr.Close(); return true; } dr.Close(); return false; }
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); } } }