コード例 #1
0
        /// <summary>
        /// Delete a bill
        /// </summary>
        public void DeleteBill()
        {
            try
            {
                string sql = @"
DELETE FROM 
    Bills 
WHERE 
    BillId = ?";

                // Add query parameters (Dont change the order of parameters)
                database.QueryParameters.Add("@BillId", this.BillId);

                database.DeleteRecord(sql);

                if (this.BillRows.Count > 0)
                {
                    BillRow billRow = new BillRow();
                    billRow.DeleteBillRowsByBillId(this.BillId);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        /// <summary>
        /// Get a bill
        /// </summary>
        public void GetBill()
        {
            try
            {
                string sql = @"
SELECT 
    b.*
FROM 
    Bills b
WHERE 
    b.BillId = ?
ORDER BY 
    b.BillId ASC";

                // Add query parameters (Dont change the order of parameters)
                database.QueryParameters.Add("@BillId", this.BillId);

                // First get bill
                DataTable dt = database.GetDataTable(sql);

                foreach (DataRow dr in dt.Rows)
                {
                    this.BillId          = int.Parse(dr["BillId"].ToString());
                    this.BillNumber      = dr["BillNumber"].ToString();
                    this.DueDate         = DateTime.Parse(dr["DueDate"].ToString());
                    this.BillDate        = DateTime.Parse(dr["BillDate"].ToString());
                    this.IBAN            = dr["IBAN"].ToString();
                    this.BIC             = dr["BIC"].ToString();
                    this.ReferenceNumber = dr["ReferenceNumber"].ToString();
                    this.Reference       = dr["Reference"].ToString();
                    this.CustomerId      = int.Parse(dr["CustomerId"].ToString());
                    this.Created         = DateTime.Parse(dr["Created"].ToString());
                    this.Modified        = DateTime.Parse(dr["Modified"].ToString());
                    this.OverdueRate     = dr["OverdueRate"].ToString();
                }

                // Then get customer
                if (this != null)
                {
                    this.Customer = Customer.GetCustomer(this.CustomerId);
                }

                // Then get billrows
                if (this != null)
                {
                    BillRow billRow = new BillRow();

                    this.BillRows = billRow.GetBillRows(this.BillId);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }