コード例 #1
0
    // creates an invoice from given record
    // adds to list of invoices
    private Invoice_AS3 CreateInvoice(OleDbDataReader _reader)
    {
        // parse info from reader
        int    _number         = (int)_reader["InvoiceNumber"];
        int    _customerID     = (int)_reader["CustNumber"];
        string _dateOrderStr   = (string)_reader["DateOrder"];
        string _dateShippedStr = (string)_reader["DateShipped"];
        string _status         = (string)_reader["Status"];

        // parse date strings
        DateTime _dateOrdered, _dateShipped;

        // formats
        string[] formats = { "dd-MM-yyyy", "d-MM-yyyy", "dd-M-yyyy", "d-M-yyyy" };

        // CultureInfo.InvariantCulture
        if (!DateTime.TryParseExact(_dateOrderStr, formats, null, DateTimeStyles.None, out _dateOrdered))
        {
            Trace.Warn("shop errors", string.Format("Invoice({0}), DateTime Ordered parse failed (\"{1}\")", _number, _dateOrderStr));
            return(null);
        }

        if (!DateTime.TryParseExact(_dateShippedStr, formats, null, DateTimeStyles.None, out _dateShipped))
        {
            Trace.Warn("shop errors", string.Format("Invoice({0}), DateTime Shipped parse failed (\"{1}\")", _number, _dateShippedStr));
            return(null);
        }

        // grab customer
        Customer_AS3 _customer = GetCreateCustomer(_customerID);

        if (_customer == null)
        {
            Trace.Warn("shop errors", string.Format("Invoice({0}), failed to get customer #{1}", _number, _customerID));
            return(null);
        }

        // grab list of items
        List <LineItem_AS3> _items = GetCreateLines(_number);

        if (_items == null)
        {
            Trace.Warn("shop errors", string.Format("Invoice({0}), failed to get lines", _number));
            return(null);
        }

        // build obj, add to list
        Invoice_AS3 _invoice = new Invoice_AS3(_number, _customer, _items, _dateOrdered, _dateShipped, _status);

        invoices.Add(_invoice);

        return(_invoice);
    }
コード例 #2
0
    // adds total line for invoice
    private void AddItemLineTotal(Table _table, Invoice_AS3 _invoice)
    {
        TableRow _row = new TableRow();

        _row.Cells.Add(CreateCell(""));
        _row.Cells.Add(CreateCell(""));
        _row.Cells.Add(CreateCell(""));
        _row.Cells.Add(CreateCell(""));
        _row.Cells.Add(CreateCell(""));
        _row.Cells.Add(CreateCell(""));
        _row.Cells.Add(CreateCell(""));

        _row.Cells.Add(CreateCell(string.Format("{0:c2}", _invoice.TotalCost), COLOR_TABLE_BACK, HorizontalAlign.Right));

        _table.Rows.Add(_row);
    }
コード例 #3
0
    // builds top row for invoice section
    private void AddInvoiceTopRow(Table _table, Invoice_AS3 _invoice)
    {
        TableRow _row = new TableRow();

        Customer_AS3 _customer = _invoice.Customer;

        string _strCustomer = string.Format("Customer #{0} - {1}", _customer.Number, (_customer.Company.Equals("None", StringComparison.OrdinalIgnoreCase)) ? (_customer.Contact) : (_customer.Company));
        string _strOrder    = string.Format("Order #{0}", _invoice.Number);
        string _strStatus   = string.Format("Status: {0}", _invoice.Status);
        string _strOrdered  = string.Format("Ordered: {0}", _invoice.Ordered.ToString("M/d/yyyy HH:mm:ss tt"));

        _row.Cells.Add(CreateCell(_strCustomer, Color.White, HorizontalAlign.Left, BorderStyle.Solid, 2));
        _row.Cells.Add(CreateCell(_strOrder, Color.White, HorizontalAlign.Left, BorderStyle.Solid, 2));
        _row.Cells.Add(CreateCell(_strStatus, Color.White, HorizontalAlign.Left, BorderStyle.Solid, 2));
        _row.Cells.Add(CreateCell(_strOrdered, Color.White, HorizontalAlign.Left, BorderStyle.Solid, 2));

        _table.Rows.Add(_row);
    }
コード例 #4
0
    // adds address rows
    private void AddAddressRows(Table _table, Invoice_AS3 _invoice)
    {
        Address_AS3 _addrBill = _invoice.Customer.AddrBill;
        Address_AS3 _addrShip = _invoice.Customer.AddrShip;

        // Billing
        TableRow _rowBill = new TableRow();

        _rowBill.Cells.Add(CreateCell("Billing: "));
        _rowBill.Cells.Add(CreateCell(string.Format("{0} {1}, {2} {3}", _addrBill.Street, _addrBill.City, _addrBill.State, _addrBill.Zip)));

        // Shipping
        TableRow _rowShip = new TableRow();

        _rowShip.Cells.Add(CreateCell("Shipping: "));
        _rowShip.Cells.Add(CreateCell(string.Format("{0} {1}, {2} {3}", _addrShip.Street, _addrShip.City, _addrShip.State, _addrShip.Zip)));

        _table.Rows.Add(_rowBill);
        _table.Rows.Add(_rowShip);
    }
コード例 #5
0
    // builds section for an invoice
    private void AddInvoiceSection(Table _table, Invoice_AS3 _invoice)
    {
        // build top row
        AddInvoiceTopRow(_table, _invoice);

        // build address rows
        AddAddressRows(_table, _invoice);

        // build items section
        AddItemsTop(_table);

        // add lines
        foreach (LineItem_AS3 _line in _invoice.LineItems)
        {
            AddItemLine(_table, _line);
        }

        // add total
        AddItemLineTotal(_table, _invoice);
    }