// // GET: /Branch/Details/5 public ActionResult Details(int id) { BranchModel branch = new BranchModel(); branch = Utility.convertSrcToTarget <Branch, BranchModel>(BranchManager.GetBranchById(id, "nirshan")); return(View(branch)); }
/// <summary> /// 修改、删除部门信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvBranchList_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Delete") { try { int branchId = Convert.ToInt32(e.CommandArgument.ToString()); BranchManager.DeleteBranchById(branchId); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, GetType(), "key", "alert('请先删除外键中的数据!')", true); } BindBranchInfo(); } if (e.CommandName == "Update") { int id = Convert.ToInt32(e.CommandArgument.ToString()); ViewState["BranchId"] = id; this.btnAdd.Enabled = false; this.btnUpdate.Enabled = true; Branch branch = BranchManager.GetBranchById(UpdateBranchId); this.txtBranchName.Text = branch.BranchName; txtBranchShortName.Text = branch.BranchShortName; } }
public static String GetOrderDetails() { String html = String.Empty; StringBuilder finalTemplate = new StringBuilder(); StringBuilder shortCarttemplate = new StringBuilder(); Double subTotal = 0; Double tax = 0; #region Detail Items if (SessionUserOrder != null) { for (int i = 0; i < SessionUserOrder.OrderDetailsList.Count; i++) { StringBuilder template = new StringBuilder(); template = template.Append(Core.Utility.ReadFile(PhysicalApplicationPath + HtmlFolder + "ShortOrderDetail.html")); template.Replace("{PRODUCTNAME}", SessionUserOrder.OrderDetailsList.ElementAt(i).ProductName); template.Replace("{IMAGEPATH}", "/Products/" + SessionUserOrder.OrderDetailsList.ElementAt(i).ProductImage); template.Replace("{QUANTITY}", SessionUserOrder.OrderDetailsList.ElementAt(i).Quantity.ToString()); template.Replace("{PRICE}", SessionUserOrder.OrderDetailsList.ElementAt(i).ItemTotal.ToString()); finalTemplate.Append(template.ToString()); subTotal += SessionUserOrder.OrderDetailsList.ElementAt(i).ItemTotal; } } #endregion #region Short Cart shortCarttemplate = shortCarttemplate.Append(Core.Utility.ReadFile(PhysicalApplicationPath + HtmlFolder + "ShortCart.html")); if (SessionUserOrder != null && SessionUserOrder.OrderDetailsList.Count > 0) { BranchManager branchManager = new BranchManager(); Branches branch = branchManager.GetBranchById(BranchId); shortCarttemplate = shortCarttemplate.Replace("{DETAIL}", finalTemplate.ToString()); shortCarttemplate = shortCarttemplate.Replace("{ITEMS}", SessionUserOrder.OrderDetailsList.Count.ToString()); shortCarttemplate = shortCarttemplate.Replace("{SUBTOTAL}", subTotal.ToString()); shortCarttemplate = shortCarttemplate.Replace("{TAX}", Math.Round(branch.TaxPercentage, 2).ToString("G")); tax = Math.Round((SessionUserOrder.OrderTotal * Convert.ToDouble(branch.TaxPercentage)) / 100, 2); shortCarttemplate = shortCarttemplate.Replace("{TAXPRICE}", tax.ToString("G")); shortCarttemplate = shortCarttemplate.Replace("{TOTALPRICE}", (tax + SessionUserOrder.OrderTotal).ToString("G")); } else { shortCarttemplate = shortCarttemplate.Replace("{DETAIL}", "No item is added in cart."); shortCarttemplate = shortCarttemplate.Replace("{ITEMS}", "0"); shortCarttemplate = shortCarttemplate.Replace("{SUBTOTAL}", "0"); shortCarttemplate = shortCarttemplate.Replace("{TAX}", "0"); shortCarttemplate = shortCarttemplate.Replace("{TAXPRICE}", "0"); shortCarttemplate = shortCarttemplate.Replace("{TOTALPRICE}", "0"); } #endregion return(shortCarttemplate.ToString()); }
private void ShowCart() { if (SessionUserOrder != null) { rptCart.DataSource = SessionUserOrder.OrderDetailsList; SessionUserOrder.OrderDetailsList.Select(o => new { o.ItemTotal }).ToList(); } else { rptCart.DataSource = null; } rptCart.DataBind(); if (SessionUserOrder != null && SessionUserOrder.OrderDetailsList.Count > 0) { BusinessEntities.Branches branch = branchManager.GetBranchById(BranchId); hdVAT.Value = Math.Round(branch.TaxPercentage, 2).ToString("G"); if (SessionPreOrderPromo != null) { txtSubTotal.Text = SessionUserOrder.OrderTotal.ToString("G"); txtDiscount.Text = SessionPreOrderPromo.PreOrderPromoValue.ToString("G"); deduction.Visible = true; txtVATAmount.Text = Math.Round(((SessionUserOrder.OrderTotal - SessionPreOrderPromo.PreOrderPromoValue) * Convert.ToDouble(branch.TaxPercentage)) / 100, 2).ToString("G"); txtTotal.Text = Math.Round(Convert.ToDouble(txtVATAmount.Text) + (SessionUserOrder.OrderTotal - SessionPreOrderPromo.PreOrderPromoValue), 2).ToString("G"); } else { txtSubTotal.Text = SessionUserOrder.OrderTotal.ToString(); txtVATAmount.Text = Math.Round((SessionUserOrder.OrderTotal * Convert.ToDouble(branch.TaxPercentage)) / 100, 2).ToString("G"); txtTotal.Text = Math.Round(Convert.ToDouble(txtVATAmount.Text) + Convert.ToDouble(txtSubTotal.Text), 2).ToString("G"); } } else { txtSubTotal.Text = ""; hdVAT.Value = ""; txtVATAmount.Text = ""; txtTotal.Text = ""; } }
private void OrderNow_Click(object sender, RoutedEventArgs e) { Branches branch = branchManager.GetBranchById(1); UserOrder.BranchID = 1; UserOrder.ContactInfoId = ContactInfoObject.ContactInfoId; UserOrder.CustomerName = ContactInfoObject.FirstName + " " + ContactInfoObject.LastName; UserOrder.OrderStatusID = OrderStatus.NewOrder; UserOrder.TaxPercentage = (double)branch.TaxPercentage; if (UserOrder.OrderTypeID == OrderType.Deliver) { UserOrder.DeliveryCharges = (double)branch.DeliveryCharges; UserOrder.OrderTypeID = OrderType.Deliver; } else { UserOrder.OrderTypeID = OrderType.SelfPickup; UserOrder.DeliveryCharges = 0; } Double Tax = ((UserOrder.OrderTotal - deduction + UserOrder.DeliveryCharges) * Convert.ToDouble(branch.TaxPercentage)) / 100; UserOrder.OrderTotal = UserOrder.OrderTotal - deduction + UserOrder.DeliveryCharges + Tax; Int64 result = orderManager.AddOrder(UserOrder, _OrderDetailOptionList, _OrderDetailAdonList); if (result > 0) { MessageBox.Show("Order has been placed successfully."); string buffer = "\x1b\x1d\x61\x1"; //Center Alignment - Refer to Pg. 3-29 //buffer = buffer + "\x5B" + "If loaded.. Logo1 goes here" + "\x5D\n"; //buffer = buffer + "\x1B\x1C\x70\x1\x0"; //Stored Logo Printing - Refer to Pg. 3-38 buffer = buffer + "\x1b\x69\x1 \x1b\x45 PIZZANESS \x1b\x46 \x1b\x69\x0 \n"; buffer = buffer + "10829 Lanham Sevem Rd.\n"; buffer = buffer + "Glenn Dale, MD 20796\n"; buffer = buffer + "301-464-2600\n\n"; buffer = buffer + "\x1b\x1d\x61\x0"; //Left Alignment - Refer to Pg. 3-29 buffer = buffer + "\x1b\x44\x2\x10\x22\x0"; //Setting Horizontal Tab - Pg. 3-27 buffer = buffer + "Date: " + DateTime.Now.ToString("MMM, dd yyyy") + "\x9 Time:" + DateTime.Now.ToString("HH:mm") + "\n"; //Moving Horizontal Tab - Pg. 3-26 buffer = buffer + "------------------------------------------------ \n"; buffer = buffer + ContactInfoObject.Title + " " + ContactInfoObject.FirstName + " " + ContactInfoObject.LastName + "\n"; buffer = buffer + ContactInfoObject.ContactAddressList.ElementAt(0).Address + "\n"; buffer = buffer + ContactInfoObject.ContactAddressList.ElementAt(0).City + " " + ContactInfoObject.ContactAddressList.ElementAt(0).State + " " + ContactInfoObject.ContactAddressList.ElementAt(0).Zip + "\n"; if (ContactInfoObject.Telephone.Length == 10) { buffer = buffer + ContactInfoObject.Telephone.Substring(0, 3) + "-" + ContactInfoObject.Telephone.Substring(3, 3) + "-" + ContactInfoObject.Telephone.Substring(6, 4) + "\n"; } else { buffer = buffer + ContactInfoObject.Telephone + "\n"; } if (!String.IsNullOrEmpty(ContactInfoObject.Mobile)) { if (ContactInfoObject.Mobile.Length == 10) { buffer = buffer + ContactInfoObject.Mobile.Substring(0, 3) + "-" + ContactInfoObject.Mobile.Substring(3, 3) + "-" + ContactInfoObject.Mobile.Substring(6, 4) + "\n"; } else { buffer = buffer + ContactInfoObject.Mobile + "\n"; } } buffer = buffer + "------------------------------------------------ \n"; buffer = buffer + "\x1b\x45"; //Select Emphasized Printing - Pg. 3-14 buffer = buffer + "ORDER DETAILS\n"; buffer = buffer + "\x1b\x46"; //Cancel Emphasized Printing - Pg. 3-14 Int16 counter = 1; Double SubTotal = 0; buffer = buffer + "No." + "\x9 Item Name\x9\x9\x9 Price \n"; foreach (OrderDetails orderDetail in UserOrder.OrderDetailsList) { buffer = buffer + counter + "\x9" + orderDetail.ProductName + "\x9\x9\x9$" + Math.Round(orderDetail.Price, 2) + " \n"; if (orderDetail.IsGroupProduct) { foreach (OrderDetailSubProduct product in orderDetail.OrderDetailSubProducts) { buffer = buffer + "\x9 • " + product.ProductName + "\n"; if (product.OrderDetailSubProductOptions.Count > 0) { buffer = buffer + "\x9 Options:\n"; foreach (OrderDetailSubProductOption suboption in product.OrderDetailSubProductOptions) { buffer = buffer + "\x9 " + suboption.ProductOptionName + "\n"; } } if (product.OrderDetailSubProductAdons.Count > 0) { buffer = buffer + "\x9 Toppings:\n"; foreach (OrderDetailSubProductAdon subadon in product.OrderDetailSubProductAdons) { if ((SelectedOption)subadon.SelectedAdonOption != SelectedOption.None) { buffer = buffer + "\x9 " + subadon.AdonName + "\n"; } } } } } else { List <OrderDetailOptions> detailOptionList = _OrderDetailOptionList.ElementAt(counter - 1); if (detailOptionList.Count > 0) { buffer = buffer + "\x9Options:\n"; foreach (OrderDetailOptions detailOption in detailOptionList) { buffer = buffer + "\x9" + detailOption.ProductOptionName + "\n"; } } List <OrderDetailAdOns> detailAdonList = _OrderDetailAdonList.ElementAt(counter - 1); if (detailAdonList.Count > 0) { buffer = buffer + "\x9Toppings:\n"; foreach (OrderDetailAdOns detailAdon in detailAdonList) { if (detailAdon.SelectedAdonOption != SelectedOption.None) { buffer = buffer + "\x9 " + detailAdon.AdonName + "(" + detailAdon.SelectedAdonOption.ToString() + ")\n"; } } } } counter++; SubTotal += orderDetail.Price; } buffer = buffer + "Subtotal " + "\x9\x9\x9 $" + Math.Round(SubTotal, 2) + " \n"; if (UserOrder.DeliveryCharges > 0) { buffer = buffer + "Delivery Charges " + "\x9" + "" + "\x9" + "" + " $" + UserOrder.DeliveryCharges + ".00\n"; } buffer = buffer + "Tax " + "\x9" + "" + "\x9" + "" + " $" + Math.Round(Tax, 2) + " \n"; if (deduction > 0) { buffer = buffer + "Discount " + "\x9\x9\x9$" + Math.Round(deduction, 2) + " \n"; } buffer = buffer + "------------------------------------------------ \n"; buffer = buffer + "Total" + "\x6" + "" + "\x9" + "\x1b\x69\x1\x1" + " $" + Math.Round(UserOrder.OrderTotal, 2) + " \n"; //Character Expansion - Pg. 3-10 buffer = buffer + "\x1b\x69\x0\x0"; //Cancel Expansion - Pg. 3-10 buffer = buffer + "------------------------------------------------ \n"; buffer = buffer + "Thank you for ordering."; /*buffer = buffer + "Visa XXXX-XXXX-XXXX-0123\n\n"; * buffer = buffer + "\x1b\x34" + "Refunds and Exchanges" + "\x1b\x35\n"; //Specify/Cencel White/Black Invert - Pg. 3-16 * buffer = buffer + "Within " + "\x1b\x2d\x1" + "30 days" + "\x1b\x2d\x0" + " with receipt\n"; //Specify/Cancel Underline Printing - Pg. 3-15 * buffer = buffer + "And tags attached\n\n";*/ buffer = buffer + "\x1b\x1d\x61\x1"; //Center Alignment - Refer to Pg. 3-29 // buffer = buffer + "\x1b\x62\x6\x2\x2" + " 12ab34cd56" + "\x1e\n"; //Barcode - Pg. 3-39 - 3-40 buffer = buffer + "\x1b\x64\x02"; //Cut - Pg. 3-41 buffer = buffer + "\x7"; //Open Cash Drawer // Allow the user to select a printer. PrintDialog pd = new PrintDialog(); //pd.PrinterSettings = new PrinterSettings(); //if (DialogResult.Value == pd.ShowDialog().Value) //{ // Send a printer-specific to the printer. RawPrinterHelper.SendStringToPrinter(System.Configuration.ConfigurationSettings.AppSettings["PrinterName"], buffer); //} UserOrder = null; _OrderDetailOptionList.Clear(); _OrderDetailAdonList.Clear(); this.Close(); } }
// // GET: /Branch/Edit/5 public ActionResult Edit(int id) { BranchManager.GetBranchById(id, "nirshan"); return(View(Utility.convertSrcToTarget <Branch, BranchModel>(BranchManager.GetBranchById(id, "nirshan")))); }
public static object AddPromotionCode(String promotionCode, Double lineTip, Double deliveryCharges) { #region Variables string json = @"{{'SubTotal':{0},'Tax': {1}, 'OrderTotal': {2}, 'InvalidCode': {3} }}"; Double deduction = 0, NewTotal = 0, Tax = 0; PromotionCodeManager promoManager = new PromotionCodeManager(); BranchManager branchManager = new BranchManager(); JavaScriptSerializer serializer = new JavaScriptSerializer(); #endregion PromotionCodes code = promoManager.GetPromotionCodeByCode(promotionCode); Branches branch = branchManager.GetBranchById(BranchId); if (code != null) { DateTime currentDate = DateTime.Now; NewTotal = SessionUserOrder.OrderTotal; Tax = ((NewTotal + deliveryCharges) * Convert.ToDouble(branch.TaxPercentage)) / 100; double preOrderPromoValue = 0.0d; if (SessionPreOrderPromo != null) { preOrderPromoValue = SessionPreOrderPromo.PreOrderPromoValue; if (SessionPreOrderPromo.PreOrderPromoCode.ToLower().Equals(promotionCode.ToLower())) { json = string.Format(json, SessionUserOrder.OrderTotal, Tax, (SessionUserOrder.OrderTotal + deliveryCharges + Tax + lineTip), Resources.ErrorMessages.PromoCodeInUse); } return(serializer.Deserialize <Dictionary <string, string> >(json)); } if (currentDate > code.EndDate || currentDate < code.StartDate) { json = string.Format(json, SessionUserOrder.OrderTotal, Tax, (SessionUserOrder.OrderTotal + deliveryCharges + Tax + lineTip), Resources.ErrorMessages.PromoOutOfDate); return(serializer.Deserialize <Dictionary <string, string> >(json)); } if (code.TypeOfPromotion == PromotionType.EGiftCard && code.CodeUsageCounter != null && code.CodeUsageCounter == 0) // in db it's incrementing { json = string.Format(json, SessionUserOrder.OrderTotal, Tax, (SessionUserOrder.OrderTotal + Tax + lineTip), Resources.ErrorMessages.PromoCounterZero); return(serializer.Deserialize <Dictionary <string, string> >(json)); } if (code.TypeOfPromotion == PromotionType.Money) { deduction = code.PromotionValue; } else if (code.TypeOfPromotion == PromotionType.EGiftCard) { if ((code.PromotionValue - code.PromoValueUsed) > 0) { if (SessionUserOrder.OrderTotal < (code.PromotionValue - code.PromoValueUsed)) { code.PromoValueUsed += deduction = SessionUserOrder.OrderTotal; } else { code.PromoValueUsed += deduction = (code.PromotionValue - code.PromoValueUsed); } } else { // promo value used completely json = string.Format(json, NewTotal, Tax, (NewTotal + deliveryCharges + Tax + lineTip), Resources.ErrorMessages.PromoCodeBalanceEnded); return(serializer.Deserialize <Dictionary <string, string> >(json)); } } else { deduction = (SessionUserOrder.OrderTotal * code.PromotionValue) / 100; } NewTotal = SessionUserOrder.OrderTotal; NewTotal = NewTotal <= 0 ? 0 : NewTotal; Tax = ((NewTotal + deliveryCharges) * Convert.ToDouble(branch.TaxPercentage)) / 100; json = string.Format(json, NewTotal, Tax, (NewTotal + deliveryCharges + Tax + lineTip) - deduction, 0); var dict = serializer.Deserialize <Dictionary <string, string> >(json); return(dict); } else { SessionPreOrderPromo = null; Tax = (SessionUserOrder.OrderTotal + deliveryCharges) * (Convert.ToDouble(branch.TaxPercentage)) / 100; json = string.Format(json, SessionUserOrder.OrderTotal, Tax, SessionUserOrder.OrderTotal + deliveryCharges + Tax + lineTip, Resources.ErrorMessages.PromoCodeInvalid); var dict = serializer.Deserialize <Dictionary <string, string> >(json); return(dict); } }