コード例 #1
0
ファイル: Payment.aspx.cs プロジェクト: htphongqn/B2C_EC
        protected void btnOrder_Click(object sender, EventArgs e)
        {
            Order order = new Order();
            order.DateCreated = DateTime.Now;
            order.Note = ToSQL.EmptyNull(txtNotes.Text);
            order.OrderStatus_ID = 1;
            if (Session["Customer"] != null)
            {
                order.Customer_ID = ((Customer)Session["Customer"]).ID;
            }
            order.ShippingAddress = new ShippingAddress()
            {
                Name = ToSQL.EmptyNull(txtFullName.Text),
                Email = ToSQL.EmptyNull(txtEmail.Text),
                Phone = ToSQL.EmptyNull(txtPhone.Text),
                Address = new Address()
                {
                    Street1 = ToSQL.EmptyNull(txtStreet.Text),
                    City = ToSQL.EmptyNull(txtCity.Text),
                    State = ToSQL.EmptyNull(txtState.Text),
                    Country = ToSQL.EmptyNull(txtCountry.Text),
                    ZipCode = ToSQL.EmptyNull(txtZipCode.Text),
                }
            };
            order.Payment_ID = tabContainer.ActiveTabIndex + 1;
            List<Cart> carts = (List<Cart>)Session["Carts"];
            List<OrderDetail> orderDetails = new List<OrderDetail>();
            foreach (var item in carts)
            {
                OrderDetail orderDetail = new OrderDetail()
                {
                    Product_ID = item.ProductID,
                    Quantity = item.Quantity,
                    Price = item.Price
                };
                orderDetails.Add(orderDetail);
            }
            order.OrderDetails = orderDetails;
            int i = new OrderRepo().CreateOrder(order);
            OrderHistory orderHis = new OrderHistory();
            orderHis.Order_ID = order.ID;
            orderHis.OrderStatus_ID = Const.Pendding;
            orderHis.DateCreated = DateTime.Now;
            int x = new OrderHistoryRepo().CreateOrderHistory(orderHis);

            Session["Order"] = order;
            Session["Subtotal"] = lbTotalPrice.Text;
            Session["Carts"] = null;
            Response.Redirect("OrderComplete.aspx");
        }
コード例 #2
0
 private void ChangeOrderStatus(int orderStatusID)
 {
     int orderID = ToSQL.SQLToInt(Request.QueryString["ID"]);
     int i = orderRepo.UpdateStatus(orderID, orderStatusID);
     OrderHistory orderHis = new OrderHistory();
     orderHis.Order_ID = orderID;
     orderHis.OrderStatus_ID = orderStatusID;
     orderHis.DateCreated = DateTime.Now;
     int x = new OrderHistoryRepo().CreateOrderHistory(orderHis);
     Response.Redirect("~/Admincp/Management-Order.aspx");
 }