/// <summary> /// Update an entry in the PrintOptionSet table /// </summary> public static bool Update(PrintOptionSet printOptionSet) { bool result = false; SqlConnection cn = GetConnection(); result = Update(cn, printOptionSet); FinishedWithConnection(cn); return(result); }
/// <summary> /// Get an entry from the PrintOptionSet table /// </summary> public static PrintOptionSet Get(int id) { PrintOptionSet result = null; SqlConnection cn = GetConnection(); result = Get(cn, id); FinishedWithConnection(cn); return(result); }
private static bool Update(SqlConnection cn, PrintOptionSet printOptionSet) { Int32 rowsAffected = 0; using (SqlCommand sqlCmd = cn.CreateCommand()) { sqlCmd.CommandText = "UPDATE PrintOptionSet SET PrintOptionSetName=@PrintOptionSetName WHERE PrintOptionSetId=@PrintOptionSetId"; BuildSqlParameter(sqlCmd, "@PrintOptionSetId", SqlDbType.Int, printOptionSet.Id); BuildSqlParameter(sqlCmd, "@PrintOptionSetDescription", SqlDbType.Text, printOptionSet.OptionSetName); rowsAffected = sqlCmd.ExecuteNonQuery(); } return(rowsAffected != 0); }
private static PrintOptionSet Get(SqlConnection cn, int id) { PrintOptionSet result = null; using (SqlCommand cmd = new SqlCommand("SELECT * FROM PrintOptionSet WHERE PrintOptionSetId=" + id, cn)) { using (SqlDataReader rdr = cmd.ExecuteReader()) { if (rdr.Read()) { result = BuildPrintOptionSet(rdr); } } } return(result); }
/// <summary> /// Delete an entry from the PrintOptionSet table /// </summary> public static bool Delete(int id) { Int32 rowsAffected = 0; SqlConnection cn = GetConnection(); PrintOptionSet printOptionSet = Get(cn, id); if (printOptionSet != null) { using (SqlCommand sqlCmd = cn.CreateCommand()) { sqlCmd.CommandText = "DELETE FROM PrintOptionSet WHERE PrintOptionSetId=" + id; rowsAffected = sqlCmd.ExecuteNonQuery(); } } FinishedWithConnection(cn); return(rowsAffected != 0); }
/// <summary> /// Add a new entry to the PrintOptionSet table /// </summary> public static PrintOptionSet Add(string description, double cost) { PrintOptionSet result = null; DateTime purchaseTime = DateTime.Now; SqlConnection cn = GetConnection(); string cmd = "AddPrintOptionSet"; using (SqlCommand sqlCmd = new SqlCommand(cmd, cn)) { sqlCmd.CommandType = CommandType.StoredProcedure; BuildSqlParameter(sqlCmd, "@PrintOptionSetDescription", SqlDbType.Text, description); BuildSqlParameter(sqlCmd, "@PrintOptionSetId", SqlDbType.Int, ParameterDirection.ReturnValue); if (sqlCmd.ExecuteNonQuery() > 0) { result = new PrintOptionSet(Convert.ToInt32(sqlCmd.Parameters["@PrintOptionSetId"].Value), description); } } FinishedWithConnection(cn); return(result); }
public bool Update() { return(PrintOptionSet.Update(this)); }