protected void ContinueClicked(object sender, ImageClickEventArgs e)
        {
            if (Page.IsValid) {

                // Create a new cartController object
                ProcessFlow.CartController cartController = new ProcessFlow.CartController();

                // Fetch the creditcard info and store it
                string cardType = WebComponents.CleanString.InputText(listCardType.SelectedItem.Text, 10);
                string cardNumber = WebComponents.CleanString.InputText(txtCardNumber.Text, 20);;
                string cardYear = WebComponents.CleanString.InputText(listYear.SelectedItem.Text, 4);;
                string cardMonth = WebComponents.CleanString.InputText(listMonth.SelectedItem.Text, 2);;

                CreditCardInfo creditCard = new CreditCardInfo(cardType, cardNumber, string.Format(FORMAT_EXPIRATION, cardMonth, cardYear));

                cartController.StoreCreditCard(creditCard);

                AddressInfo billingAddress = billAddr.Address;

                // Now store the billing information
                cartController.StoreBillingAddress(billAddr.Address);

                // Continue with the order process
                cartController.ContinueOrder(chkShipBilling.Checked);

                enterAddress.Visible = false;
                confirmAddress.Visible = true;

                staticAddressBilling.ShowAddress(billingAddress);
                staticAddressShipping.ShowAddress(billingAddress);
            }
        }
Exemple #2
0
        /// <summary>
        /// Read an order from the database
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public OrderInfo GetOrder(int orderId)
        {
            //Create a parameter
            SqlParameter parm = new SqlParameter(PARM_ORDER_ID, SqlDbType.Int);
            parm.Value = orderId;

            //Execute a query to read the order
            using (SqlDataReader rdr = SQLHelper.ExecuteReader(SQLHelper.ConnectionString, CommandType.Text, SQL_SELECT_ORDER, parm)) {

                if (rdr.Read()) {

                    //Generate an order header from the first row
                    CreditCardInfo creditCard = new CreditCardInfo(rdr.GetString(2), rdr.GetString(3), rdr.GetString(4));
                    AddressInfo billingAddress = new AddressInfo(rdr.GetString(5), rdr.GetString(6), rdr.GetString(7), rdr.GetString(8), rdr.GetString(9), rdr.GetString(10), rdr.GetString(11), rdr.GetString(12), null);
                    AddressInfo shippingAddress = new AddressInfo(rdr.GetString(13), rdr.GetString(14), rdr.GetString(15), rdr.GetString(16), rdr.GetString(17), rdr.GetString(18), rdr.GetString(19), rdr.GetString(20), null);

                    OrderInfo order = new OrderInfo(orderId, rdr.GetDateTime(0), rdr.GetString(1), creditCard, billingAddress, shippingAddress, rdr.GetDecimal(21));

                    ArrayList lineItems = new ArrayList();
                    LineItemInfo item = null;

                    //Create the lineitems from the first row and subsequent rows
                    do{
                        item = new LineItemInfo(rdr.GetString(22), string.Empty, rdr.GetInt32(23), rdr.GetInt32(24), rdr.GetDecimal(25));
                        lineItems.Add(item);
                    }while(rdr.Read());

                    order.LineItems = (LineItemInfo[])lineItems.ToArray(typeof(LineItemInfo));

                    return order;
                }
            }

            return null;
        }
Exemple #3
0
 /// <summary>
 /// Constructor with specified initial values
 /// </summary>
 /// <param name="orderId">Unique identifier</param>
 /// <param name="date">Order date</param>
 /// <param name="userId">User placing order</param>
 /// <param name="creditCard">Credit card used for order</param>
 /// <param name="billing">Billing address for the order</param>
 /// <param name="shipping">Shipping address for the order</param>
 /// <param name="total">Order total value</param>
 public OrderInfo(int orderId, DateTime date, string userId, CreditCardInfo creditCard, AddressInfo billing, AddressInfo shipping, decimal total)
 {
     this._orderId = orderId;
     this._date = date;
     this._userId = userId;
     this._creditCard = creditCard;
     this._billingAddress = billing;
     this._shippingAddress = shipping;
     this._orderTotal = total;
 }
Exemple #4
0
 /// <summary>
 /// Constructor with specified initial values
 /// </summary>
 /// <param name="orderId">Unique identifier</param>
 /// <param name="date">Order date</param>
 /// <param name="userId">User placing order</param>
 /// <param name="creditCard">Credit card used for order</param>
 /// <param name="billing">Billing address for the order</param>
 /// <param name="shipping">Shipping address for the order</param>
 /// <param name="total">Order total value</param>
 /// <param name="line">Ordered items</param>
 /// <param name="authorization">Credit card authorization number</param>
 public OrderInfo(int orderId, DateTime date, string userId, CreditCardInfo creditCard, AddressInfo billing, AddressInfo shipping, decimal total, LineItemInfo[] line, Nullable<int> authorization)
 {
     this.orderId = orderId;
     this.date = date;
     this.userId = userId;
     this.creditCard = creditCard;
     this.billingAddress = billing;
     this.shippingAddress = shipping;
     this.orderTotal = total;
     this.lineItems = line;
     this.authorizationNumber = authorization;
 }
 /// <summary>
 /// A method to store credit card state information
 /// </summary>
 public void StoreCreditCard(CreditCardInfo creditCard)
 {
     HttpContext.Current.Session[CREDITCARD_KEY] = creditCard;
 }