Example #1
0
        public static void InsertReceipt(Receipt receipt)
        {
            IDbCommand command = null;
            try
            {
                command = DbActions.GetCommand();

                string data = string.Format("'{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}'", receipt.Id, receipt.Name, receipt.Date, receipt.Tip, receipt.Total, receipt.Payer, receipt.RentId);
                command.CommandText = string.Format(DbActions.InsertStatement, Receipt.TableName, Receipt.Columns, data);

                command.CommandType = CommandType.Text;

                command.ExecuteNonQuery();

            }
            finally
            {
                DbActions.DisposeCommand(command);
            }
        }
Example #2
0
 public InvalidTotalException(Receipt exp, decimal total)
     : base(string.Format("Invalid Total, Receipt: {0}, Expected: {1}, Was {2}", exp.Name, exp.Total, total))
 {
 }
Example #3
0
 public InvalidTipException(Receipt exp, decimal tip)
     : base(string.Format("Invalid Tip, Receipt: {0}, Expected: {1}, Was {2}", exp.Name, exp.Tip, tip))
 {
 }
Example #4
0
 public InvalidTaxException(Receipt exp, decimal tax)
     : base(string.Format("Invalid Tax, Receipt: {0}, Expected: {1}, Was {2}", exp.Name, exp.Tax, tax))
 {
 }
Example #5
0
        public static void UpdateReceipt(Receipt receipt)
        {
            IDbCommand command = null;
            try
            {
                command = DbActions.GetCommand();

                string data = string.Format("Name='{0}', Date='{1}', Tip='{2}', Total='{3}', Payer='{4}', RentId='{5}'", receipt.Name, receipt.Date, receipt.Tip, receipt.Total, receipt.Payer, receipt.RentId);
                command.CommandText = string.Format(DbActions.UpdateStatement, Receipt.TableName, data, Receipt.IdColumn, "'" + receipt.Id + "'");

                command.CommandType = CommandType.Text;

                command.ExecuteNonQuery();

            }
            finally
            {
                DbActions.DisposeCommand(command);
            }
        }