public static int Update(ProgramCodes o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[9]; arrParams[0] = new SqlParameter("@PCID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PCID, o.PCID.GetTypeCode())); arrParams[1] = new SqlParameter("@PID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PID, o.PID.GetTypeCode())); arrParams[2] = new SqlParameter("@CodeNumber", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.CodeNumber, o.CodeNumber.GetTypeCode())); arrParams[3] = new SqlParameter("@CodeValue", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.CodeValue, o.CodeValue.GetTypeCode())); arrParams[4] = new SqlParameter("@ShortCode", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ShortCode, o.ShortCode.GetTypeCode())); arrParams[5] = new SqlParameter("@isUsed", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.isUsed, o.isUsed.GetTypeCode())); arrParams[6] = new SqlParameter("@DateCreated", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.DateCreated, o.DateCreated.GetTypeCode())); arrParams[7] = new SqlParameter("@DateUsed", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.DateUsed, o.DateUsed.GetTypeCode())); arrParams[8] = new SqlParameter("@PatronId", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PatronId, o.PatronId.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_ProgramCodes_Update", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return(iReturn); }
public static int Delete(ProgramCodes o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@PCID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PCID, o.PCID.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_ProgramCodes_Delete", arrParams); } catch (SqlException exx) { System.Diagnostics.Debug.Write(exx.Message); } return(iReturn); }
public static int Insert(ProgramCodes o) { SqlParameter[] arrParams = new SqlParameter[9]; arrParams[0] = new SqlParameter("@PID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PID, o.PID.GetTypeCode())); arrParams[1] = new SqlParameter("@CodeNumber", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.CodeNumber, o.CodeNumber.GetTypeCode())); arrParams[2] = new SqlParameter("@CodeValue", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.CodeValue, o.CodeValue.GetTypeCode())); arrParams[3] = new SqlParameter("@ShortCode", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ShortCode, o.ShortCode.GetTypeCode())); arrParams[4] = new SqlParameter("@isUsed", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.isUsed, o.isUsed.GetTypeCode())); arrParams[5] = new SqlParameter("@DateCreated", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.DateCreated, o.DateCreated.GetTypeCode())); arrParams[6] = new SqlParameter("@DateUsed", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.DateUsed, o.DateUsed.GetTypeCode())); arrParams[7] = new SqlParameter("@PatronId", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PatronId, o.PatronId.GetTypeCode())); arrParams[8] = new SqlParameter("@PCID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PCID, o.PCID.GetTypeCode())); arrParams[8].Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_ProgramCodes_Insert", arrParams); o.PCID = int.Parse(arrParams[8].Value.ToString()); return(o.PCID); }
public static int Delete(ProgramCodes o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@PCID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PCID, o.PCID.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_ProgramCodes_Delete", arrParams); } catch (SqlException ex) { "GRA.SRP.DAL.ProgramCodes".Log().Error("Error in Delete: {0} - {1}", ex.Message, ex.StackTrace); } return(iReturn); }
public bool Fetch(int PCID) { // declare reader SqlDataReader dr; SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@PCID", PCID); dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_ProgramCodes_GetByID", arrParams); if (dr.Read()) { // declare return value ProgramCodes result = new ProgramCodes(); DateTime _datetime; int _int; //decimal _decimal; if (int.TryParse(dr["PCID"].ToString(), out _int)) { this.PCID = _int; } if (int.TryParse(dr["PID"].ToString(), out _int)) { this.PID = _int; } if (int.TryParse(dr["CodeNumber"].ToString(), out _int)) { this.CodeNumber = _int; } this.CodeValue = dr["CodeValue"].ToString(); this.ShortCode = dr["ShortCode"].ToString(); this.isUsed = bool.Parse(dr["isUsed"].ToString()); if (DateTime.TryParse(dr["DateCreated"].ToString(), out _datetime)) { this.DateCreated = _datetime; } if (DateTime.TryParse(dr["DateUsed"].ToString(), out _datetime)) { this.DateUsed = _datetime; } if (int.TryParse(dr["PatronId"].ToString(), out _int)) { this.PatronId = _int; } dr.Close(); return(true); } dr.Close(); return(false); }
public static int Delete(ProgramCodes o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@PCID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PCID, o.PCID.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_ProgramCodes_Delete", arrParams); } catch (SqlException ex) { "GRA.SRP.DAL.ProgramCodes".Log().Error("Error in Delete: {0} - {1}", ex.Message, ex.StackTrace); } return iReturn; }
public static int Update(ProgramCodes o) { int iReturn = -1; //assume the worst SqlParameter[] arrParams = new SqlParameter[9]; arrParams[0] = new SqlParameter("@PCID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PCID, o.PCID.GetTypeCode())); arrParams[1] = new SqlParameter("@PID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PID, o.PID.GetTypeCode())); arrParams[2] = new SqlParameter("@CodeNumber", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.CodeNumber, o.CodeNumber.GetTypeCode())); arrParams[3] = new SqlParameter("@CodeValue", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.CodeValue, o.CodeValue.GetTypeCode())); arrParams[4] = new SqlParameter("@ShortCode", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ShortCode, o.ShortCode.GetTypeCode())); arrParams[5] = new SqlParameter("@isUsed", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.isUsed, o.isUsed.GetTypeCode())); arrParams[6] = new SqlParameter("@DateCreated", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.DateCreated, o.DateCreated.GetTypeCode())); arrParams[7] = new SqlParameter("@DateUsed", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.DateUsed, o.DateUsed.GetTypeCode())); arrParams[8] = new SqlParameter("@PatronId", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PatronId, o.PatronId.GetTypeCode())); try { iReturn = SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_ProgramCodes_Update", arrParams); } catch (SqlException ex) { "GRA.SRP.DAL.ProgramCodes".Log().Error("Error in Update: {0} - {1}", ex.Message, ex.StackTrace); } return iReturn; }
public static int Insert(ProgramCodes o) { SqlParameter[] arrParams = new SqlParameter[9]; arrParams[0] = new SqlParameter("@PID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PID, o.PID.GetTypeCode())); arrParams[1] = new SqlParameter("@CodeNumber", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.CodeNumber, o.CodeNumber.GetTypeCode())); arrParams[2] = new SqlParameter("@CodeValue", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.CodeValue, o.CodeValue.GetTypeCode())); arrParams[3] = new SqlParameter("@ShortCode", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.ShortCode, o.ShortCode.GetTypeCode())); arrParams[4] = new SqlParameter("@isUsed", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.isUsed, o.isUsed.GetTypeCode())); arrParams[5] = new SqlParameter("@DateCreated", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.DateCreated, o.DateCreated.GetTypeCode())); arrParams[6] = new SqlParameter("@DateUsed", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.DateUsed, o.DateUsed.GetTypeCode())); arrParams[7] = new SqlParameter("@PatronId", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PatronId, o.PatronId.GetTypeCode())); arrParams[8] = new SqlParameter("@PCID", GRA.SRP.Core.Utilities.GlobalUtilities.DBSafeValue(o.PCID, o.PCID.GetTypeCode())); arrParams[8].Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, "app_ProgramCodes_Insert", arrParams); o.PCID = int.Parse(arrParams[8].Value.ToString()); return o.PCID; }
public bool Fetch(int PCID) { // declare reader SqlDataReader dr; SqlParameter[] arrParams = new SqlParameter[1]; arrParams[0] = new SqlParameter("@PCID", PCID); dr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "app_ProgramCodes_GetByID", arrParams); if (dr.Read()) { // declare return value ProgramCodes result = new ProgramCodes(); DateTime _datetime; int _int; //decimal _decimal; if (int.TryParse(dr["PCID"].ToString(), out _int)) this.PCID = _int; if (int.TryParse(dr["PID"].ToString(), out _int)) this.PID = _int; if (int.TryParse(dr["CodeNumber"].ToString(), out _int)) this.CodeNumber = _int; this.CodeValue = dr["CodeValue"].ToString(); this.ShortCode = dr["ShortCode"].ToString(); this.isUsed = bool.Parse(dr["isUsed"].ToString()); if (DateTime.TryParse(dr["DateCreated"].ToString(), out _datetime)) this.DateCreated = _datetime; if (DateTime.TryParse(dr["DateUsed"].ToString(), out _datetime)) this.DateUsed = _datetime; if (int.TryParse(dr["PatronId"].ToString(), out _int)) this.PatronId = _int; dr.Close(); return true; } dr.Close(); return false; }