public static int Update(PatronPrizes o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[11]; arrParams[0] = new SqlParameter("@PPID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PPID, o.PPID.GetTypeCode())); arrParams[1] = new SqlParameter("@PID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PID, o.PID.GetTypeCode())); arrParams[2] = new SqlParameter("@PrizeSource", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PrizeSource, o.PrizeSource.GetTypeCode())); arrParams[3] = new SqlParameter("@BadgeID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BadgeID, o.BadgeID.GetTypeCode())); arrParams[4] = new SqlParameter("@DrawingID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.DrawingID, o.DrawingID.GetTypeCode())); arrParams[5] = new SqlParameter("@PrizeName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PrizeName, o.PrizeName.GetTypeCode())); arrParams[6] = new SqlParameter("@RedeemedFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.RedeemedFlag, o.RedeemedFlag.GetTypeCode())); arrParams[7] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.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())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_PatronPrizes_Update", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return(iReturn); }
public static int Delete(PatronPrizes o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@PPID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PPID, o.PPID.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_PatronPrizes_Delete", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return(iReturn); }
public static int Insert(PatronPrizes o) { SqlParameter[] arrParams = new SqlParameter[11]; arrParams[0] = new SqlParameter("@PID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PID, o.PID.GetTypeCode())); arrParams[1] = new SqlParameter("@PrizeSource", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PrizeSource, o.PrizeSource.GetTypeCode())); arrParams[2] = new SqlParameter("@BadgeID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BadgeID, o.BadgeID.GetTypeCode())); arrParams[3] = new SqlParameter("@DrawingID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.DrawingID, o.DrawingID.GetTypeCode())); arrParams[4] = new SqlParameter("@PrizeName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PrizeName, o.PrizeName.GetTypeCode())); arrParams[5] = new SqlParameter("@RedeemedFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.RedeemedFlag, o.RedeemedFlag.GetTypeCode())); arrParams[6] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.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("@PPID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PPID, o.PPID.GetTypeCode())); arrParams[10].Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_PatronPrizes_Insert", arrParams); o.PPID = int.Parse(arrParams[10].Value.ToString()); return(o.PPID); }
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); }
public bool Fetch(int PPID) { // declare reader SqlDataReader dr; SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@PPID", PPID); dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_PatronPrizes_GetByID", arrParams); if (dr.Read()) { // declare return value PatronPrizes result = new PatronPrizes(); DateTime _datetime; int _int; //decimal _decimal; if (int.TryParse(dr["PPID"].ToString(), out _int)) { this.PPID = _int; } if (int.TryParse(dr["PID"].ToString(), out _int)) { this.PID = _int; } if (int.TryParse(dr["PrizeSource"].ToString(), out _int)) { this.PrizeSource = _int; } if (int.TryParse(dr["BadgeID"].ToString(), out _int)) { this.BadgeID = _int; } if (int.TryParse(dr["DrawingID"].ToString(), out _int)) { this.DrawingID = _int; } this.PrizeName = dr["PrizeName"].ToString(); this.RedeemedFlag = bool.Parse(dr["RedeemedFlag"].ToString()); 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(); dr.Close(); return(true); } dr.Close(); return(false); }
public static int Delete(PatronPrizes o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@PPID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PPID, o.PPID.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_PatronPrizes_Delete", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return iReturn; }
public static int Update(PatronPrizes o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[11]; arrParams[0] = new SqlParameter("@PPID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PPID, o.PPID.GetTypeCode())); arrParams[1] = new SqlParameter("@PID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PID, o.PID.GetTypeCode())); arrParams[2] = new SqlParameter("@PrizeSource", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PrizeSource, o.PrizeSource.GetTypeCode())); arrParams[3] = new SqlParameter("@BadgeID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BadgeID, o.BadgeID.GetTypeCode())); arrParams[4] = new SqlParameter("@DrawingID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.DrawingID, o.DrawingID.GetTypeCode())); arrParams[5] = new SqlParameter("@PrizeName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PrizeName, o.PrizeName.GetTypeCode())); arrParams[6] = new SqlParameter("@RedeemedFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.RedeemedFlag, o.RedeemedFlag.GetTypeCode())); arrParams[7] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.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())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_PatronPrizes_Update", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return iReturn; }
public static int Insert(PatronPrizes o) { SqlParameter[] arrParams = new SqlParameter[11]; arrParams[0] = new SqlParameter("@PID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PID, o.PID.GetTypeCode())); arrParams[1] = new SqlParameter("@PrizeSource", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PrizeSource, o.PrizeSource.GetTypeCode())); arrParams[2] = new SqlParameter("@BadgeID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BadgeID, o.BadgeID.GetTypeCode())); arrParams[3] = new SqlParameter("@DrawingID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.DrawingID, o.DrawingID.GetTypeCode())); arrParams[4] = new SqlParameter("@PrizeName", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PrizeName, o.PrizeName.GetTypeCode())); arrParams[5] = new SqlParameter("@RedeemedFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.RedeemedFlag, o.RedeemedFlag.GetTypeCode())); arrParams[6] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.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("@PPID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PPID, o.PPID.GetTypeCode())); arrParams[10].Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_PatronPrizes_Insert", arrParams); o.PPID = int.Parse(arrParams[10].Value.ToString()); return o.PPID; }
public bool Fetch(int PPID) { // declare reader SqlDataReader dr; SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@PPID", PPID); dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_PatronPrizes_GetByID", arrParams); if (dr.Read()) { // declare return value PatronPrizes result = new PatronPrizes(); DateTime _datetime; int _int; //decimal _decimal; if (int.TryParse(dr["PPID"].ToString(), out _int)) this.PPID = _int; if (int.TryParse(dr["PID"].ToString(), out _int)) this.PID = _int; if (int.TryParse(dr["PrizeSource"].ToString(), out _int)) this.PrizeSource = _int; if (int.TryParse(dr["BadgeID"].ToString(), out _int)) this.BadgeID = _int; if (int.TryParse(dr["DrawingID"].ToString(), out _int)) this.DrawingID = _int; this.PrizeName = dr["PrizeName"].ToString(); this.RedeemedFlag = bool.Parse(dr["RedeemedFlag"].ToString()); 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(); 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; }