public static int Update(PrizeTemplate o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[33]; arrParams[0] = new SqlParameter("@TID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TID, o.TID.GetTypeCode())); arrParams[1] = new SqlParameter("@TName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TName, o.TName.GetTypeCode())); arrParams[2] = new SqlParameter("@NumPrizes", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.NumPrizes, o.NumPrizes.GetTypeCode())); arrParams[3] = new SqlParameter("@IncPrevWinnersFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.IncPrevWinnersFlag, o.IncPrevWinnersFlag.GetTypeCode())); arrParams[4] = new SqlParameter("@SendNotificationFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SendNotificationFlag, o.SendNotificationFlag.GetTypeCode())); arrParams[5] = new SqlParameter("@NotificationSubject", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.NotificationSubject, o.NotificationSubject.GetTypeCode())); arrParams[6] = new SqlParameter("@NotificationMessage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.NotificationMessage, o.NotificationMessage.GetTypeCode())); arrParams[7] = new SqlParameter("@ProgID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ProgID, o.ProgID.GetTypeCode())); arrParams[8] = new SqlParameter("@Gender", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Gender, o.Gender.GetTypeCode())); arrParams[9] = new SqlParameter("@SchoolName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SchoolName, o.SchoolName.GetTypeCode())); arrParams[10] = new SqlParameter("@PrimaryLibrary", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PrimaryLibrary, o.PrimaryLibrary.GetTypeCode())); arrParams[11] = new SqlParameter("@MinPoints", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MinPoints, o.MinPoints.GetTypeCode())); arrParams[12] = new SqlParameter("@MaxPoints", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MaxPoints, o.MaxPoints.GetTypeCode())); arrParams[13] = new SqlParameter("@LogDateStart", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LogDateStart, o.LogDateStart.GetTypeCode())); arrParams[14] = new SqlParameter("@LogDateEnd", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LogDateEnd, o.LogDateEnd.GetTypeCode())); arrParams[15] = new SqlParameter("@MinReviews", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MinReviews, o.MinReviews.GetTypeCode())); arrParams[16] = new SqlParameter("@MaxReviews", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MaxReviews, o.MaxReviews.GetTypeCode())); arrParams[17] = new SqlParameter("@ReviewDateStart", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ReviewDateStart, o.ReviewDateStart.GetTypeCode())); arrParams[18] = new SqlParameter("@ReviewDateEnd", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ReviewDateEnd, o.ReviewDateEnd.GetTypeCode())); arrParams[19] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())); arrParams[20] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())); arrParams[21] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())); arrParams[22] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())); arrParams[23] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode())); arrParams[24] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())); arrParams[25] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())); arrParams[26] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())); arrParams[27] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())); arrParams[28] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())); arrParams[29] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())); arrParams[30] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())); arrParams[31] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())); arrParams[32] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_PrizeTemplate_Update", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return(iReturn); }
public static int Insert(PrizeTemplate o) { SqlParameter[] arrParams = new SqlParameter[33]; arrParams[0] = new SqlParameter("@TName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TName, o.TName.GetTypeCode())); arrParams[1] = new SqlParameter("@NumPrizes", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.NumPrizes, o.NumPrizes.GetTypeCode())); arrParams[2] = new SqlParameter("@IncPrevWinnersFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.IncPrevWinnersFlag, o.IncPrevWinnersFlag.GetTypeCode())); arrParams[3] = new SqlParameter("@SendNotificationFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SendNotificationFlag, o.SendNotificationFlag.GetTypeCode())); arrParams[4] = new SqlParameter("@NotificationSubject", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.NotificationSubject, o.NotificationSubject.GetTypeCode())); arrParams[5] = new SqlParameter("@NotificationMessage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.NotificationMessage, o.NotificationMessage.GetTypeCode())); arrParams[6] = new SqlParameter("@ProgID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ProgID, o.ProgID.GetTypeCode())); arrParams[7] = new SqlParameter("@Gender", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Gender, o.Gender.GetTypeCode())); arrParams[8] = new SqlParameter("@SchoolName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SchoolName, o.SchoolName.GetTypeCode())); arrParams[9] = new SqlParameter("@PrimaryLibrary", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PrimaryLibrary, o.PrimaryLibrary.GetTypeCode())); arrParams[10] = new SqlParameter("@MinPoints", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MinPoints, o.MinPoints.GetTypeCode())); arrParams[11] = new SqlParameter("@MaxPoints", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MaxPoints, o.MaxPoints.GetTypeCode())); arrParams[12] = new SqlParameter("@LogDateStart", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LogDateStart, o.LogDateStart.GetTypeCode())); arrParams[13] = new SqlParameter("@LogDateEnd", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LogDateEnd, o.LogDateEnd.GetTypeCode())); arrParams[14] = new SqlParameter("@MinReviews", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MinReviews, o.MinReviews.GetTypeCode())); arrParams[15] = new SqlParameter("@MaxReviews", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MaxReviews, o.MaxReviews.GetTypeCode())); arrParams[16] = new SqlParameter("@ReviewDateStart", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ReviewDateStart, o.ReviewDateStart.GetTypeCode())); arrParams[17] = new SqlParameter("@ReviewDateEnd", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ReviewDateEnd, o.ReviewDateEnd.GetTypeCode())); arrParams[18] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())); arrParams[19] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())); arrParams[20] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())); arrParams[21] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())); arrParams[22] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode())); arrParams[23] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())); arrParams[24] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())); arrParams[25] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())); arrParams[26] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())); arrParams[27] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())); arrParams[28] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())); arrParams[29] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())); arrParams[30] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())); arrParams[31] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())); arrParams[32] = new SqlParameter("@TID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TID, o.TID.GetTypeCode())); arrParams[32].Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_PrizeTemplate_Insert", arrParams); o.TID = int.Parse(arrParams[32].Value.ToString()); return(o.TID); }
public static int Delete(PrizeTemplate o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@TID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TID, o.TID.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_PrizeTemplate_Delete", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return(iReturn); }
public bool Fetch(int TID) { // declare reader SqlDataReader dr; SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@TID", TID); dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_PrizeTemplate_GetByID", arrParams); if (dr.Read()) { // declare return value PrizeTemplate result = new PrizeTemplate(); DateTime _datetime; int _int; //decimal _decimal; if (int.TryParse(dr["TID"].ToString(), out _int)) { this.TID = _int; } this.TName = dr["TName"].ToString(); if (int.TryParse(dr["NumPrizes"].ToString(), out _int)) { this.NumPrizes = _int; } this.IncPrevWinnersFlag = bool.Parse(dr["IncPrevWinnersFlag"].ToString()); this.SendNotificationFlag = bool.Parse(dr["SendNotificationFlag"].ToString()); this.NotificationSubject = dr["NotificationSubject"].ToString(); this.NotificationMessage = dr["NotificationMessage"].ToString(); if (int.TryParse(dr["ProgID"].ToString(), out _int)) { this.ProgID = _int; } this.Gender = dr["Gender"].ToString(); this.SchoolName = dr["SchoolName"].ToString(); if (int.TryParse(dr["PrimaryLibrary"].ToString(), out _int)) { this.PrimaryLibrary = _int; } if (int.TryParse(dr["MinPoints"].ToString(), out _int)) { this.MinPoints = _int; } if (int.TryParse(dr["MaxPoints"].ToString(), out _int)) { this.MaxPoints = _int; } if (DateTime.TryParse(dr["LogDateStart"].ToString(), out _datetime)) { this.LogDateStart = _datetime; } if (DateTime.TryParse(dr["LogDateEnd"].ToString(), out _datetime)) { this.LogDateEnd = _datetime; } if (int.TryParse(dr["MinReviews"].ToString(), out _int)) { this.MinReviews = _int; } if (int.TryParse(dr["MaxReviews"].ToString(), out _int)) { this.MaxReviews = _int; } if (DateTime.TryParse(dr["ReviewDateStart"].ToString(), out _datetime)) { this.ReviewDateStart = _datetime; } if (DateTime.TryParse(dr["ReviewDateEnd"].ToString(), out _datetime)) { this.ReviewDateEnd = _datetime; } 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["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(); dr.Close(); return(true); } dr.Close(); return(false); }
public static int DrawWinners(int PDID, int numWinners, int additional = 0) { SqlParameter[] arrParams = new SqlParameter[3]; arrParams[0] = new SqlParameter("@PDID", PDID); arrParams[1] = new SqlParameter("@NumWinners", numWinners); arrParams[2] = new SqlParameter("@Additional", additional); var ds = SqlHelper.ExecuteDataset(conn, CommandType.StoredProcedure, "app_PrizeDrawing_DrawWinners", arrParams); var ret = ds.Tables[0].Rows.Count; var pd = PrizeDrawing.FetchObject(PDID); var pt = PrizeTemplate.FetchObject(pd.TID); var now = DateTime.Now; for (var i = 0; i < ds.Tables[0].Rows.Count; i++) { int PID = (int)ds.Tables[0].Rows[i]["PatronID"]; int NID = (int)ds.Tables[0].Rows[i]["NotificationID"]; int PDWID = (int)ds.Tables[0].Rows[i]["PDWID"]; // insert patron prize var pp = new PatronPrizes { PID = PID, PrizeSource = 0, BadgeID = 0, DrawingID = PDWID, PrizeName = pd.PrizeName, RedeemedFlag = false, AddedDate = now, LastModDate = now, AddedUser = "******", LastModUser = "******" }; pp.Insert(); if (pt.SendNotificationFlag) { // generate notification var not = new Notifications { PID_To = PID, PID_From = 0, //0 == System Notification Subject = pt.NotificationSubject, Body = pt.NotificationMessage, isQuestion = false, AddedDate = now, LastModDate = now, AddedUser = "******", LastModUser = "******" }; not.Insert(); var w = PrizeDrawingWinners.FetchObject(PDWID); w.NotificationID = not.NID; w.Update(); } else { var w = PrizeDrawingWinners.FetchObject(PDWID); w.NotificationID = -1; w.Update(); } } return(ret); }
protected void GvRowCommand(object sender, GridViewCommandEventArgs e) { string editpage = "~/ControlRoom/Modules/Drawings/PrizeTemplateAddEdit.aspx"; if (e.CommandName.ToLower() == "addrecord") { Session["DTD"]= string.Empty; Response.Redirect(editpage); } if (e.CommandName.ToLower() == "editrecord") { int key = Convert.ToInt32(e.CommandArgument); Session["DTD"] = key; Response.Redirect(editpage); } if (e.CommandName.ToLower() == "deleterecord") { var key = Convert.ToInt32(e.CommandArgument); try { var obj = new PrizeTemplate(); if (obj.IsValid(BusinessRulesValidationMode.DELETE)) { PrizeTemplate.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); } } }
public static int Delete(PrizeTemplate o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@TID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TID, o.TID.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_PrizeTemplate_Delete", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return iReturn; }
public static int Update(PrizeTemplate o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[33]; arrParams[0] = new SqlParameter("@TID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TID, o.TID.GetTypeCode())); arrParams[1] = new SqlParameter("@TName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TName, o.TName.GetTypeCode())); arrParams[2] = new SqlParameter("@NumPrizes", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.NumPrizes, o.NumPrizes.GetTypeCode())); arrParams[3] = new SqlParameter("@IncPrevWinnersFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.IncPrevWinnersFlag, o.IncPrevWinnersFlag.GetTypeCode())); arrParams[4] = new SqlParameter("@SendNotificationFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SendNotificationFlag, o.SendNotificationFlag.GetTypeCode())); arrParams[5] = new SqlParameter("@NotificationSubject", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.NotificationSubject, o.NotificationSubject.GetTypeCode())); arrParams[6] = new SqlParameter("@NotificationMessage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.NotificationMessage, o.NotificationMessage.GetTypeCode())); arrParams[7] = new SqlParameter("@ProgID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ProgID, o.ProgID.GetTypeCode())); arrParams[8] = new SqlParameter("@Gender", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Gender, o.Gender.GetTypeCode())); arrParams[9] = new SqlParameter("@SchoolName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SchoolName, o.SchoolName.GetTypeCode())); arrParams[10] = new SqlParameter("@PrimaryLibrary", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PrimaryLibrary, o.PrimaryLibrary.GetTypeCode())); arrParams[11] = new SqlParameter("@MinPoints", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MinPoints, o.MinPoints.GetTypeCode())); arrParams[12] = new SqlParameter("@MaxPoints", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MaxPoints, o.MaxPoints.GetTypeCode())); arrParams[13] = new SqlParameter("@LogDateStart", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LogDateStart, o.LogDateStart.GetTypeCode())); arrParams[14] = new SqlParameter("@LogDateEnd", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LogDateEnd, o.LogDateEnd.GetTypeCode())); arrParams[15] = new SqlParameter("@MinReviews", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MinReviews, o.MinReviews.GetTypeCode())); arrParams[16] = new SqlParameter("@MaxReviews", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MaxReviews, o.MaxReviews.GetTypeCode())); arrParams[17] = new SqlParameter("@ReviewDateStart", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ReviewDateStart, o.ReviewDateStart.GetTypeCode())); arrParams[18] = new SqlParameter("@ReviewDateEnd", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ReviewDateEnd, o.ReviewDateEnd.GetTypeCode())); arrParams[19] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())); arrParams[20] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())); arrParams[21] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())); arrParams[22] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())); arrParams[23] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode())); arrParams[24] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())); arrParams[25] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())); arrParams[26] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())); arrParams[27] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())); arrParams[28] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())); arrParams[29] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())); arrParams[30] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())); arrParams[31] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())); arrParams[32] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_PrizeTemplate_Update", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return iReturn; }
public static int Insert(PrizeTemplate o) { SqlParameter[] arrParams = new SqlParameter[33]; arrParams[0] = new SqlParameter("@TName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TName, o.TName.GetTypeCode())); arrParams[1] = new SqlParameter("@NumPrizes", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.NumPrizes, o.NumPrizes.GetTypeCode())); arrParams[2] = new SqlParameter("@IncPrevWinnersFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.IncPrevWinnersFlag, o.IncPrevWinnersFlag.GetTypeCode())); arrParams[3] = new SqlParameter("@SendNotificationFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SendNotificationFlag, o.SendNotificationFlag.GetTypeCode())); arrParams[4] = new SqlParameter("@NotificationSubject", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.NotificationSubject, o.NotificationSubject.GetTypeCode())); arrParams[5] = new SqlParameter("@NotificationMessage", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.NotificationMessage, o.NotificationMessage.GetTypeCode())); arrParams[6] = new SqlParameter("@ProgID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ProgID, o.ProgID.GetTypeCode())); arrParams[7] = new SqlParameter("@Gender", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.Gender, o.Gender.GetTypeCode())); arrParams[8] = new SqlParameter("@SchoolName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.SchoolName, o.SchoolName.GetTypeCode())); arrParams[9] = new SqlParameter("@PrimaryLibrary", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PrimaryLibrary, o.PrimaryLibrary.GetTypeCode())); arrParams[10] = new SqlParameter("@MinPoints", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MinPoints, o.MinPoints.GetTypeCode())); arrParams[11] = new SqlParameter("@MaxPoints", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MaxPoints, o.MaxPoints.GetTypeCode())); arrParams[12] = new SqlParameter("@LogDateStart", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LogDateStart, o.LogDateStart.GetTypeCode())); arrParams[13] = new SqlParameter("@LogDateEnd", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LogDateEnd, o.LogDateEnd.GetTypeCode())); arrParams[14] = new SqlParameter("@MinReviews", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MinReviews, o.MinReviews.GetTypeCode())); arrParams[15] = new SqlParameter("@MaxReviews", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.MaxReviews, o.MaxReviews.GetTypeCode())); arrParams[16] = new SqlParameter("@ReviewDateStart", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ReviewDateStart, o.ReviewDateStart.GetTypeCode())); arrParams[17] = new SqlParameter("@ReviewDateEnd", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ReviewDateEnd, o.ReviewDateEnd.GetTypeCode())); arrParams[18] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())); arrParams[19] = new SqlParameter("@LastModUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModUser, o.LastModUser.GetTypeCode())); arrParams[20] = new SqlParameter("@AddedDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedDate, o.AddedDate.GetTypeCode())); arrParams[21] = new SqlParameter("@AddedUser", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.AddedUser, o.AddedUser.GetTypeCode())); arrParams[22] = new SqlParameter("@TenID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TenID, o.TenID.GetTypeCode())); arrParams[23] = new SqlParameter("@FldInt1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt1, o.FldInt1.GetTypeCode())); arrParams[24] = new SqlParameter("@FldInt2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt2, o.FldInt2.GetTypeCode())); arrParams[25] = new SqlParameter("@FldInt3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldInt3, o.FldInt3.GetTypeCode())); arrParams[26] = new SqlParameter("@FldBit1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit1, o.FldBit1.GetTypeCode())); arrParams[27] = new SqlParameter("@FldBit2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit2, o.FldBit2.GetTypeCode())); arrParams[28] = new SqlParameter("@FldBit3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldBit3, o.FldBit3.GetTypeCode())); arrParams[29] = new SqlParameter("@FldText1", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText1, o.FldText1.GetTypeCode())); arrParams[30] = new SqlParameter("@FldText2", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText2, o.FldText2.GetTypeCode())); arrParams[31] = new SqlParameter("@FldText3", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.FldText3, o.FldText3.GetTypeCode())); arrParams[32] = new SqlParameter("@TID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.TID, o.TID.GetTypeCode())); arrParams[32].Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_PrizeTemplate_Insert", arrParams); o.TID = int.Parse(arrParams[32].Value.ToString()); return o.TID; }
public bool Fetch(int TID) { // declare reader SqlDataReader dr; SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@TID", TID); dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_PrizeTemplate_GetByID", arrParams); if (dr.Read()) { // declare return value PrizeTemplate result = new PrizeTemplate(); DateTime _datetime; int _int; //decimal _decimal; if (int.TryParse(dr["TID"].ToString(), out _int)) this.TID = _int; this.TName = dr["TName"].ToString(); if (int.TryParse(dr["NumPrizes"].ToString(), out _int)) this.NumPrizes = _int; this.IncPrevWinnersFlag = bool.Parse(dr["IncPrevWinnersFlag"].ToString()); this.SendNotificationFlag = bool.Parse(dr["SendNotificationFlag"].ToString()); this.NotificationSubject = dr["NotificationSubject"].ToString(); this.NotificationMessage = dr["NotificationMessage"].ToString(); if (int.TryParse(dr["ProgID"].ToString(), out _int)) this.ProgID = _int; this.Gender = dr["Gender"].ToString(); this.SchoolName = dr["SchoolName"].ToString(); if (int.TryParse(dr["PrimaryLibrary"].ToString(), out _int)) this.PrimaryLibrary = _int; if (int.TryParse(dr["MinPoints"].ToString(), out _int)) this.MinPoints = _int; if (int.TryParse(dr["MaxPoints"].ToString(), out _int)) this.MaxPoints = _int; if (DateTime.TryParse(dr["LogDateStart"].ToString(), out _datetime)) this.LogDateStart = _datetime; if (DateTime.TryParse(dr["LogDateEnd"].ToString(), out _datetime)) this.LogDateEnd = _datetime; if (int.TryParse(dr["MinReviews"].ToString(), out _int)) this.MinReviews = _int; if (int.TryParse(dr["MaxReviews"].ToString(), out _int)) this.MaxReviews = _int; if (DateTime.TryParse(dr["ReviewDateStart"].ToString(), out _datetime)) this.ReviewDateStart = _datetime; if (DateTime.TryParse(dr["ReviewDateEnd"].ToString(), out _datetime)) this.ReviewDateEnd = _datetime; 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["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(); dr.Close(); return true; } dr.Close(); return false; }
protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e) { string returnURL = "~/ControlRoom/Modules/Drawings/TemplateList.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 PrizeTemplate(); //obj.GenNotificationFlag = ((CheckBox)((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2").FindControl("GenNotificationFlag")).Checked; obj.TName = ((TextBox)((DetailsView)sender).FindControl("TName")).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; if (obj.IsValid(BusinessRulesValidationMode.INSERT)) { obj.Insert(); if (e.CommandName.ToLower() == "addandback") { Response.Redirect(returnURL); } lblPK.Text = obj.TID.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 PrizeTemplate(); int pk = int.Parse(((DetailsView)sender).Rows[0].Cells[1].Text); obj.Fetch(pk); obj.TName = ((TextBox)((DetailsView)sender).FindControl("TName")).Text; obj.NumPrizes = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("NumPrizes")).Text); obj.IncPrevWinnersFlag = ((CheckBox)((DetailsView)sender).FindControl("IncPrevWinnersFlag")).Checked; obj.SendNotificationFlag = ((CheckBox)((DetailsView)sender).FindControl("SendNotificationFlag")).Checked; obj.NotificationSubject = ((TextBox)((DetailsView)sender).FindControl("NotificationSubject")).Text; obj.NotificationMessage = ((HtmlTextArea)((DetailsView)sender).FindControl("NotificationMessage")).InnerHtml; obj.ProgID = FormatHelper.SafeToInt(((DropDownList) ((DetailsView) sender).FindControl("ProgID")).SelectedValue); obj.Gender = ((DropDownList)((DetailsView)sender).FindControl("Gender")).SelectedValue; obj.PrimaryLibrary = FormatHelper.SafeToInt(((DropDownList) ((DetailsView) sender).FindControl("PrimaryLibrary")).SelectedValue); obj.MinPoints = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("MinPoints")).Text); obj.MaxPoints = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("MaxPoints")).Text); obj.LogDateStart = FormatHelper.SafeToDateTime(((TextBox)((DetailsView)sender).FindControl("LogDateStart")).Text); obj.LogDateEnd = FormatHelper.SafeToDateTime(((TextBox)((DetailsView)sender).FindControl("LogDateEnd")).Text); obj.MinReviews = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("MinReviews")).Text); obj.MaxReviews = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("MaxReviews")).Text); obj.ReviewDateStart = FormatHelper.SafeToDateTime(((TextBox)((DetailsView)sender).FindControl("ReviewDateStart")).Text); obj.ReviewDateEnd = FormatHelper.SafeToDateTime(((TextBox)((DetailsView)sender).FindControl("ReviewDateEnd")).Text); obj.SchoolName = ((DropDownList)((DetailsView)sender).FindControl("SchoolName")).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); } } }