private void viewCart(int id) { lblPayment.Visible = true; DropDownListPaymentType.Visible = true; GridViewCart.FooterRow.Cells[0].Font.Bold = true; GridViewCart.FooterRow.Cells[0].Text = "Grand Total"; GridViewCart.FooterRow.Cells[6].Font.Bold = true; GridViewCart.FooterRow.Cells[6].Text = ViewCartController.getGrandTotal(id).ToString(); DropDownListPaymentType.DataSource = ViewCartController.getPaymentType().Select(pt => pt.Type).ToList(); DropDownListPaymentType.DataBind(); btnCheckout.Visible = true; }
private void BindPaymentType() { DropDownListPaymentType.DataSource = PaymentType.GetPaymentTypeList(); DropDownListPaymentType.DataTextField = "Description"; DropDownListPaymentType.DataValueField = "PaymentTypeId"; DropDownListPaymentType.DataBind(); if (DropDownListPaymentType.Items.Count > 1) { DropDownListPaymentType.Items.Insert(0, new ListItem("Please select", "0")); } }
protected void Load_Cart() { int userID = getUserID(); List <Model.Cart> cartList = CartController.getCartbyUserId(userID); int totalPrice = 0; int grandTotal = 0; for (int i = 0; i < cartList.Count; i++) { TableRow newRow = new TableRow(); ListCart.Controls.Add(newRow); TableCell numberCell = new TableCell(); numberCell.Controls.Add(new Label() { Text = (i + 1) + "." }); newRow.Cells.Add(numberCell); int productId = cartList.ElementAt(i).ProductID; Product products = ProductController.getProductById(productId); TableCell productIDCell = new TableCell(); productIDCell.Visible = false; productIDCell.Controls.Add(new Label() { Text = productId.ToString() }); newRow.Cells.Add(productIDCell); TableCell productNameCell = new TableCell(); productNameCell.Controls.Add(new Label() { Text = products.ProductName }); newRow.Cells.Add(productNameCell); TableCell productPriceCell = new TableCell(); productPriceCell.Controls.Add(new Label() { Text = "Rp. " + products.Price.ToString() }); newRow.Cells.Add(productPriceCell); TableCell qtyCell = new TableCell(); qtyCell.Controls.Add(new Label() { Text = cartList.ElementAt(i).Quantity.ToString() }); newRow.Cells.Add(qtyCell); totalPrice = (products.Price * cartList.ElementAt(i).Quantity); TableCell totalPriceCell = new TableCell(); totalPriceCell.Controls.Add(new Label() { Text = "Rp. " + totalPrice.ToString() }); newRow.Cells.Add(totalPriceCell); grandTotal = grandTotal + totalPrice; TableCell deleteButtonCell = new TableCell(); Button deleteButton = new Button() { ID = (i + 1) + "_D", Text = "Delete", CssClass = "btn btn-danger" }; deleteButton.Click += deleteButton_Click; deleteButtonCell.Controls.Add(deleteButton); newRow.Cells.Add(deleteButtonCell); } LblGrandTotal.Text = "GRAND TOTAL : Rp. " + grandTotal.ToString(); DropDownListPaymentType.DataSource = CartController.getPaymentType().Select(pt => pt.PaymetTypeName).ToList(); DropDownListPaymentType.DataBind(); }