|
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using TestableApplication.Testable.Dalc;
namespace TestableApplication.Testable
{
public partial class Invoice : IInvoice
{
private ICustomer _customer;
public ICustomer Customer
{
get { return _customer; }
}
private IInvoiceDalc _invoiceDalc;
public IInvoiceDalc InvoiceDalc
{
get
{
if (_invoiceDalc == null) _invoiceDalc = new InvoiceDalc(this);
return _invoiceDalc;
}
#if DEBUG
set
{
this._invoiceDalc = value;
}
#endif
}
private int _invoiceNumber;
public int InvoiceNumber
{
get { return _invoiceNumber; }
set { _invoiceNumber = value; }
}
DateTime _issueDate;
public DateTime IssueDate
{
get { return _issueDate; }
set { _issueDate = value; }
}
string _description;
public string Description
{
get { return _description; }
}
internal Status _status;
public Status Status
{
get
{
return _status;
}
}
public DateTime DueDate
{
get { return _issueDate.AddMonths(1); }
}
List<InvoiceItem> _items;
public List<InvoiceItem> Items
{
get
{
if (_items == null) _items = new List<InvoiceItem>();
return _items;
}
set { _items = value; }
}
public Invoice(int invoiceNumber, string description, ICustomer customer)
{
this._invoiceNumber = invoiceNumber;
this._description = description;
this._customer = customer;
}
public Invoice(int invoiceNumber, string description, ICustomer customer, DateTime issueDate, Status status, List<InvoiceItem> items)
: this(invoiceNumber, description, customer)
{
this._items = items;
this._issueDate = issueDate;
this._status = status;
}
public Invoice()
{
}
public Invoice IssueInvoice(string description, ICustomer customer, List<InvoiceItem> items)
{
Console.WriteLine("--- IssueInvoice Method was invoked from object {0} ", this);
Console.WriteLine("press enter to continue ....");
Console.ReadLine();
return this.InvoiceDalc.IssueInvoice(description, customer, items);
}
public void PayOffInvoice(ICustomer customer)
{
Console.WriteLine("--- PayOffInvoice Method was invoked from object {0} ", this);
Console.WriteLine("press enter to continue ....");
Console.ReadLine();
this.InvoiceDalc.PayOffInvoice(customer);
}
public Invoice GetInvoice(int invoiceNomber)
{
Console.WriteLine("--- GetInvoice Method was invoked from object {0} ", this);
Console.WriteLine("press enter to continue ....");
Console.ReadLine();
return this.InvoiceDalc.GetInvoice(invoiceNomber);
}
public int ItemsCount
{
get
{
return Items.Count;
}
}
public bool Contains(string itemDescription)
{
foreach (InvoiceItem item in Items)
{
if (string.Compare(item.Description, itemDescription, true) == 0) return true;
}
return false;
}
public decimal TotalAmount
{
get
{
decimal amount = 0;
foreach (InvoiceItem item in Items)
{
amount += item.Quantity * item.Price;
}
return amount;
}
}
public void Update()
{
Console.WriteLine("--- Update Method was invoked from object {0} ", this);
Console.WriteLine("press enter to continue ....");
Console.ReadLine();
this.InvoiceDalc.Update();
}
public override string ToString()
{
return string.Format("{0}-{1}", this.InvoiceNumber, this.Description);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here