public static int Update(PatronBookLists o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[6]; arrParams[0] = new SqlParameter("@PBLBID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PBLBID, o.PBLBID.GetTypeCode())); arrParams[1] = new SqlParameter("@PID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PID, o.PID.GetTypeCode())); arrParams[2] = new SqlParameter("@BLBID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BLBID, o.BLBID.GetTypeCode())); arrParams[3] = new SqlParameter("@BLID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BLID, o.BLID.GetTypeCode())); arrParams[4] = new SqlParameter("@HasReadFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HasReadFlag, o.HasReadFlag.GetTypeCode())); arrParams[5] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_PatronBookLists_Update", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return(iReturn); }
public static PatronBookLists FetchObject(int PBLBID) { // declare reader SqlDataReader dr; SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@PBLBID", PBLBID); dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_PatronBookLists_GetByID", arrParams); if (dr.Read()) { // declare return value PatronBookLists result = new PatronBookLists(); DateTime _datetime; int _int; //decimal _decimal; if (int.TryParse(dr["PBLBID"].ToString(), out _int)) { result.PBLBID = _int; } if (int.TryParse(dr["PID"].ToString(), out _int)) { result.PID = _int; } if (int.TryParse(dr["BLBID"].ToString(), out _int)) { result.BLBID = _int; } if (int.TryParse(dr["BLID"].ToString(), out _int)) { result.BLID = _int; } result.HasReadFlag = bool.Parse(dr["HasReadFlag"].ToString()); if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime)) { result.LastModDate = _datetime; } dr.Close(); return(result); } dr.Close(); return(null); }
public static int Insert(PatronBookLists o) { SqlParameter[] arrParams = new SqlParameter[6]; arrParams[0] = new SqlParameter("@PID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PID, o.PID.GetTypeCode())); arrParams[1] = new SqlParameter("@BLBID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BLBID, o.BLBID.GetTypeCode())); arrParams[2] = new SqlParameter("@BLID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BLID, o.BLID.GetTypeCode())); arrParams[3] = new SqlParameter("@HasReadFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HasReadFlag, o.HasReadFlag.GetTypeCode())); arrParams[4] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())); arrParams[5] = new SqlParameter("@PBLBID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PBLBID, o.PBLBID.GetTypeCode())); arrParams[5].Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_PatronBookLists_Insert", arrParams); o.PBLBID = int.Parse(arrParams[5].Value.ToString()); return(o.PBLBID); }
protected void btnSave_Click(object sender, EventArgs e) { if (!this.ProgramOpen) { return; } var now = DateTime.Now; var onlyCheckedBoxes = true; var selBLI = 0; var readCount = 0; var neeedCount = 0; var BLID = -1; foreach (RepeaterItem item in rptr2.Items) { if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { if (BLID < 0) { BLID = int.Parse(((Label)item.FindControl("BLID")).Text); neeedCount = BookList.FetchObject(BLID).NumBooksToComplete; } var chkRead = (CheckBox)item.FindControl("chkRead"); var PBLBID = int.Parse(((Label)item.FindControl("PBLBID")).Text); var BLBID = int.Parse(((Label)item.FindControl("BLBID")).Text); selBLI = BLID; var pbl = new PatronBookLists(); if (PBLBID != 0) { pbl = PatronBookLists.FetchObject(PBLBID); } pbl.BLBID = BLBID; pbl.BLID = BLID; pbl.PID = this.CurrentPatron.PID; pbl.LastModDate = now; pbl.HasReadFlag = chkRead.Checked; if (!pbl.HasReadFlag) { onlyCheckedBoxes = false; } else { readCount++; } if (PBLBID != 0) { pbl.Update(); } else { pbl.Insert(); } } } string success = StringResources.getString("challenges-progress-saved"); new SessionTools(Session).AlertPatron(success, glyphicon: "check"); // read the entire book list! Award points and badges if ((neeedCount == 0 && onlyCheckedBoxes) || (neeedCount <= readCount)) { success = StringResources.getString("challenges-completed"); new SessionTools(Session).AlertPatron(success, glyphicon: "star"); var bl = BookList.FetchObject(selBLI); if (PatronPoints.HasEarnedBookList(this.CurrentPatron.PID, selBLI)) { PopulateChallengeList(); return; } if (bl.AwardBadgeID != 0 || bl.AwardPoints != 0) { success = StringResources.getString("challenges-completed-badge"); new SessionTools(Session).AlertPatron(success, glyphicon: "certificate"); var pa = new AwardPoints(this.CurrentPatron.PID); var sBadges = pa.AwardPointsToPatron(bl.AwardPoints, PointAwardReason.BookListCompletion, bookListID: bl.BLID); if (sBadges.Length > 0) { new SessionTools(Session).EarnedBadges(sBadges); } } } PopulateChallengeList(); }
public static PatronBookLists FetchObject(int PBLBID) { // declare reader SqlDataReader dr; SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@PBLBID", PBLBID); dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_PatronBookLists_GetByID", arrParams); if (dr.Read()) { // declare return value PatronBookLists result = new PatronBookLists(); DateTime _datetime; int _int; //decimal _decimal; if (int.TryParse(dr["PBLBID"].ToString(), out _int)) result.PBLBID = _int; if (int.TryParse(dr["PID"].ToString(), out _int)) result.PID = _int; if (int.TryParse(dr["BLBID"].ToString(), out _int)) result.BLBID = _int; if (int.TryParse(dr["BLID"].ToString(), out _int)) result.BLID = _int; result.HasReadFlag = bool.Parse(dr["HasReadFlag"].ToString()); if (DateTime.TryParse(dr["LastModDate"].ToString(), out _datetime)) result.LastModDate = _datetime; dr.Close(); return result; } dr.Close(); return null; }
public static int Delete(PatronBookLists o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@PBLBID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PBLBID, o.PBLBID.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_PatronBookLists_Delete", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return iReturn; }
public static int Insert(PatronBookLists o) { SqlParameter[] arrParams = new SqlParameter[6]; arrParams[0] = new SqlParameter("@PID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PID, o.PID.GetTypeCode())); arrParams[1] = new SqlParameter("@BLBID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BLBID, o.BLBID.GetTypeCode())); arrParams[2] = new SqlParameter("@BLID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.BLID, o.BLID.GetTypeCode())); arrParams[3] = new SqlParameter("@HasReadFlag", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.HasReadFlag, o.HasReadFlag.GetTypeCode())); arrParams[4] = new SqlParameter("@LastModDate", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.LastModDate, o.LastModDate.GetTypeCode())); arrParams[5] = new SqlParameter("@PBLBID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PBLBID, o.PBLBID.GetTypeCode())); arrParams[5].Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_PatronBookLists_Insert", arrParams); o.PBLBID = int.Parse(arrParams[5].Value.ToString()); return o.PBLBID; }