/// <summary> /// The Remove method is used to delete a record from the corresponding database table. It receives /// the primary key, and will use the generic helper method of the DataSQL class to remove the record. /// </summary> /// <param name="id">The primary key.</param> /// <returns>A boolean indicating whether the record was removed.</returns> public static Boolean Remove(int id) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@CardID", id); return(DataSQL <CreditCard> .NonQuery(SQL_DELETE, parameters) > 0); }
/// <summary> /// The Update method is used to update the record within the database table to the instance /// data of the received object. The AddParameters method is used to covert the instance data /// into a passable dictionary of data, which is then passed to the generic helper method of /// the DataSQL class along with the statement. The ID is also added at the end of the dictionary, /// since it is the last variable (within the where clause) of the update statement. /// </summary> /// <param name="customer">The customer object.</param> /// <returns>A int indicating the rows affected.</returns> public static int Update(Transaction transaction) { Dictionary <string, object> parameters = AddParameters(transaction); parameters.Add("@TransactionID", transaction.transactionID); return(DataSQL <Transaction> .NonQuery(SQL_UPDATE, parameters)); }
/// <summary> /// The Update method is used to update the record within the database table to the instance /// data of the received object. The AddParameters method is used to covert the instance data /// into a passable dictionary of data, which is then passed to the generic helper method of /// the DataSQL class along with the statement. The ID is also added at the end of the dictionary, /// since it is the last variable (within the where clause) of the update statement. /// </summary> /// <param name="dvd">The dvd object.</param> /// <returns>A int indicating the rows affected.</returns> public static int Update(DVD dvd) { Dictionary <string, object> parameters = AddParameters(dvd); parameters.Add("@dvdID", dvd.dvdID); return(DataSQL <DVD> .NonQuery(SQL_UPDATE, parameters)); }
/// <summary> /// The Clear method is used to delete all record from the corresponding database table. It receives /// the primary key of the transaction, and will use the generic helper method of the DataSQL class to remove all the child records. /// </summary> /// <param name="id">The transaction primary key.</param> public static void Clear(int id) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@TransactionID", id); DataSQL <TransactionItem> .NonQuery(SQL_DELETE, parameters); }
/// <summary> /// The UpdateCopies method is used to update the status of all the DVDCopies that /// were added to a transaction. It uses the generic helper method of the DataSQL class /// to execute the query. /// </summary> /// <param name="transactionID">The transactionID of the.</param> /// <returns>A boolean indicating whether the record was updated.</returns> public static int UpdateCopies(int transactionID, DVDCopy.Status status) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@Status", (int)status); parameters.Add("@TransactionID", transactionID); return(DataSQL <DVDCopy> .NonQuery(SQL_UPDATE, parameters)); }
/// <summary> /// The Update method is used to update the record within the database table to the instance /// data of the received object. It then coverts the instance data /// into a passable dictionary of data, which is then passed to the generic helper method of /// the DataSQL class along with the statement. The ID is also added at the end of the dictionary, /// since it is the last variable (within the where clause) of the update statement. /// </summary> /// <param name="card">The credit card object.</param> /// <returns>A int indicating the rows affected.</returns> public static int Update(CreditCard card) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@CardHolder", card.cardName); parameters.Add("@CardNumber", card.cardNumber); parameters.Add("@CardID", card.cardID); return(DataSQL <CreditCard> .NonQuery(SQL_UPDATE, parameters)); }
/// <summary> /// The Add method is used to insert the received object into the corresponding database table. /// It coverts the object attributes into a dictionary, which is then passed /// into the DataSQL helper method along with the insert sql statement. /// </summary> /// <param name="card">The credit card object.</param> /// <returns>The rows affected.</returns> public static int Add(CreditCard card) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@CustomerID", card.customerID); parameters.Add("@CardHolder", card.cardName); parameters.Add("@CardNumber", card.cardNumber); return(DataSQL <CreditCard> .NonQuery(SQL_INSERT, parameters)); }
/// <summary> /// The Update method is used to update the record within the database table to the instance /// data of the received object. It then coverts the instance data /// into a passable dictionary of data, which is then passed to the generic helper method of /// the DataSQL class along with the statement. The ID is also added at the end of the dictionary, /// since it is the last variable (within the where clause) of the update statement. /// </summary> /// <param name="copy">The dvd copy object.</param> /// <returns>A boolean indicating whether the record was updated.</returns> public static Boolean Update(DVDCopy copy) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@Barcode", copy.barcode); parameters.Add("@Status", (int)copy.status); parameters.Add("@copyID", copy.copyID); return(DataSQL <DVDCopy> .NonQuery(SQL_UPDATE, parameters) > 0); }
/// <summary> /// The Add method is used to insert the received object into the corresponding database table. /// It coverts the object attributes into a dictionary, which is then passed /// into the DataSQL helper method along with the insert sql statement. /// </summary> /// <param name="copy">The dvd copy object.</param> /// <returns>A boolean indicating whether the record was inserted.</returns> public static Boolean Add(DVDCopy copy) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@dvdID", copy.dvdID); parameters.Add("@Barcode", copy.barcode); parameters.Add("@Status", (int)copy.status); return(DataSQL <DVDCopy> .NonQuery(SQL_INSERT, parameters) > 0); }
/// <summary> /// The Add method is used to insert the received object into the corresponding database table. /// It coverts the object attributes into a dictionary, which is then passed /// into the DataSQL helper method along with the insert sql statement. /// </summary> /// <param name="copy">The transaction item object.</param> public static void Add(TransactionItem item) { Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@TransactionID", item.transactionID); parameters.Add("@CopyID", item.copyID); parameters.Add("@Type", (int)item.type); DataSQL <TransactionItem> .NonQuery(SQL_INSERT, parameters); }
/// <summary> /// The Update method is used to update the record within the database table to the instance /// data of the received object. The AddParameters method is used to covert the instance data /// into a passable dictionary of data, which is then passed to the generic helper method of /// the DataSQL class along with the statement. The ID is also added at the end of the dictionary, /// since it is the last variable (within the where clause) of the update statement. /// </summary> /// <param name="customer">The customer object.</param> /// <returns>A int indicating the rows affected.</returns> public static int Update(Customer customer) { // Converts the instance data to a dictionary which matches the variables in the sql statement. Dictionary <string, object> parameters = AddParameters(customer); // Adds the primary key to the end, which is for the where clause. parameters.Add("@CustomerID", customer.customerID); // Passes both the SQL statement, and the parameters as arguments to the generic NonQuery // helper method. It will return a int of the rows affected by the change. return(DataSQL <Customer> .NonQuery(SQL_UPDATE, parameters)); }
/// <summary> /// The Remove method is used to delete a record from the corresponding database table. It receives /// the primary key, and will use the generic helper method of the DataSQL class to remove the record. /// </summary> /// <param name="id">The primary key.</param> /// <returns>A boolean indicating whether the record was removed.</returns> public static Boolean Remove(int id) { // Instantiates a new dictionary to add the parameters. Dictionary <string, object> parameters = new Dictionary <string, object>(); // Adds the primary key as a parameter. parameters.Add("@CustomerID", id); // Invokes the generic NonQuery method passing the sql statement, and the paramaters as arguments. // Returns a boolean indicating success. return(DataSQL <Customer> .NonQuery(SQL_DELETE, parameters) > 0); }