コード例 #1
0
        /// <summary>
        /// The Fetch method will find the record in the database, and return a newly instantiated object containing
        /// the record data. It uses the generic DataSQL Fetch method to dynamically instantiate the object using Reflection,
        /// which will return the instance.
        /// </summary>
        /// <param name="id">The primary key of the object desired to find.</param>
        /// <returns>The instance object.</returns>
        public static Transaction Fetch(int id)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@TransactionID", id);
            return(DataSQL <Transaction> .Fetch(SQL_FETCH, parameters));
        }
コード例 #2
0
 /// <summary>
 /// The Add method is used to insert the received object into the corresponding database table. It uses the
 /// AddParameters method to covert the object attributes into a dictionary, which is then passed
 /// into the DataSQL helper method along with the insert sql statement.
 /// </summary>
 /// <param name="customer">The customer object.</param>
 /// <returns>The inserted record's primary key.</returns>
 public static int Add(Customer customer)
 {
     // Converts the instance data to a dictionary, and passes both the sql statement & the dictionary
     // as arguments to the generic ScalarQuery helper method. It will return a int being the newly inserted
     // primary key.
     return(DataSQL <Customer> .ScalarQuery(SQL_INSERT, AddParameters(customer)));
 }
コード例 #3
0
        /// <summary>
        /// The List method is used to fetch all objects within the corresponding database table. It uses
        /// the generic List method of the DataSQL class to fetch the instances. It uses Reflection to dynamically
        /// instantiate the object based on the generic type.
        /// </summary>
        /// <param name="id">The Customer primary key.</param>
        /// <returns>Returns a List of the transactions relating to a Customer.</returns>
        public static List <Transaction> List(int customerID)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@CustomerID", customerID);
            return(DataSQL <Transaction> .List(SQL_LIST_CUSTOMER, parameters));
        }
コード例 #4
0
ファイル: DataDVD.cs プロジェクト: izuc/dvd_rental_system
        /// <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));
        }
コード例 #5
0
ファイル: DataDVDCopy.cs プロジェクト: izuc/dvd_rental_system
        /// <summary>
        /// The List method is used to fetch all objects within the corresponding database table. It uses
        /// the generic List method of the DataSQL class to fetch the instances. It uses Reflection to dynamically
        /// instantiate the object based on the generic type.
        /// </summary>
        /// <param name="id">The DVD primary key.</param>
        /// <returns>Returns a List of the DVD Copies.</returns>
        public static List <DVDCopy> List(int dvdID)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@dvdID", dvdID);
            return(DataSQL <DVDCopy> .List(SQL_LIST, parameters));
        }
コード例 #6
0
        /// <summary>
        /// The Fetch method will find the record in the database, and return a newly instantiated object containing
        /// the record data. It uses the generic DataSQL Fetch method to dynamically instantiate the object using Reflection,
        /// which will return the instance.
        /// </summary>
        /// <param name="id">The primary key of the object desired to find.</param>
        /// <returns>The instance object.</returns>
        public static CreditCard Fetch(int id)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@CardID", id);
            return(DataSQL <CreditCard> .Fetch(SQL_FETCH, parameters));
        }
コード例 #7
0
ファイル: DataDVD.cs プロジェクト: izuc/dvd_rental_system
        /// <summary>
        /// The Fetch method will find the record in the database, and return a newly instantiated object containing
        /// the record data. It uses the generic DataSQL Fetch method to dynamically instantiate the object using Reflection,
        /// which will return the instance.
        /// </summary>
        /// <param name="id">The primary key of the object desired to find.</param>
        /// <returns>The instance object.</returns>
        public static DVD Fetch(int id)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@dvdID", id);
            return(DataSQL <DVD> .Fetch(SQL_FETCH, parameters));
        }
コード例 #8
0
        /// <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);
        }
コード例 #9
0
        /// <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);
        }
コード例 #10
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));
        }
コード例 #11
0
        /// <summary>
        /// The List method is used to fetch all objects within the corresponding database table. It uses
        /// the generic List method of the DataSQL class to fetch the instances. It uses Reflection to dynamically
        /// instantiate the object based on the generic type.
        /// </summary>
        /// <param name="id">The Customer primary key.</param>
        /// <returns>Returns a List of the Credit Cards.</returns>
        public static List <CreditCard> List(int customerID)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@CustomerID", customerID);
            return(DataSQL <CreditCard> .List(SQL_LIST, parameters));
        }
コード例 #12
0
        /// <summary>
        /// The Fetch method will find the record in the database, and return a newly instantiated object containing
        /// the record data. It uses the generic DataSQL Fetch method to dynamically instantiate the object using Reflection,
        /// which will return the instance.
        /// </summary>
        /// <param name="transactionID">The Transaction primary key.</param>
        /// /// <param name="copyID">The DVD Copy primary key.</param>
        /// <returns>The instance object.</returns>
        public static TransactionItem Fetch(int transactionID, int copyID)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@TransactionID", transactionID);
            parameters.Add("@CopyID", copyID);
            return(DataSQL <TransactionItem> .Fetch(SQL_FETCH, parameters));
        }
コード例 #13
0
        /// <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));
        }
コード例 #14
0
        /// <summary>
        /// The Count method is used to count the amount of transaction items that have been
        /// added to a specific transaction based on the transaction type (either being rental or sale).
        /// </summary>
        /// <param name="transactionID">The transaction's primary key.</param>
        /// <param name="TransactionType">The transaction type.</param>
        /// <returns>The count of items relating to a transaction & type.</returns>
        public static int Count(int transactionID, TransactionItem.TransactionType type)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@TransactionID", transactionID);
            parameters.Add("@Type", (int)type);
            return(DataSQL <Transaction> .ScalarQuery(SQL_COUNT, parameters));
        }
コード例 #15
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);
        }
コード例 #16
0
        /// <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));
        }
コード例 #17
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="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));
        }
コード例 #18
0
ファイル: DataDVDCopy.cs プロジェクト: izuc/dvd_rental_system
        /// <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);
        }
コード例 #19
0
ファイル: DataDVDCopy.cs プロジェクト: izuc/dvd_rental_system
        /// <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);
        }
コード例 #20
0
        /// <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);
        }
コード例 #21
0
        /// <summary>
        /// The Fetch method will find the record in the database, and return a newly instantiated object containing
        /// the record data. It uses the generic DataSQL Fetch method to dynamically instantiate the object using Reflection,
        /// which will return the instance.
        /// </summary>
        /// <param name="id">The primary key of the object desired to find.</param>
        /// <returns>The instance object.</returns>
        public static Customer Fetch(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 Fetch method passing the sql statement, and the paramaters as arguments.
            // Returns the object instance.
            return(DataSQL <Customer> .Fetch(SQL_FETCH, parameters));
        }
コード例 #22
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(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));
        }
コード例 #23
0
        /// <summary>
        /// The List method is used to fetch all objects within the corresponding database table. It uses
        /// the generic List method of the DataSQL class to fetch the instances. It uses Reflection to dynamically
        /// instantiate the object based on the generic type. It doesn't however return a List of TransactionItem,
        /// instead it will return the DVDCopy objects relating to the Item.
        /// </summary>
        /// <param name="transactionID">The Transaction primary key.</param>
        /// <param name="TransactionType">The Transaction Type.</param>
        /// <returns>Returns a List of the DVD Copies.</returns>
        public static List <DVDCopy> List(int transactionID, TransactionItem.TransactionType type)
        {
            // Instantiates a empty list of DVDCopy.
            List <DVDCopy> list = new List <DVDCopy>();
            // Prepares and adds the paramaters to the dictionary.
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@TransactionID", transactionID);
            parameters.Add("@Type", (int)type);
            // Executes the query through the helper, then iterates the resulting TransactionItems.
            foreach (TransactionItem item in DataSQL <TransactionItem> .List(SQL_LIST, parameters))
            {
                // Adds each item's relating DVDCopy instance to the DVD Copy list.
                list.Add(item.copy);
            }
            return(list); // Returns the List.
        }
コード例 #24
0
ファイル: DataDVD.cs プロジェクト: izuc/dvd_rental_system
 /// <summary>
 /// The Add method is used to insert the received object into the corresponding database table. It uses the
 /// AddParameters method to covert the object attributes into a dictionary, which is then passed
 /// into the DataSQL helper method along with the insert sql statement.
 /// </summary>
 /// <param name="dvd">The dvd object.</param>
 /// <returns>The inserted record's primary key.</returns>
 public static int Add(DVD dvd)
 {
     return(DataSQL <DVD> .ScalarQuery(SQL_INSERT, AddParameters(dvd)));
 }
コード例 #25
0
ファイル: DataDVD.cs プロジェクト: izuc/dvd_rental_system
 /// <summary>
 /// The List method is used to fetch all objects within the corresponding database table. It uses
 /// the generic List method of the DataSQL class to fetch the instances. It uses Reflection to dynamically
 /// instantiate the object based on the generic type.
 /// </summary>
 /// <returns>Returns a List of the objects.</returns>
 public static List <DVD> List()
 {
     return(DataSQL <DVD> .List(SQL_LIST, null));
 }
コード例 #26
0
 /// <summary>
 /// The List method is used to fetch all objects within the corresponding database table. It uses
 /// the generic List method of the DataSQL class to fetch the instances. It uses Reflection to dynamically
 /// instantiate the object based on the generic type.
 /// </summary>
 /// <returns>Returns a List of the objects.</returns>
 public static List <Transaction> List()
 {
     return(DataSQL <Transaction> .List(SQL_LIST, null));
 }
コード例 #27
0
 /// <summary>
 /// The List method is used to fetch all objects within the corresponding database table. It uses
 /// the generic List method of the DataSQL class to fetch the instances. It uses Reflection to dynamically
 /// instantiate the object based on the generic type.
 /// </summary>
 /// <returns>Returns a List of the objects.</returns>
 public static List <Customer> List()
 {
     return(DataSQL <Customer> .List(SQL_LIST, null));
 }
コード例 #28
0
 /// <summary>
 /// The Add method is used to insert the received object into the corresponding database table. It uses the
 /// AddParameters method to covert the object attributes into a dictionary, which is then passed
 /// into the DataSQL helper method along with the insert sql statement.
 /// </summary>
 /// <param name="transaction">The transaction object.</param>
 /// <returns>The inserted record's primary key.</returns>
 public static int Add(Transaction transaction)
 {
     return(DataSQL <Transaction> .ScalarQuery(SQL_INSERT, AddParameters(transaction)));
 }