Exemple #1
0
        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");
        }
        private void BindItemsList()
        {
            List<Order> orders = new OrderRepo().GetManagementOrders(ToSQL.SQLToInt(txtOrderID.Text), ToSQL.SQLToDateTimeNull(txtFromDate.Text), ToSQL.SQLToDateTimeNull(txtToDate.Text),
                                                                       ToSQL.SQLToInt(ddlOrderStatus.SelectedValue), ToSQL.SQLToInt(ddlCustomer.SelectedValue));
            //_PageDataSource.DataSource = users;
            //_PageDataSource.AllowPaging = true;
            //_PageDataSource.PageSize = 10;
            //_PageDataSource.CurrentPageIndex = CurrentPage;
            //ViewState["TotalPages"] = _PageDataSource.PageCount;

            //this.lblPageInfo.Text = "Results: " + ProductList.Count.ToString() + "&nbsp;&nbsp;&nbsp;&nbsp;Page " + (CurrentPage + 1) + " of " + _PageDataSource.PageCount + "&nbsp;&nbsp;";

            //this.btnPre.Visible = !_PageDataSource.IsFirstPage;
            //this.btnNext.Visible = !_PageDataSource.IsLastPage;
            //this.lbtnFirst.Visible = !_PageDataSource.IsFirstPage;
            //this.lbtnLast.Visible = !_PageDataSource.IsLastPage;

            this.gvOrders.DataSource = orders;
            this.gvOrders.DataBind();
            this.gvOrders.UseAccessibleHeader = true;
            this.gvOrders.HeaderRow.TableSection = TableRowSection.TableHeader;
            //this.doPaging();
        }
        protected void btnRemove_Click(object sender, EventArgs e)
        {
            try
            {
                LinkButton lnk = (LinkButton)sender;
                int Id = ToSQL.SQLToInt(lnk.CommandArgument);
                if (Id > 0)
                {
                    int i = new OrderRepo().DeleteOrder(Id);
                    BindItemsList();
                }
            }
            catch
            {

            }
        }