public string GetMGIDs(Patron patron, Programs pgm, ProgramGame gm, int StartingPoints, int defMGID = 0, int whichMinigames = 1) { //Tally up the points //var level = 0; //var points = 0; var bonus = false; string ret = defMGID == 0 ? "" : defMGID.ToString(); var prefix1 = whichMinigames == 1 ? "1" : "2"; var prefixBonus = bonus ? "Bonus" : ""; if(pgm.ProgramGameID > 0) { // only if we have a game we can earn badges by reading .... var ds = ProgramGameLevel.GetAll(gm.PGID); var normalLevelTotalPoints = GetGameCompletionPoints(ds); //var bonusLevelTotalPoints = GetGameCompletionBonusPoints(ds, gm.BonusLevelPointMultiplier); bonus = (StartingPoints > normalLevelTotalPoints); // loop thru the levels to see where we are at ... before awarding the new points var rp = StartingPoints; //remaining points if(bonus) { prefixBonus = string.Empty; // first do all non bonus levels // if we are on the bonus, we have access to all of them for(var i = 0; i < ds.Tables[0].Rows.Count; i++) { var MGIDfield = string.Format("Minigame{0}ID{1}", prefix1, prefixBonus); if(Convert.ToInt32(ds.Tables[0].Rows[i][MGIDfield]) != 0) { ret = string.Format("{0}{1}{2}", ret, (ret.Length > 0 ? "," : ""), Convert.ToInt32(ds.Tables[0].Rows[i][MGIDfield])); } } rp = StartingPoints - normalLevelTotalPoints; } prefixBonus = bonus ? "Bonus" : ""; // we have not tallied the bonus levels yet, or if not on bonus mode we have not tallied the regular levels yet .... for(var i = 0; i < ds.Tables[0].Rows.Count; i++) { var multiplier = (bonus ? gm.BonusLevelPointMultiplier : 1.00m); var levelPoints = Convert.ToInt32(Convert.ToInt32(ds.Tables[0].Rows[i]["PointNumber"]) * multiplier); rp = rp - levelPoints; if(rp < 0) { return ret; //break; } var MGIDfield = string.Format("Minigame{0}ID{1}", prefix1, prefixBonus); if(Convert.ToInt32(ds.Tables[0].Rows[i][MGIDfield]) != 0) { ret = string.Format("{0}{1}{2}", ret, (ret.Length > 0 ? "," : ""), Convert.ToInt32(ds.Tables[0].Rows[i][MGIDfield])); } } } return ret; }
public static int Update(ProgramGame o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[24]; arrParams[0] = new SqlParameter("@PGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PGID, o.PGID.GetTypeCode())); arrParams[1] = new SqlParameter("@GameName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.GameName, o.GameName.GetTypeCode())); arrParams[2] = new SqlParameter("@MapImage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MapImage, o.MapImage.GetTypeCode())); arrParams[3] = new SqlParameter("@BonusMapImage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BonusMapImage, o.BonusMapImage.GetTypeCode())); arrParams[4] = new SqlParameter("@BoardWidth", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BoardWidth, o.BoardWidth.GetTypeCode())); arrParams[5] = new SqlParameter("@BoardHeight", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BoardHeight, o.BoardHeight.GetTypeCode())); arrParams[6] = new SqlParameter("@BonusLevelPointMultiplier", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BonusLevelPointMultiplier, o.BonusLevelPointMultiplier.GetTypeCode())); arrParams[7] = new SqlParameter("@LevelCompleteImage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LevelCompleteImage, o.LevelCompleteImage.GetTypeCode())); arrParams[8] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())); arrParams[9] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())); arrParams[10] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())); arrParams[11] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())); arrParams[12] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode())); arrParams[13] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())); arrParams[14] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())); arrParams[15] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())); arrParams[16] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())); arrParams[17] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())); arrParams[18] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())); arrParams[19] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())); arrParams[20] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())); arrParams[21] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())); arrParams[22] = new SqlParameter("@Minigame1ID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Minigame1ID, o.Minigame1ID.GetTypeCode())); arrParams[23] = new SqlParameter("@Minigame2ID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Minigame2ID, o.Minigame2ID.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_ProgramGame_Update", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return(iReturn); }
public static int Insert(ProgramGame o) { SqlParameter[] arrParams = new SqlParameter[24]; arrParams[0] = new SqlParameter("@GameName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.GameName, o.GameName.GetTypeCode())); arrParams[1] = new SqlParameter("@MapImage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MapImage, o.MapImage.GetTypeCode())); arrParams[2] = new SqlParameter("@BonusMapImage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BonusMapImage, o.BonusMapImage.GetTypeCode())); arrParams[3] = new SqlParameter("@BoardWidth", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BoardWidth, o.BoardWidth.GetTypeCode())); arrParams[4] = new SqlParameter("@BoardHeight", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BoardHeight, o.BoardHeight.GetTypeCode())); arrParams[5] = new SqlParameter("@BonusLevelPointMultiplier", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BonusLevelPointMultiplier, o.BonusLevelPointMultiplier.GetTypeCode())); arrParams[6] = new SqlParameter("@LevelCompleteImage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LevelCompleteImage, o.LevelCompleteImage.GetTypeCode())); arrParams[7] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())); arrParams[8] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())); arrParams[9] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())); arrParams[10] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())); arrParams[11] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode())); arrParams[12] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())); arrParams[13] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())); arrParams[14] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())); arrParams[15] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())); arrParams[16] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())); arrParams[17] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())); arrParams[18] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())); arrParams[19] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())); arrParams[20] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())); arrParams[21] = new SqlParameter("@Minigame1ID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Minigame1ID, o.Minigame1ID.GetTypeCode())); arrParams[22] = new SqlParameter("@Minigame2ID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Minigame2ID, o.Minigame2ID.GetTypeCode())); arrParams[23] = new SqlParameter("@PGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PGID, o.PGID.GetTypeCode())); arrParams[23].Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_ProgramGame_Insert", arrParams); o.PGID = int.Parse(arrParams[23].Value.ToString()); return(o.PGID); }
public string GetGameInfo(Patron patron, Programs pgm, ProgramGame gm, int StartingPoints) { //Tally up the points //var level = 0; //var points = 0; var bonus = false; string ret = string.Empty; if(pgm.ProgramGameID > 0) { // only if we have a game we can earn badges by reading .... var ds = ProgramGameLevel.GetAll(gm.PGID); var normalLevelTotalPoints = GetGameCompletionPoints(ds); var bonusLevelTotalPoints = GetGameCompletionBonusPoints(ds, gm.BonusLevelPointMultiplier); bonus = (StartingPoints > normalLevelTotalPoints); // loop thru the levels to see where we are at ... before awarding the new points var rp = StartingPoints; //remaining points if(bonus) { // if we are on the bonus, we have access to all of them for(var i = 0; i < ds.Tables[0].Rows.Count; i++) { ret = string.Format("{0}{1}{2}", ret, (ret.Length > 0 ? "," : ""), Convert.ToInt32(ds.Tables[0].Rows[i]["PGLID"])); } return ret; } // we have not completed the bonus yet .... for(var i = 0; i < ds.Tables[0].Rows.Count; i++) { var multiplier = (bonus ? gm.BonusLevelPointMultiplier : 1.00m); var levelPoints = Convert.ToInt32(Convert.ToInt32(ds.Tables[0].Rows[i]["PointNumber"]) * multiplier); rp = rp - levelPoints; if(rp < 0) { return ret; //break; } ret = string.Format("{0}{1}{2}", ret, (ret.Length > 0 ? "," : ""), Convert.ToInt32(ds.Tables[0].Rows[i]["PGLID"])); } } return ret; }
protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e) { string returnURL = "~/ControlRoom/Modules/Setup/BoardGameList.aspx"; string levelURL = "~/ControlRoom/Modules/Setup/ProgramGameLevelList.aspx"; 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 ProgramGame(); obj.GameName = ((TextBox)((DetailsView)sender).FindControl("GameName")).Text; //obj.MapImage = ((TextBox)((DetailsView)sender).FindControl("MapImage")).Text; //obj.BonusMapImage = ((TextBox)((DetailsView)sender).FindControl("BonusMapImage")).Text; obj.BoardWidth = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("BoardWidth")).Text); //obj.BoardHeight = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("BoardHeight")).Text); obj.BonusLevelPointMultiplier = FormatHelper.SafeToDecimal(((TextBox)((DetailsView)sender).FindControl("BonusLevelPointMultiplier")).Text); //obj.LevelCompleteImage = ((TextBox)((DetailsView)sender).FindControl("LevelCompleteImage")).Text; obj.Minigame1ID = ((DropDownList)((DetailsView)sender).FindControl("Minigame1ID")).SelectedValue.SafeToInt(); obj.Minigame2ID = ((DropDownList)((DetailsView)sender).FindControl("Minigame2ID")).SelectedValue.SafeToInt(); 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.PGID.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() == "levels") { Response.Redirect(levelURL + "?PGID=" + lblPK.Text); } if (e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback") { try { var obj = new ProgramGame(); int pk = int.Parse(lblPK.Text); obj.Fetch(pk); obj.GameName = ((TextBox)((DetailsView)sender).FindControl("GameName")).Text; //obj.MapImage = ((TextBox)((DetailsView)sender).FindControl("MapImage")).Text; //obj.BonusMapImage = ((TextBox)((DetailsView)sender).FindControl("BonusMapImage")).Text; obj.BoardWidth = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("BoardWidth")).Text); //obj.BoardHeight = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("BoardHeight")).Text); obj.BonusLevelPointMultiplier = FormatHelper.SafeToDecimal(((TextBox)((DetailsView)sender).FindControl("BonusLevelPointMultiplier")).Text); //obj.LevelCompleteImage = ((TextBox)((DetailsView)sender).FindControl("LevelCompleteImage")).Text; obj.Minigame1ID = ((DropDownList)((DetailsView)sender).FindControl("Minigame1ID")).SelectedValue.SafeToInt(); obj.Minigame2ID = ((DropDownList)((DetailsView)sender).FindControl("Minigame2ID")).SelectedValue.SafeToInt(); 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); } } }
public bool Fetch(int PGID) { // declare reader SqlDataReader dr; SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@PGID", PGID); dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_ProgramGame_GetByID", arrParams); if (dr.Read()) { // declare return value ProgramGame result = new ProgramGame(); DateTime _datetime; int _int; decimal _decimal; if (int.TryParse(dr["PGID"].ToString(), out _int)) { this.PGID = _int; } this.GameName = dr["GameName"].ToString(); this.MapImage = dr["MapImage"].ToString(); this.BonusMapImage = dr["BonusMapImage"].ToString(); if (int.TryParse(dr["BoardWidth"].ToString(), out _int)) { this.BoardWidth = _int; } if (int.TryParse(dr["BoardHeight"].ToString(), out _int)) { this.BoardHeight = _int; } if (decimal.TryParse(dr["BonusLevelPointMultiplier"].ToString(), out _decimal)) { this.BonusLevelPointMultiplier = _decimal; } this.LevelCompleteImage = dr["LevelCompleteImage"].ToString(); this.LastModUser = dr["LastModUser"].ToString(); if (DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime)) { this.AddedDate = _datetime; } this.AddedUser = dr["AddedUser"].ToString(); if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime)) { this.LastModDate = _datetime; } if (int.TryParse(dr["TenID"].ToString(), out _int)) { this.TenID = _int; } if (int.TryParse(dr["FldInt1"].ToString(), out _int)) { this.FldInt1 = _int; } if (int.TryParse(dr["FldInt2"].ToString(), out _int)) { this.FldInt2 = _int; } if (int.TryParse(dr["FldInt3"].ToString(), out _int)) { this.FldInt3 = _int; } this.FldBit1 = bool.Parse(dr["FldBit1"].ToString()); this.FldBit2 = bool.Parse(dr["FldBit2"].ToString()); this.FldBit3 = bool.Parse(dr["FldBit3"].ToString()); this.FldText1 = dr["FldText1"].ToString(); this.FldText2 = dr["FldText2"].ToString(); this.FldText3 = dr["FldText3"].ToString(); if (int.TryParse(dr["Minigame1ID"].ToString(), out _int)) { this.Minigame1ID = _int; } if (int.TryParse(dr["Minigame2ID"].ToString(), out _int)) { this.Minigame2ID = _int; } dr.Close(); return(true); } dr.Close(); return(false); }
public static int Delete(ProgramGame o ) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@PGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PGID, o.PGID.GetTypeCode())); try { var fileName = (HttpContext.Current.Server.MapPath("~/Images/Games/Board/") + "\\" + o.PGID.ToString() + ".png"); File.Delete(fileName); fileName = (HttpContext.Current.Server.MapPath("~/Images/Games/Board/") + "\\bonus_" + o.PGID.ToString() + ".png"); File.Delete(fileName); fileName = (HttpContext.Current.Server.MapPath("~/Images/Games/Board/") + "\\stamp_" + o.PGID.ToString() + ".png"); File.Delete(fileName); iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_ProgramGame_Delete", arrParams); } catch(SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return iReturn; }
public static int Update(ProgramGame o ) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[24]; arrParams[0] = new SqlParameter("@PGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PGID, o.PGID.GetTypeCode())); arrParams[1] = new SqlParameter("@GameName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.GameName, o.GameName.GetTypeCode())); arrParams[2] = new SqlParameter("@MapImage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MapImage, o.MapImage.GetTypeCode())); arrParams[3] = new SqlParameter("@BonusMapImage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BonusMapImage, o.BonusMapImage.GetTypeCode())); arrParams[4] = new SqlParameter("@BoardWidth", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BoardWidth, o.BoardWidth.GetTypeCode())); arrParams[5] = new SqlParameter("@BoardHeight", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BoardHeight, o.BoardHeight.GetTypeCode())); arrParams[6] = new SqlParameter("@BonusLevelPointMultiplier", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BonusLevelPointMultiplier, o.BonusLevelPointMultiplier.GetTypeCode())); arrParams[7] = new SqlParameter("@LevelCompleteImage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LevelCompleteImage, o.LevelCompleteImage.GetTypeCode())); arrParams[8] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())); arrParams[9] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())); arrParams[10] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())); arrParams[11] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())); arrParams[12] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode())); arrParams[13] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())); arrParams[14] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())); arrParams[15] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())); arrParams[16] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())); arrParams[17] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())); arrParams[18] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())); arrParams[19] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())); arrParams[20] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())); arrParams[21] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())); arrParams[22] = new SqlParameter("@Minigame1ID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Minigame1ID, o.Minigame1ID.GetTypeCode())); arrParams[23] = new SqlParameter("@Minigame2ID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Minigame2ID, o.Minigame2ID.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_ProgramGame_Update", arrParams); } catch(SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return iReturn; }
public static int Insert(ProgramGame o ) { SqlParameter[] arrParams = new SqlParameter[24]; arrParams[0] = new SqlParameter("@GameName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.GameName, o.GameName.GetTypeCode())); arrParams[1] = new SqlParameter("@MapImage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MapImage, o.MapImage.GetTypeCode())); arrParams[2] = new SqlParameter("@BonusMapImage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BonusMapImage, o.BonusMapImage.GetTypeCode())); arrParams[3] = new SqlParameter("@BoardWidth", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BoardWidth, o.BoardWidth.GetTypeCode())); arrParams[4] = new SqlParameter("@BoardHeight", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BoardHeight, o.BoardHeight.GetTypeCode())); arrParams[5] = new SqlParameter("@BonusLevelPointMultiplier", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BonusLevelPointMultiplier, o.BonusLevelPointMultiplier.GetTypeCode())); arrParams[6] = new SqlParameter("@LevelCompleteImage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LevelCompleteImage, o.LevelCompleteImage.GetTypeCode())); arrParams[7] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())); arrParams[8] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())); arrParams[9] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())); arrParams[10] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())); arrParams[11] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode())); arrParams[12] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())); arrParams[13] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())); arrParams[14] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())); arrParams[15] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())); arrParams[16] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())); arrParams[17] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())); arrParams[18] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())); arrParams[19] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())); arrParams[20] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())); arrParams[21] = new SqlParameter("@Minigame1ID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Minigame1ID, o.Minigame1ID.GetTypeCode())); arrParams[22] = new SqlParameter("@Minigame2ID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Minigame2ID, o.Minigame2ID.GetTypeCode())); arrParams[23] = new SqlParameter("@PGID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PGID, o.PGID.GetTypeCode())); arrParams[23].Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_ProgramGame_Insert", arrParams); o.PGID = int.Parse(arrParams[23].Value.ToString()); return o.PGID; }
public bool Fetch(int PGID) { // declare reader SqlDataReader dr; SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@PGID", PGID); dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_ProgramGame_GetByID", arrParams); if(dr.Read()) { // declare return value ProgramGame result = new ProgramGame(); DateTime _datetime; int _int; decimal _decimal; if (int.TryParse(dr["PGID"].ToString(), out _int)) this.PGID = _int; this.GameName = dr["GameName"].ToString(); this.MapImage = dr["MapImage"].ToString(); this.BonusMapImage = dr["BonusMapImage"].ToString(); if (int.TryParse(dr["BoardWidth"].ToString(), out _int)) this.BoardWidth = _int; if (int.TryParse(dr["BoardHeight"].ToString(), out _int)) this.BoardHeight = _int; if (decimal.TryParse(dr["BonusLevelPointMultiplier"].ToString(), out _decimal)) this.BonusLevelPointMultiplier = _decimal; this.LevelCompleteImage = dr["LevelCompleteImage"].ToString(); this.LastModUser = dr["LastModUser"].ToString(); if (DateTime.TryParse(dr["AddedDate"].ToString(), out _datetime)) this.AddedDate = _datetime; this.AddedUser = dr["AddedUser"].ToString(); if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime)) this.LastModDate = _datetime; if (int.TryParse(dr["TenID"].ToString(), out _int)) this.TenID = _int; if (int.TryParse(dr["FldInt1"].ToString(), out _int)) this.FldInt1 = _int; if (int.TryParse(dr["FldInt2"].ToString(), out _int)) this.FldInt2 = _int; if (int.TryParse(dr["FldInt3"].ToString(), out _int)) this.FldInt3 = _int; this.FldBit1 = bool.Parse(dr["FldBit1"].ToString()); this.FldBit2 = bool.Parse(dr["FldBit2"].ToString()); this.FldBit3 = bool.Parse(dr["FldBit3"].ToString()); this.FldText1 = dr["FldText1"].ToString(); this.FldText2 = dr["FldText2"].ToString(); this.FldText3 = dr["FldText3"].ToString(); if (int.TryParse(dr["Minigame1ID"].ToString(), out _int)) this.Minigame1ID = _int; if (int.TryParse(dr["Minigame2ID"].ToString(), out _int)) this.Minigame2ID = _int; dr.Close(); return true; } dr.Close(); return false; }
protected void GvRowCommand(object sender, GridViewCommandEventArgs e) { string editpage = "~/ControlRoom/Modules/Setup/BoardGameAddEdit.aspx"; if (e.CommandName.ToLower() == "addrecord") { Session["BGID"]= string.Empty; Response.Redirect(editpage); } if (e.CommandName.ToLower() == "editrecord") { int key = Convert.ToInt32(e.CommandArgument); Session["BGID"] = key; Response.Redirect(editpage); } if (e.CommandName.ToLower() == "deleterecord") { var key = Convert.ToInt32(e.CommandArgument); try { var obj = new ProgramGame(); if (obj.IsValid(BusinessRulesValidationMode.DELETE)) { ProgramGame.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); } } }