protected string GetOrderTotalPrice(Order order) { var orderTotal = theGateContext.OrderLines.Where(ol => ol.orderID == order.orderID).Sum(ol => ol.quantity * ol.price); return "$" + orderTotal.ToString(); }
private string GetOrderTotal(Order o) { var total = new decimal(); foreach (var od in o.OrderLines) { total += od.price * od.quantity; } return total.ToString(); }
protected string GetOrderState(Order order) { var orderState = theGateContext.OrderStates.Where(os => os.orderStateID == order.state).FirstOrDefault(); return orderState.name; }
protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(Request.QueryString["id"])) { // add order setup if (!Page.IsPostBack) LoadDropdowns(); ButtonOrderAction.Text = "Add Order"; ButtonOrderAction.Click += ButtonOrderActionAdd_Click; ButtonOrderCancelled.Visible = false; ButtonOrderShipped.Visible = false; ButtonOrderRecieved.Visible = false; PanelOrderDetails.Visible = false; ddlState.SelectedValue = "1"; ddlState.Enabled = false; return; } int i = int.Parse(Request.QueryString["id"] != null ? Request.QueryString["id"] : "0"); orderA = theGateContext.Orders.FirstOrDefault(o => o.orderID == i); if (orderA == null) { ShowError("Order not found."); PanelOrderForm.Visible = false; return; } ButtonOrderAction.Text = "Update Order"; ButtonOrderAction.Click += ButtonOrderActionUpdate_Click; if (Page.IsPostBack) return; ButtonOrderCancelled.Visible = true; ButtonOrderShipped.Visible = true; LoadDropdowns(); ddlState.Enabled = false; if (orderA.type != 3) ButtonOrderRecieved.Visible = false; ddlType.SelectedValue = orderA.type.ToString(); if (orderA.state == 4) { ButtonOrderShipped.Enabled = false; ButtonOrderCancelled.Enabled = false; ButtonOrderAction.Enabled = false; ButtonOrderRecieved.Enabled = false; PanelOrderFormControls.Enabled = false; } ddlState.SelectedValue = orderA.state.ToString(); if (orderA.accountID != null) ddlAccount.SelectedValue = orderA.accountID.ToString(); else { ddlAccount.SelectedIndex = -1; ddlAccount.Enabled = false; } ddlContact.SelectedValue = orderA.contactID.ToString(); lblDateMadeData.Text = orderA.dateMade.ToString("g"); if (orderA.dateShipped != null) { lblDateShippedData.Text = orderA.dateShipped.GetValueOrDefault().ToString("g"); ButtonOrderShipped.Enabled = false; } if (orderA.dateRecieved != null) { lblDateRecievedData.Text = orderA.dateRecieved.GetValueOrDefault().ToString("g"); ButtonOrderRecieved.Enabled = false; } if (orderA.paid.GetValueOrDefault()) { ButtonOrderPaid.CssClass = "btn btn-success"; ButtonOrderPaid.Enabled = false; } LoadOrderDetails(); }
private void WriteOrderInfo(Order o) { StringBuilder stringBuilder = new StringBuilder(); AddComma(o.orderID.ToString(), stringBuilder); AddComma(o.Contact.firstName + " " + o.Contact.lastName, stringBuilder); AddComma(o.accountID == null ? string.Empty : o.Account.accountName, stringBuilder); AddComma(o.OrderState.name, stringBuilder); AddComma(o.dateMade.ToString(), stringBuilder); AddComma(o.dateShipped == null ? string.Empty : o.dateShipped.ToString(), stringBuilder); AddComma(string.Format("{0:C2}", GetOrderTotal(o)), stringBuilder); HttpContext.Current.Response.Write(stringBuilder.ToString()); HttpContext.Current.Response.Write(Environment.NewLine); }
protected string GetOrderStatus(Order o) { return o.OrderState.name; }
protected void ProceedBtn_Click(object sender, EventArgs e) { var order = new Order() { type = 1, state = 1, contactID = contact.contactID, accountID = contact.accountID, dateMade = DateTime.Now }; theGateContext.Orders.Add(order); theGateContext.SaveChanges(); int orderIdVal = order.orderID; Dictionary<string, int> ht = (Dictionary<string, int>)Session["cartHashTable"]; foreach (var pair in ht) { Session["currentKey"] = pair.Key; var orderline = new OrderLine() { orderID = orderIdVal, productID = Product.productID, quantity = pair.Value, price = pair.Value * Product.price }; theGateContext.OrderLines.Add(orderline); theGateContext.SaveChanges(); } Dictionary<string, int> clearHT = new Dictionary<string, int>(); Session["cartHashTable"] = clearHT; Response.Redirect("OrderSuccess.aspx"); }
protected string GetOrderDateShipped(Order o) { return o.dateShipped != null ? o.dateShipped.GetValueOrDefault().ToString("g") : string.Empty; }
protected string GetOrderDateMade(Order o) { return o.dateMade.ToString("g"); }
protected string GetOrderContact(Order o) { return string.Format("{0} {1}", o.Contact.firstName, o.Contact.lastName); }
protected string GetOrderAccount(Order o) { return o.accountID != null ? o.Account.accountName : string.Empty; }
protected string GenOrderDetailLink(Order o) { return "OrderDetails.aspx?id=" + o.orderID.ToString(); }