protected void Page_Load(object sender, EventArgs e) { OrderTier theTier = new OrderTier(); List <Orders> orders = (List <Orders>)Session["Pending"]; orders = theTier.getPendingOrders(); if (orders == null) { lblOrd.Text = "No items to display."; } else { lblOrd.Text = " "; Table theTable = null; foreach (Orders order in orders) { orderno = order.order_no; qty = order.qty_ordered; } ItemTier aTier = new ItemTier(); List <Item> items = aTier.getIncomingItems(); foreach (Item item in items) { theTable = getItemTable(item); pnlOut.Controls.Add(theTable); } } }
protected void detailsClick(object sender, EventArgs e) { Button theButton = (Button)sender; OrderTier theTier = new OrderTier(); string id = theButton.ID.Remove(theButton.ID.IndexOf('b'), 1); int orderID = int.Parse(id); Session["OrderID"] = orderID; Response.Redirect("/Admin/OrderDetails.aspx"); }
protected void deleteClick(object sender, EventArgs e) { Button theButton = (Button)sender; OrderTier theTier = new OrderTier(); OrderDetailTier theDetailTier = new OrderDetailTier(); int orderID = int.Parse(theButton.ID); theTier.deleteOrder(orderID); theDetailTier.deleteFullOrder(orderID); Response.Redirect("/Admin/OrderInfo.aspx"); }
protected void submitClick(object sender, EventArgs e) { if (txtCustID.Text != null) { Cart theCart = (Cart)Session["theCart"]; OrderTier theOrderTier = new OrderTier(); OrderDetailTier theDetailTier = new OrderDetailTier(); OrderDetail theDetail; Order theOrder = new Order(); if (txtCustID.Text != null) { theOrder.custID = int.Parse(txtCustID.Text); } theOrder.cartID = theCart.cartID; theOrder.total = (double)Session["total"]; theOrder.dateOfSale = DateTime.Now; theOrder.taxRate = 8.625; if (txtDiscount.Text != null) { theOrder.discount = double.Parse(txtDiscount.Text); } bool success = false; if (theOrderTier.insertOrder(theOrder)) { theOrder = theOrderTier.getLastOrder(); foreach (Product item in theCart.products) { theDetail = new OrderDetail(); theDetail.orderID = theOrder.orderID; theDetail.prodID = item.prodID; theDetail.quantitySold = int.Parse(theCart.quantities[theCart.products.IndexOf(item)].ToString()); if (theDetailTier.insertOrderDetail(theDetail)) { success = true; } } } else { success = false; } if (success) { Response.Redirect("/SuccessfulSubmission.aspx"); Session["theCart"] = null; } else { Response.Redirect("/FailedSubmission.aspx"); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { OrderTier theTier = new OrderTier(); Order theOrder = (Order)Session["theOrder"]; if (theTier.insertOrder(theOrder)) { Response.Redirect("/SuccessfulSubmission.aspx"); } else { Response.Redirect("/FailedSubmission.aspx"); } }
protected void btnSubmit_Click(object sender, EventArgs e) { OrderTier theTier = new OrderTier(); Order theOrder = new Order(); theOrder.custID = int.Parse(txtCustID.Text); theOrder.cartID = Guid.Parse(txtCartID.Text); theOrder.total = double.Parse(txtTotal.Text); if (calDateOfSale.SelectedDate != null) { theOrder.dateOfSale = calDateOfSale.SelectedDate; } theOrder.taxRate = double.Parse(txtTaxRate.Text); theOrder.discount = double.Parse(txtDiscount.Text); Session["theOrder"] = theOrder; Response.Redirect("/Admin/OrderConfirmation.aspx"); }
protected void recClick(Object Sender, EventArgs e) { Button theButton = (Button)Sender; int id = int.Parse(theButton.ID); ItemTier tier = new ItemTier(); Item item = tier.getItemByID(id); ItemTier itemTier = new ItemTier(); itemTier.itemRec(id, qty); OrderTier ordTier = new OrderTier(); ordTier.orderRec(orderno); Session["OrderInfo"] = null; //Redirect to edit page Response.Redirect("PendingOrders.aspx"); }
protected void btnSubmit_Click(object sender, EventArgs e) { OrderTier theTier = new OrderTier(); Order theOrder = new Order(); theOrder.orderID = (int)Session["OrderID"]; theOrder.custID = int.Parse(txtCustID.Text); theOrder.cartID = Guid.Parse(txtCartID.Text); if (txtTotal.Text.StartsWith("$")) { txtTotal.Text.Remove(0, 1); } theOrder.total = Convert.ToDouble(txtTotal.Text); if (calDateOfSale.SelectedDate != null) { theOrder.dateOfSale = calDateOfSale.SelectedDate; } //This is here because I was initially concatenating $ and % onto some of the fields but it kept giving me invalid format //exceptions even when I removed them before parsing. if (txtTaxRate.Text.EndsWith("%")) { txtTaxRate.Text.Remove(txtTaxRate.Text.IndexOf("%"), 1); } theOrder.taxRate = Convert.ToDouble(txtTaxRate.Text); if (txtDiscount.Text.EndsWith("%")) { txtDiscount.Text.Remove(txtDiscount.Text.IndexOf("%"), 1); } theOrder.discount = Convert.ToDouble(txtDiscount.Text); if (theTier.modifyOrder(theOrder)) { Response.Redirect("/SuccessfulSubmission.aspx"); } else { Response.Redirect("/FailedSubmission.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["OrderID"] != null) { int id = (int)Session["OrderID"]; OrderTier theTier = new OrderTier(); Order theOrder = theTier.getOrderByID(id); idLabel.InnerText = "Order ID: " + theOrder.orderID; if (!IsPostBack) { txtCartID.Text = theOrder.cartID.ToString(); txtCustID.Text = theOrder.custID.ToString(); txtTotal.Text = Math.Round(theOrder.total).ToString(); lblDateOfSale.Text = theOrder.dateOfSale.ToShortDateString(); txtTaxRate.Text = Math.Round(theOrder.taxRate, 3).ToString(); txtDiscount.Text = Math.Round(theOrder.discount, 2).ToString(); } } else { Response.Redirect("/Admin/OrderInfo.aspx"); } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (txtQty.Text == "") { Response.Write("<script>alert('Please enter a quantity')</script>"); } else { Orders ord = (Orders)Session["OrderInfo"]; ord.qty_ordered = Int32.Parse(txtQty.Text); Session["OrderInfo"] = ord; if (ord == null) { Response.Write("<script>alert('null. thats weird')</script>"); } else { OrderTier ordTier = new OrderTier(); ordTier.insertOrder(ord); Response.Redirect("Order.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { OrderTier theTier = new OrderTier(); List <Order> theList = theTier.getAllOrders(); Table theTable = new Table(); theTable.CssClass = "table-striped"; theTable.Style.Add("margin", "10px auto 10px auto"); theTable.Style.Add("width", "auto"); TableHeaderCell th; TableRow tr = new TableRow(); TableCell td; Button delete; Button edit; Button details; th = new TableHeaderCell(); Label theLabel = new Label(); theLabel.Text = "Order ID"; th.Controls.Add(theLabel); tr.Cells.Add(th); th = new TableHeaderCell(); theLabel = new Label(); theLabel.Text = "Customer ID"; th.Controls.Add(theLabel); tr.Cells.Add(th); th = new TableHeaderCell(); theLabel = new Label(); theLabel.Text = "Cart ID"; th.Controls.Add(theLabel); tr.Cells.Add(th); th = new TableHeaderCell(); theLabel = new Label(); theLabel.Text = "Total"; th.Controls.Add(theLabel); tr.Cells.Add(th); th = new TableHeaderCell(); theLabel = new Label(); theLabel.Text = "Date of Sale"; th.Controls.Add(theLabel); tr.Cells.Add(th); th = new TableHeaderCell(); theLabel = new Label(); theLabel.Text = "Tax Rate"; th.Controls.Add(theLabel); tr.Cells.Add(th); th = new TableHeaderCell(); theLabel = new Label(); theLabel.Text = "Discount"; th.Controls.Add(theLabel); tr.Cells.Add(th); theTable.Rows.Add(tr); if (theList != null) { foreach (Order item in theList) { tr = new TableRow(); td = new TableCell(); theLabel = new Label(); theLabel.Text = item.orderID.ToString(); td.Controls.Add(theLabel); tr.Cells.Add(td); td = new TableCell(); theLabel = new Label(); theLabel.Text = item.custID.ToString(); td.Controls.Add(theLabel); tr.Cells.Add(td); td = new TableCell(); theLabel = new Label(); theLabel.Text = item.cartID.ToString(); td.Controls.Add(theLabel); tr.Cells.Add(td); td = new TableCell(); theLabel = new Label(); theLabel.Text = "$" + Math.Round(item.total, 2).ToString("N2"); td.Controls.Add(theLabel); tr.Cells.Add(td); td = new TableCell(); theLabel = new Label(); theLabel.Text = item.dateOfSale.ToShortDateString(); td.Controls.Add(theLabel); tr.Cells.Add(td); td = new TableCell(); theLabel = new Label(); theLabel.Text = Math.Round(item.taxRate, 3).ToString() + "%"; td.Controls.Add(theLabel); tr.Cells.Add(td); td = new TableCell(); theLabel = new Label(); theLabel.Text = Math.Round(item.discount, 2).ToString() + "%"; td.Controls.Add(theLabel); tr.Cells.Add(td); td = new TableCell(); delete = new Button(); delete.Text = "Delete"; delete.ID = item.orderID.ToString(); delete.Click += deleteClick; td.Controls.Add(delete); edit = new Button(); edit.Text = "Edit"; edit.ID = item.orderID.ToString() + "a"; edit.Click += editClick; td.Controls.Add(edit); tr.Cells.Add(td); td = new TableCell(); details = new Button(); details.Text = "Details"; details.ID = item.orderID.ToString() + "b"; details.Click += detailsClick; td.Controls.Add(details); tr.Cells.Add(td); theTable.Rows.Add(tr); } } pnlOut.Controls.Add(theTable); }