Exemple #1
0
    // grab address w/ ID from DB
    // build obj
    private Address_AS3 CreateAddress(int _id)
    {
        // build command, get reader
        string          _query  = string.Format("SELECT * FROM Address WHERE (AddressID = {0});", _id);
        OleDbCommand    _cmd    = new OleDbCommand(_query, connection);
        OleDbDataReader _reader = _cmd.ExecuteReader();

        if (!_reader.Read())
        {
            Trace.Warn("shop errors", string.Format("Address, failed to find record with id={0}", _id));
            return(null);
        }

        // parse information
        int    _addrID = (int)_reader["AddressID"];
        string _street = (string)_reader["Street"];
        string _city   = (string)_reader["City"];
        string _state  = (string)_reader["State"];
        string _zip    = (string)_reader["Zip"];

        // create, add to cache
        Address_AS3 _address = new Address_AS3(_addrID, _street, _city, _state, _zip);

        addresses.Add(_address);

        return(_address);
    }
Exemple #2
0
 // Constructor
 public Customer_AS3(int _number, Address_AS3 _ship, Address_AS3 _bill, string _company, string _contact, string _phone)
 {
     Number   = _number;
     AddrShip = _ship;
     AddrBill = _bill;
     Company  = _company;
     Contact  = _contact;
     Phone    = _phone;
 }
Exemple #3
0
    // gets customer from DB, creates object
    // uses given ID
    private Customer_AS3 CreateCustomer(int _id)
    {
        // build command, get reader
        string          _query  = string.Format("SELECT * FROM Customer WHERE (CustNumber = {0});", _id);
        OleDbCommand    _cmd    = new OleDbCommand(_query, connection);
        OleDbDataReader _reader = _cmd.ExecuteReader();

        if (!_reader.Read())
        {
            Trace.Warn("shop errors", string.Format("Customer, failed to find record with id={0}", _id));
            return(null);
        }

        // parse information
        int    _number     = (int)_reader["CustNumber"];
        int    _addrShipID = (int)_reader["AddrShip"];
        int    _addrBillID = (int)_reader["AddrBill"];
        string _company    = (string)_reader["Company"];
        string _contact    = (string)_reader["Contact"];
        string _phone      = (string)_reader["Phone"];

        // get addresses
        Address_AS3 _addrShip = GetCreateAddress(_addrShipID);

        if (_addrShip == null)
        {
            Trace.Warn("shop errors", string.Format("Customer({0}), failed to parse shipping address ({1})", _id, _addrShipID));
            return(null);
        }

        Address_AS3 _addrBill = GetCreateAddress(_addrBillID);

        if (_addrBill == null)
        {
            Trace.Warn("shop errors", string.Format("Customer({0}), failed to parse billing address ({1})", _id, _addrBillID));
            return(null);
        }

        // build object, add to list
        Customer_AS3 _customer = new Customer_AS3(_number, _addrShip, _addrBill, _company, _contact, _phone);

        customers.Add(_customer);

        return(_customer);
    }
Exemple #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);
    }