public Invoice(DBInvoice invoice)
        {
            invoiceCustomer = API.CustomerAPI.GetCustomerDetailsByCustomerNumber(invoice.Customer.CustomerNumber);
            companyName = invoice.Company.CompanyName;
            companyABN = invoice.Company.CompanyABN;
            CompanyAddress = string.Format("{0} {1} {2} {3}",
                invoice.Company.CompanyAddress.Address1,
                invoice.Company.CompanyAddress.City,
                invoice.Company.CompanyAddress.State,
                invoice.Company.CompanyAddress.Postcode);
            provider = API.CarrierAPI.GetCarrierById((Enums.CarrierDatabaseKey)invoice.Carrier.carrierId);

            invoiceNo = invoice.InvoiceNumber;
            invoiceDate = invoice.TimeCreated;

            status = (Enums.InvoiceStatus)invoice.InvoiceStatus;
            packed = false;
        }
        public void loadInvoiceDetails()
        {
            if (!String.IsNullOrEmpty(invoiceNo)) {
                Customer temp_customer = new Customer();

                IDataReader reader = API.InvoicesAPI.GetInvoiceDetails(invoiceNo);
                if (reader.Read()) {
                    invoiceCustomer.CustomerNumber = reader["custNo"].ToString();
                    invoiceCustomer.Title = reader["title"].ToString();
                    invoiceCustomer.Firstname = reader["firstName"].ToString();
                    invoiceCustomer.Middlename = reader["middleName"].ToString();
                    invoiceCustomer.Lastname = reader["surName"].ToString();
                    invoiceCustomer.Address1 = reader["address1"].ToString();
                    invoiceCustomer.Address2 = reader["address2"].ToString();
                    invoiceCustomer.City = reader["city"].ToString();
                    invoiceCustomer.State = reader["state"].ToString();
                    invoiceCustomer.Postcode = reader["postcode"].ToString();
                    invoiceCustomer.Country = reader["countryCode"].ToString();
                    invoiceCustomer.PhoneNumber = reader["phoneNumber"].ToString();
                    invoiceCustomer.EmailAddress = reader["emailAddress"].ToString();
                    companyName = reader["companyName"].ToString();
                    companyABN = reader["companyABN"].ToString();
                    if (companyName == "Bright Life Australia") {
                        companyAddress = "PO Box 6521 Brookvale NSW 2100";
                    } else {
                        companyAddress = reader["companyAddress"].ToString();
                    }
                    status = Enums.InvoiceStatus.WAITING;
                    packed = false;
                }
                reader.Close();
            }
        }
        public void loadInvoiceDetails()
        {
            if (!String.IsNullOrEmpty(invoiceNo))
            {
                using (BlauModel _dbcontext = BlauModel.GetContext())
                {
                    DBInvoice invoice = _dbcontext.Invoice.Where(x => x.InvoiceNumber == invoiceNo).FirstOrDefault();
                    if (invoice == default(DBInvoice))
                        throw new InvoiceException(string.Format("Invoice not found for invoiceNo: {0}", invoiceNo));

                    invoiceCustomer = new Customer(invoice.Customer);
                    companyName = invoice.Company.CompanyName;
                    companyABN = invoice.Company.CompanyABN;
                    CompanyAddress = string.Format("{0} {1} {2} {3}",
                        invoice.Company.CompanyAddress.Address1,
                        invoice.Company.CompanyAddress.City,
                        invoice.Company.CompanyAddress.State,
                        invoice.Company.CompanyAddress.Postcode);
                    provider = API.CarrierAPI.GetCarrierById((Enums.CarrierDatabaseKey)invoice.Carrier.carrierId);

                    invoiceNo = invoice.InvoiceNumber;
                    invoiceDate = invoice.TimeCreated;

                    status = (Enums.InvoiceStatus)invoice.InvoiceStatus;
                    packed = false;
                }
            }
        }