Exemplo n.º 1
0
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Qty       = Qty + Double.Parse(e.Row.Cells[6].Text);
                UnitPrice = UnitPrice + Double.Parse(e.Row.Cells[7].Text);
                TotalDP   = TotalDP + Double.Parse(e.Row.Cells[10].Text);
                //TotalTaxAmount = TotalTaxAmount + Double.Parse(e.Row.Cells[8].Text);
                TotalPrice             = TotalPrice + Double.Parse(e.Row.Cells[12].Text);
                lblTotalTaxAmount.Text = string.Format("{0:f2}", (Double.Parse(lblTotalTaxAmount.Text)));
                GrossAmt = GrossAmt + Double.Parse(e.Row.Cells[12].Text);
                Tottax   = (0 + Double.Parse(lblTotalTaxAmount.Text.ToString().Replace(".0000", ".00")));
            }

            if (e.Row.RowType == DataControlRowType.Footer)
            {
                e.Row.Cells[2].Text  = "Total :";
                e.Row.Cells[7].Text  = string.Format("{0:f2}", UnitPrice);
                e.Row.Cells[6].Text  = Qty.ToString();
                e.Row.Cells[10].Text = string.Format("{0:f0}", TotalDP);
                //e.Row.Cells[8].Text = string.Format("{0:f2}", TotalTaxAmount);
                e.Row.Cells[12].Text = string.Format("{0:f2}", TotalPrice);

                Double Courch = Double.Parse((lblCourierCharges.Text).ToString().Replace(".0000", ".00"));
                Double NetPay = Tottax + TotalPrice + Courch;

                lblTotalPayment.Text  = TotalPrice.ToString();
                bvdiscountamount.Text = "0.00";
            }
        }
 protected void rpt_FinalCart_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     try
     {
         if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
         {
             TotalQty   += Convert.ToDecimal(DataBinder.Eval(e.Item.DataItem, "Quantity"));
             TotalPrice += Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "Unit_Price"));
         }
         if (e.Item.ItemType == ListItemType.Footer)
         {
             Label l_TotalQty   = e.Item.FindControl("l_TotalQty") as Label;
             Label l_TotalPrice = e.Item.FindControl("l_TotalPrice") as Label;
             if (l_TotalQty != null && l_TotalPrice != null)
             {
                 l_TotalQty.Text   = TotalQty.ToString("0");
                 l_TotalPrice.Text = TotalPrice.ToString();
             }
         }
     }
     catch (Exception ex)
     {
         var message = new JavaScriptSerializer().Serialize(ex.Message.ToString());
         var script  = string.Format("alert({0});", message);
         ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "", script, true);
     }
 }
Exemplo n.º 3
0
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Double qtyes = Double.Parse(e.Row.Cells[5].Text);
                Double taxes = (Double.Parse(e.Row.Cells[8].Text) + Double.Parse(e.Row.Cells[7].Text)) * (qtyes);
                Qty            = Qty + Double.Parse(e.Row.Cells[5].Text);
                UnitPrice      = UnitPrice + Double.Parse(e.Row.Cells[4].Text);
                TotalDP        = TotalDP + Double.Parse(e.Row.Cells[6].Text);
                TotalTaxAmount = TotalTaxAmount + Double.Parse(e.Row.Cells[7].Text);
                Total          = Total + Double.Parse(e.Row.Cells[9].Text);
                TotalPrice     = TotalPrice + Double.Parse(e.Row.Cells[10].Text);
                TTax           = TTax + Double.Parse(e.Row.Cells[8].Text);
                // lblTotalTaxAmount.Text = string.Format("{0:f2}", (Double.Parse(e.Row.Cells[10].Text)) - (Double.Parse(e.Row.Cells[4].Text) * Double.Parse(e.Row.Cells[5].Text)));
                // lblnetprice.Text = string.Format("{0:f2}", (Double.Parse(e.Row.Cells[4].Text) * Double.Parse(e.Row.Cells[5].Text)));
            }
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                e.Row.Cells[3].Text = "Total :";
                // e.Row.Cells[4].Text = string.Format("{0:f2}", UnitPrice);
                e.Row.Cells[5].Text = Qty.ToString();
                // e.Row.Cells[6].Text = string.Format("{0:f2}", TotalDP);
                e.Row.Cells[7].Text  = string.Format("{0:f2}", TotalTaxAmount);
                e.Row.Cells[8].Text  = string.Format("{0:f2}", TTax);
                e.Row.Cells[9].Text  = string.Format("{0:f2}", Total);
                e.Row.Cells[10].Text = string.Format("{0:f2}", TotalPrice);

                // lblMoneyInWord.Text = NoToEng.changeNumericToWords(TotalPrice);
                lblNetProductValue.Text = TotalDP.ToString();
                lbltotalprice.Text      = TotalPrice.ToString();
                lblAddvat.Text          = TTax.ToString();
                lblTotalTaxAmount.Text  = TotalTaxAmount.ToString();
            }
        }
Exemplo n.º 4
0
        public List <ShippingOption> GetOptions(bool isCombine = true)
        {
            Init();

            var webRequest = (HttpWebRequest)WebRequest.Create(Url + "/searchDeliveryList");

            webRequest.ContentType = "application/x-www-form-urlencoded";
            webRequest.Method      = "POST";
            webRequest.Accept      = "text/json";

            var data = new Dictionary <string, object>()
            {
                { "client_id", _clientId },
                { "city_from", _cityFrom },
                { "city_to", CityTo },
                { "weight", Weight.ToString("F3").Replace(",", ".") },
                { "height", Height },
                { "width", Width },
                { "length", Length },
                { "total_cost", TotalPrice.ToString("F2").Replace(",", ".") }
            };


            var dataPost = string.Format("{0}&secret_key={1}",
                                         String.Join("&", data.Select(x => x.Key + "=" + x.Value)),
                                         MultishipService.GetSign(data, _secretKeyDelivery));

            var bytes = Encoding.UTF8.GetBytes(dataPost);

            webRequest.ContentLength = bytes.Length;
            using (var requestStream = webRequest.GetRequestStream())
            {
                requestStream.Write(bytes, 0, bytes.Length);
                requestStream.Close();
            }

            try
            {
                using (var response = webRequest.GetResponse())
                {
                    using (var stream = response.GetResponseStream())
                    {
                        if (stream != null)
                        {
                            using (var reader = new StreamReader(stream))
                            {
                                var result = reader.ReadToEnd();
                                return(ParseAnswer(result, isCombine));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.LogError(ex);
            }

            return(new List <ShippingOption>());
        }
Exemplo n.º 5
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            int transid = Convert.ToInt32(TxtIdTrans.Text);

            if (TxtQuantity.Text == "")
            {
                MessageBox.Show("Quantity is empty");
            }
            else
            {
                itemid = Convert.ToInt32(CBItems.SelectedValue.ToString());
                var itemname  = myContext.Items.Where(w => w.Id == itemid).FirstOrDefault();
                var transitem = myContext.Transactions.Where(w => w.Id == transid).FirstOrDefault();

                int q = Convert.ToInt32(TxtQuantity.Text);
                int s = Convert.ToInt32(TxtStock.Text);
                if (q != 0)
                {
                    if (s >= q)
                    {
                        int price     = Convert.ToInt32(TxtPrice.Text);
                        int quantity  = Convert.ToInt32(TxtQuantity.Text);
                        int tot       = price * quantity;
                        int tempStock = s - quantity;

                        int stock  = itemname.Stock;
                        var stock2 = s - stock;

                        int stockminus = stock2;
                        TxtTotal1.Text = TotalPrice.ToString();

                        lasttotal += tot;

                        TransList.Add(new TransactionItem {
                            Quantity = quantity, Transaction = transitem, Item = itemname
                        });

                        DataGridTransaction.Items.Add(new { Name = CBItems.Text, Quantity = TxtQuantity.Text, Price = TxtPrice.Text, TotalPrice = tot.ToString() });

                        TxtTotal1.Text = lasttotal.ToString();
                        TxtTotal2.Text = lasttotal.ToString();
                        TxtStock.Text  = tempStock.ToString();

                        itemname.Stock = tempStock;
                        myContext.SaveChanges();

                        DataGridItem.ItemsSource = myContext.Items.ToList();
                    }
                    else
                    {
                        MessageBox.Show("Invalid Quantity");
                    }
                }
                else
                {
                    MessageBox.Show("Quantity is Null");
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Override the ToString() method;
        /// To generate an item string description
        /// </summary>
        /// <returns>An string description of the item</returns>
        public override string ToString()
        {
            string unitPriceAndQuantity = UnitPrice.ToString("C2", CultureInfo.CreateSpecificCulture("en-NZ")) + "*" + Quantity;
            string discount             = IsDiscountApplied ? ("Dis.:" + DiscountPercentage + "%\t-" + DiscountedTotalPrice.ToString("C2", CultureInfo.CreateSpecificCulture("en-NZ"))) : null;
            string totalPrice           = TotalPrice.ToString("C2", CultureInfo.CreateSpecificCulture("en-NZ"));

            return(Name + "\n" + unitPriceAndQuantity + "\t" + totalPrice + "\t" + discount);
        }
Exemplo n.º 7
0
 protected void txtNum_TextChanged(object sender, EventArgs e)
 {
     BookOrderInThisControl.quantity = int.Parse(txtNum.Text);
     OrderBLL.SetBookQuantity(BookOrderInThisControl, OrderOnThisPage);
     txtNum.Text   = BookOrderInThisControl.quantity.ToString();
     TotalPrice    = BookOrderInThisControl.quantity * BookOrderInThisControl.price;
     txtTotal.Text = TotalPrice.ToString("F2");
 }
Exemplo n.º 8
0
 public override string ToString()
 {
     return("Id: " + Id
            + ", Produto: " + Product
            + ", Classificação: " + ClassProduct
            + ", Preço Unidade: R$" + Price.ToString("F2")
            + ", Preço Total: R$" + TotalPrice.ToString("F2"));
 }
Exemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            InventoryText = "";

            if (!this.IsPostBack)
            {
                this._presenter.OnViewInitialized();

                //poulate state drop down lists
                PopulateStateDropDownList(ddlState);
            }
            this._presenter.OnViewLoaded();

            if (Session["ShoppingCart"] != null)
            {
                lblFeedback.Text  = "";
                lblInventory.Text = "";
                foreach (Inventory inv in (List <Inventory>)Session["ShoppingCart"])
                {
                    InventoryText += (SkiChair.Shell.Utility.SkiChairProduct)inv.ProductUID + ": " + inv.InventoryName + ", ";
                    TotalPrice    += inv.Price;

                    //if ottoman is part of order, add the price of it to total
                    if (inv.HasOttoman)
                    {
                        TotalPrice += Convert.ToDecimal(ConfigurationManager.AppSettings.Get("OttomanPrice"));
                    }
                }
                lblPrice.Text = TotalPrice.ToString("c");

                // set paypal session amount for processing within App_Code/paypalfunctions.cs
                decimal shipping = 0;
                decimal tax      = 0;
                CalculateTaxShipping(ref shipping, ref tax);
                Session["payment_amt"]  = TotalPrice;
                Session["shipping_amt"] = shipping;

                InventoryText = InventoryText.Substring(0, InventoryText.Length - 2); //drop last two digits of product string
                Session["product_description"] = InventoryText;
            }
            else
            {
                lblFeedback.Text = "Your shopping cart is empty, please choose a product before continuing";
                pnlPersonalInfoRequired.Visible = false;
                pnlOrderInfo.Visible            = false;
                pnlPersonalInfo.Visible         = false;
            }

            //add FirstData postbackurl to submit button from config file
            //btnSubmit.PostBackUrl = ConfigurationManager.AppSettings.Get("FirstDataURL");
            //btnSubmit.PostBackUrl = ConfigurationManager.AppSettings.Get("PayPalEndpointURL");
            //Response.Redirect("expresscheckout.aspx");

            //add store name to form for FirstData from config file
            //spanStoreName.InnerHtml = "<input type='hidden' name='storename' value='" + ConfigurationManager.AppSettings.Get("FirstDataStoreNumber") + "' />";

            lblInventory.Text = InventoryText;
        }
Exemplo n.º 10
0
        private void MyBind()
        {
            M_UserInfo mu = buser.GetLogin();

            CartDT         = cartBll.SelByCartID(CartCookID, mu.UserID, ProClass);//从数据库中获取
            RPT.DataSource = orderCom.SelStoreDT(CartDT);
            RPT.DataBind();
            totalmoney.InnerText = TotalPrice.ToString("f2");
        }
        public FrmSellAuctionItemsToPerson(PersonPickup person)
        {
            InitializeComponent();
            Person         = person;
            StripeFirstTry = true;
            Text           = "Items Won by " + Person.Name;
            LblTaxes.Text  = "Taxes @ " + decimal.Round(Program.TaxRate * 100, 1) + "%";

            var payload = "action=GetItemsForPickup&id=" + Person.BadgeID + "&year=" + Program.Year.ToString();
            var data    = Encoding.ASCII.GetBytes(payload);

            var request = WebRequest.Create(Program.URL + "/functions/artQuery.php");

            request.ContentLength = data.Length;
            request.ContentType   = "application/x-www-form-urlencoded";
            request.Method        = "POST";
            using (var stream = request.GetRequestStream())
                stream.Write(data, 0, data.Length);

            var response = (HttpWebResponse)request.GetResponse();
            var results  = new StreamReader(response.GetResponseStream()).ReadToEnd();

            Items = JsonConvert.DeserializeObject <List <ArtShowItem> >(results);

            TotalPrice = 0;
            TotalDue   = 0;
            decimal taxibleAmount = 0;

            TotalTax = 0;
            foreach (var showItem in Items)
            {
                var item = new ListViewItem {
                    Text = showItem.LocationCode
                };
                item.SubItems.Add(showItem.ShowNumber.ToString());
                item.SubItems.Add(showItem.Title);
                item.SubItems.Add(showItem.ArtistDisplayName);
                item.SubItems.Add(((decimal)showItem.FinalSalePrice).ToString("C"));
                item.Tag = showItem;
                LstItems.Items.Add(item);
                TotalPrice += (decimal)showItem.FinalSalePrice;
                if (showItem.IsCharity)
                {
                    item.BackColor = Color.LightGreen;
                }
                else
                {
                    taxibleAmount += (decimal)showItem.FinalSalePrice;
                }
            }
            TotalTax            = taxibleAmount * Program.TaxRate;
            TotalTax            = decimal.Round(TotalTax, 2);
            TotalDue            = TotalPrice + TotalTax;
            LblAmountDue.Text   = TotalPrice.ToString("C");
            LblAmountTax.Text   = TotalTax.ToString("C");
            LblAmountTotal.Text = TotalDue.ToString("C");
        }
Exemplo n.º 12
0
 public string[] GetProperties() => new string[]
 {
     ID.ToString(),
         FullName,
         Address,
         Phone,
         Note,
         TotalPrice.ToString(),
         TotalAmount.ToString()
 };
Exemplo n.º 13
0
 public string GetTotalPrice()
 {
     if (LangType == LangType.Fa_En)
     {
         return(TotalPrice.ToString("0,0"));
     }
     else
     {
         return(TotalPriceOtherLang.ToString("0,0"));
     }
 }
Exemplo n.º 14
0
        private void MyBind()
        {
            M_UserInfo mu = buser.GetLogin();

            B_Cart.UpdateUidByCartID(CartCookID, mu);
            CartDT = cartBll.SelByCartID(CartCookID, mu.UserID, ProClass);//从数据库中获取
            CartDT.DefaultView.RowFilter = "StoreID=" + StoreID;
            CartDT         = CartDT.DefaultView.ToTable();
            RPT.DataSource = orderCom.SelStoreDT(CartDT);
            RPT.DataBind();
            totalmoney.InnerText = TotalPrice.ToString("f2");
        }
Exemplo n.º 15
0
        public XElement Write()
        {
            XElement element = new XElement(name);

            element.Add(new XAttribute("Version", writeVersion));
            element.Add(new XElement("Date", Date.ToString("o", CultureInfo.CreateSpecificCulture("de-DE"))));
            element.Add(new XElement("Type", Type.ToString()));
            element.Add(new XElement("Shares", Shares));
            element.Add(new XElement("Total", TotalPrice.ToString(CultureInfo.InvariantCulture)));

            return(element);
        }
Exemplo n.º 16
0
 public void SetBook(BookOrderModel bookOrder, OrderModel order)
 {
     BookOrderInThisControl = bookOrder;
     OrderOnThisPage        = order;
     linkDetail.Text        = bookOrder.book.title;
     linkDetail.PostBackUrl = "/details.aspx?book=" + bookOrder.book.id;
     imgCover.ImageUrl      = "/public/images/cover/" + bookOrder.book.image;
     txtCategory.Text       = bookOrder.book.category;
     txtNum.Text            = bookOrder.quantity.ToString();
     txtPrice.Text          = bookOrder.price.ToString("F2");
     TotalPrice             = bookOrder.quantity * bookOrder.book.price;
     txtTotal.Text          = TotalPrice.ToString("F2");
 }
Exemplo n.º 17
0
        private void CalculateTotal()
        {
            TotalPrice = LstCart.Items.Cast <ListViewItem>().Sum(cartItem => ((PrintShopItem)cartItem.Tag).Price);
            decimal taxibleAmount = LstCart.Items.Cast <ListViewItem>().Where(cartItem => !((PrintShopItem)cartItem.Tag).IsCharity).Sum(cartItem => ((PrintShopItem)cartItem.Tag).Price);

            TotalTax            = taxibleAmount * Program.TaxRate;
            TotalTax            = decimal.Round(TotalTax, 2);
            TotalDue            = TotalPrice + TotalTax;
            LblAmountDue.Text   = TotalPrice.ToString("C");
            LblAmountTax.Text   = TotalTax.ToString("C");
            LblAmountTotal.Text = TotalDue.ToString("C");
            UpdatePurchaseButton();
        }
Exemplo n.º 18
0
 private void CalculateCommandExecute()
 {
     try
     {
         TotalPrice = 0d;
         if (Size == "Small")
         {
             TotalPrice += 12;
         }
         if (Size == "Medium")
         {
             TotalPrice += 15;
         }
         if (Size == "Large")
         {
             TotalPrice += 19;
         }
         double doughPrice = TotalPrice;
         Dictionary <string, double> ingredientPrices = GetIngredientPrices();
         Dictionary <string, bool>   ingredientList   = GetSelectedIngredients();
         List <string> ingredientBrakedown            = new List <string>();
         foreach (var ingredient in ingredientPrices)
         {
             if (ingredientList.ContainsKey(ingredient.Key))
             {
                 TotalPrice += ingredient.Value;
                 ingredientBrakedown.Add(string.Format($"\n{ingredient.Key}: ${ingredient.Value}"));
             }
         }
         TotalPrice = Convert.ToDouble(TotalPrice.ToString("#.##"));
         StringBuilder priceBrakedown = new StringBuilder();
         priceBrakedown.Append("**********************\n");
         priceBrakedown.Append($"Item: Pizza - {Size}");
         priceBrakedown.Append($"\nTotal Price: ${TotalPrice}");
         priceBrakedown.Append("\n**********************");
         priceBrakedown.Append($"\nPizza dough: ${doughPrice}");
         foreach (var ingredient in ingredientBrakedown)
         {
             priceBrakedown.Append(ingredient);
         }
         priceBrakedown.Append("\n**********************");
         FiscalBill = priceBrakedown.ToString();
         IsEnabled  = false;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Exemplo n.º 19
0
        private void MyBind()
        {
            M_UserInfo mu = SnsHelper.GetLogin();

            //B_Cart.UpdateUidByCartID(CartCookID, mu);
            CartDT = SelByCartID(CartCookID, 0, ProClass); //从数据库中获取
            if (StoreID != -100)                           //仅显示指定商铺的商品
            {
                CartDT.DefaultView.RowFilter = "StoreID=" + StoreID;
                CartDT = CartDT.DefaultView.ToTable();
            }
            RPT.DataSource = orderCom.SelStoreDT(CartDT);
            RPT.DataBind();
            totalmoney.InnerText = TotalPrice.ToString("F2");
        }
Exemplo n.º 20
0
        public void PrintOrderSummary()
        {
            Console.WriteLine("\n===========================================\n");
            Console.WriteLine("\t\tORDER SUMMARY");
            Console.WriteLine("\n===========================================\n");

            Console.WriteLine("Total coffees ordered:\t" + BeverageList.Count() + "\n\n");
            for (int orderItem = 0; orderItem < BeverageList.Count(); orderItem++)
            {
                _newCoffee = (Coffee)BeverageList[orderItem];
                Console.WriteLine("\n\n-------------------------------------------");
                Console.WriteLine("Order Item #" + (orderItem + 1));
                Console.WriteLine("-------------------------------------------\n");
                _newCoffee.PrintSummary();
            }

            Console.WriteLine("\n===========================================\n");
            Console.WriteLine("ORDER TOTAL:\t" + TotalPrice.ToString("C") + "\n\n");
        }
Exemplo n.º 21
0
        private void dgvGRN_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvGRN.Columns[e.ColumnIndex] == clmbtnDelete)
            {
                int index = dgvGRN.Rows.Count - 1;

                if (index == 0)
                {
                    int id = Convert.ToInt32(dgvGRN.Rows[dgvGRN.CurrentCell.RowIndex].Cells[clmItemID1.Name].Value);

                    GlobalSelectedItemList.RemoveAll(x => x.intItemID == id);

                    dgvGRN.DataSource = GlobalSelectedItemList.ToList();


                    decimal DiscountedVal = 0;;
                    decimal TotalPrice    = 0;
                    TotalPrice    = TotalPrice - DiscountedVal;
                    lblTotal.Text = TotalPrice.ToString("#,##0.00");

                    CalculateDiscountedPrice();
                }
                else
                {
                    int id = Convert.ToInt32(dgvGRN.Rows[dgvGRN.CurrentCell.RowIndex].Cells[clmItemID1.Name].Value);

                    decimal DiscountedVal = Convert.ToDecimal(dgvGRN.Rows[dgvGRN.CurrentCell.RowIndex].Cells[clmDiscountedValue.Name].Value);
                    TotalPrice    = TotalPrice - DiscountedVal;
                    lblTotal.Text = TotalPrice.ToString("#,##0.00");

                    GlobalSelectedItemList.RemoveAll(x => x.intItemID == id);

                    dgvGRN.DataSource = GlobalSelectedItemList.ToList();

                    CalculateDiscountedPrice();
                }
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Overide the ToString() method;
        /// To generate the details(Receipt) of this order;
        /// </summary>
        /// <returns>A string description for this order</returns>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            // Order Number
            sb.AppendLine("订单编号: " + OrderNumber);
            sb.AppendLine();

            // Order items
            foreach (OrderItem item in CartItemList)
            {
                sb.AppendLine(item.ToString());
            }
            sb.AppendLine();

            // Price, tax and discount for the order
            sb.AppendLine("价格: " + NetPrice.ToString("C2", CultureInfo.CreateSpecificCulture("en-NZ")));
            sb.AppendLine("邮费: " + TaxPrice.ToString("C2", CultureInfo.CreateSpecificCulture("en-NZ")));
            sb.AppendLine("折扣: -" + DiscountedTotalPrice.ToString("C2", CultureInfo.CreateSpecificCulture("en-NZ")));
            sb.AppendLine("总计价格: " + TotalPrice.ToString("C2", CultureInfo.CreateSpecificCulture("en-NZ")));

            return(sb.ToString());
        }
        public override string ToString()
        {
            string orderResults = "";

            orderResults += CustomerName + ": " + items.Count;
            if (items.Count > 1)
            {
                orderResults += " items.";
            }
            else
            {
                orderResults += " item.";
            }
            orderResults += "\nTotal Price: " + TotalPrice.ToString("C");
            if (Address != null)
            {
                orderResults += "\nShip to:\n" + Address;
            }
            else
            {
                orderResults += "\nLocal Pickup";
            }
            return(orderResults);
        }
Exemplo n.º 24
0
 public override string ToString() => $"Offer with total price: {TotalPrice.ToString()}";
Exemplo n.º 25
0
        public ViewResult makePayment(PaymentInformation cardInfo)
        {
            try
            {
                Stripe.StripeConfiguration.SetApiKey("sk_test_51HqI05B1UsJ4lZg1agboQSE7i0fWn98619xc2FP5NhREH4igqo1AlKTQO8VWMfsQBUs1OlXNBzBkOqORRQP6ZlPf00E2l0QVhL");



                Stripe.CreditCardOptions card = new Stripe.CreditCardOptions();
                card.Name     = cardInfo.CardOwnerFirstName + " " + cardInfo.CardOwnerLastName;
                card.Number   = cardInfo.CardNumber;
                card.ExpYear  = cardInfo.ExpirationYear;
                card.ExpMonth = cardInfo.ExpirationMonth;
                card.Cvc      = cardInfo.CVV2;

                Console.WriteLine(TotalPrice.ToString());


                Stripe.TokenCreateOptions token = new Stripe.TokenCreateOptions();
                token.Card = card;
                Stripe.TokenService serviceToken = new Stripe.TokenService();
                Stripe.Token        newToken     = serviceToken.Create(token);

                Stripe.CustomerCreateOptions myCustomer = new Stripe.CustomerCreateOptions();
                myCustomer.Email       = cardInfo.Buyer_Email;
                myCustomer.SourceToken = newToken.Id;
                var             customerService = new Stripe.CustomerService();
                Stripe.Customer stripeCustomer  = customerService.Create(myCustomer);

                var t = TempData["totalCost"];


                int    t1 = (int)Math.Round(Convert.ToDouble(t)) - 1;
                string total;
                string input_decimal_number = t.ToString();

                var regex = new System.Text.RegularExpressions.Regex("(?<=[\\.])[0-9]+");
                if (regex.IsMatch(input_decimal_number))
                {
                    string decimal_places = regex.Match(input_decimal_number).Value;
                    total = t1.ToString() + decimal_places;
                }
                else
                {
                    total = t1 + "00";
                }


                System.Diagnostics.Trace.WriteLine(t1.ToString());


                var options = new Stripe.ChargeCreateOptions
                {
                    Amount       = Convert.ToInt32(total),
                    Currency     = "USD",
                    ReceiptEmail = cardInfo.Buyer_Email,
                    CustomerId   = stripeCustomer.Id,
                };



                var           service = new Stripe.ChargeService();
                Stripe.Charge charge  = service.Create(options);


                return(View("Thanks"));
            }
            catch (StripeException e)
            {
                switch (e.StripeError.ErrorType)
                {
                case "card_error":

                    error = (" Error Message: " + e.StripeError.Message);
                    break;

                case "api_connection_error":
                    break;

                case "api_error":
                    break;

                case "authentication_error":
                    break;

                case "invalid_request_error":
                    break;

                case "rate_limit_error":
                    break;

                case "validation_error":
                    break;

                default:
                    // Unknown Error Type
                    break;
                }
                ViewBag.Greeting = error;
                return(View("Error"));
            }
        }
Exemplo n.º 26
0
        public decimal PromptForPayment()
        {
            _prompt.Message = "\n" +
                              "Please pay for your order using " + PaymentType.ToLower() + ". Enter the amount to pay:";

            //Get input and trim any $ symbol, the user might have specified.
            string userResponse = Prompt.CleanCurrencyInput(_prompt.GetUserInput());


            while (!decimal.TryParse(userResponse, out decimal num) || Convert.ToDecimal(userResponse) < TotalPrice) // while not a decimal value that is at least the amount requested
            {
                // Validate Payment (did they give enough money?)
                if (decimal.TryParse(userResponse, out num) && (Convert.ToDecimal(userResponse) < TotalPrice))
                {
                    _prompt.Message = "Inadequate amount received. You are " + (TotalPrice - Convert.ToDecimal(userResponse)).ToString("C") + " short. Please pay the full amount: " + TotalPrice.ToString("C");
                }
                else
                {
                    _prompt.Message = "That is not a valid numeric response. Please enter a number:";
                }

                //Get input and trim any $ symbol, the user might have specified.
                userResponse = Prompt.CleanCurrencyInput(_prompt.GetUserInput());
            }
            return(Convert.ToDecimal(userResponse));
        }
Exemplo n.º 27
0
        private void Show()
        {
            string sql = " 1=1 ";

            if (txtFrom.Text != "")
            {
                if (CommHelp.VerifesToDateTime(txtFrom.Text.Trim()) == false)
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('申请日期 格式错误!');</script>");
                    return;
                }
                sql += string.Format(" and AppTime>='{0} 00:00:00'", txtFrom.Text);
            }

            if (txtTo.Text != "")
            {
                if (CommHelp.VerifesToDateTime(txtTo.Text.Trim()) == false)
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('申请日期 格式错误!');</script>");
                    return;
                }
                sql += string.Format(" and AppTime<='{0} 23:59:59'", txtTo.Text);
            }


            if (txtUseFromTime.Text != "")
            {
                if (CommHelp.VerifesToDateTime(txtUseFromTime.Text.Trim()) == false)
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('使用日期 格式错误!');</script>");
                    return;
                }
                sql += string.Format(" and useDate>='{0} 00:00:00'", txtUseFromTime.Text);
            }

            if (txtUseToTime.Text != "")
            {
                if (CommHelp.VerifesToDateTime(txtUseToTime.Text.Trim()) == false)
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('使用日期 格式错误!');</script>");
                    return;
                }
                sql += string.Format(" and useDate<='{0} 23:59:59'", txtUseToTime.Text);
            }


            if (txtGuestName.Text.Trim() != "")
            {
                sql += string.Format(" and TB_UseCarDetail.GuestName like '%{0}%'", txtGuestName.Text.Trim());
            }


            if (txtDriver.Text != "")
            {
                sql += string.Format(" and Driver like '%{0}%'", txtDriver.Text);
            }

            if (txtAppName.Text != "")
            {
                sql += string.Format(" and LoginName like '%{0}%'", txtAppName.Text);
            }

            if (txtPONo.Text.Trim() != "")
            {
                if (CheckPoNO(txtPONo.Text.Trim()) == false)
                {
                    return;
                }
                sql += string.Format(" and TB_UseCarDetail.PONo like '%{0}%'", txtPONo.Text.Trim());
            }
            if (ddlCompany.Text != "-1")
            {
                string where = string.Format(" CompanyCode='{0}'", ddlCompany.Text.Split(',')[2]);
                sql         += string.Format(" and exists(select id from CG_POOrder where  IFZhui=0 and CG_POOrder.PONo=TB_UseCarDetail.PONo and AE IN(select LOGINNAME from tb_User where {0}))", where);
            }

            if (ddlCarNo.Text != "")
            {
                sql += string.Format(" and CarNo like '%{0}%'", ddlCarNo.Text);
            }
            if (txtProNo.Text.Trim() != "")
            {
                if (CheckProNo(txtProNo.Text) == false)
                {
                    return;
                }
                sql += string.Format(" and TB_UseCarDetail.ProNo like '%{0}%'", txtProNo.Text.Trim());
            }



            if (ddlIsSpecial.Text != "-1")
            {
                sql += " and IsSpecial=" + ddlIsSpecial.Text;
            }

            if (ddlClose.Text != "-1")
            {
                sql += " and IsClose=" + ddlClose.Text;
            }

            if (ddlIsSelect.Text != "-1")
            {
                sql += " and IsSelected=" + ddlIsSelect.Text;
            }
            if (ddlGuestTypeList.Text != "全部")
            {
                sql += string.Format(" and CG_POOrder.GuestType='{0}'", ddlGuestTypeList.Text);
            }
            if (ddlGuestProList.Text != "-2")
            {
                sql += " and CG_POOrder.GuestPro=" + ddlGuestProList.Text;
            }
            if (ddlModel.Text != "全部")
            {
                sql += string.Format(" and Model='{0}'", ddlModel.Text);
            }
            if (ddlJieIsSelected.Text != "-1")
            {
                sql += " and JieIsSelected=" + ddlJieIsSelected.Text;
            }


            if (ddlUser.Text == "-1")//显示所有用户
            {
            }
            else if (ddlUser.Text == "0")//显示部门信息
            {
                var model = Session["userInfo"] as User;
                sql += string.Format(" and CG_POOrder.AE in (select loginName from tb_User where 1=1 and loginName<>'admin' and loginStatus<>'离职' and loginIPosition<>'' and loginIPosition='{0}')", model.LoginIPosition);
            }
            else
            {
                sql += string.Format(" and CG_POOrder.AE='{0}'", ddlUser.SelectedItem.Text);
            }

            sql += string.Format(@" and TB_UseCarDetail.id in (select allE_id from tb_EForm where proId in (
select pro_Id from A_ProInfo where pro_Type='用车明细表') and state='通过')");
            decimal Total = 0;
            decimal TotalPrice;
            List <TB_UseCarDetail> UseCarServices = this.useCarSer.GetListArrayReps_1(sql, out Total, out TotalPrice);

            lblTotal.Text            = Total.ToString();
            lblTotalPrice.Text       = TotalPrice.ToString();
            AspNetPager1.RecordCount = UseCarServices.Count;
            this.gvList.PageIndex    = AspNetPager1.CurrentPageIndex - 1;
            this.gvList.DataSource   = UseCarServices;
            this.gvList.DataBind();
        }
Exemplo n.º 28
0
        public async Task <IActionResult> OnGet()
        {
            //ApplicationUser = await userManager.GetUserAsync(User);
            //if (ApplicationUser != null)
            //{
            //    if (ApplicationUser.IsMember)
            //    {
            //        var membership = membershipData.GetMembershipById(ApplicationUser.MembershipId.Value);
            //        ApplicationUser.Membership = membership;
            //    }


            //    if (HttpContext.Session.GetObjectFromJson<List<ShoppingCart>>("CartItems") != null)
            //    {
            //        CartItems = HttpContext.Session.GetObjectFromJson<List<ShoppingCart>>("CartItems").ToList();


            //        if (ApplicationUser.IsMember)
            //        {

            //            TotalPrice = cartBL.TotalPrice(CartItems, ApplicationUser.Membership.Discount);
            //        }
            //        else
            //        {
            //            TotalPrice = cartBL.TotalPrice(CartItems, 0);
            //        }
            //    }

            //    HttpContext.Session.SetString("TotalPrice", TotalPrice.ToString());
            //}
            //CartItems = HttpContext.Session.GetObjectFromJson<List<ShoppingCart>>("CartItems").ToList();

            //return Page();


            if (HttpContext.Session.GetObjectFromJson <List <ShoppingCart> >("CartItems") != null)
            {
                CartItems       = HttpContext.Session.GetObjectFromJson <List <ShoppingCart> >("CartItems").ToList();
                ApplicationUser = await userManager.GetUserAsync(User);

                if (ApplicationUser != null)
                {
                    if (ApplicationUser.IsMember)
                    {
                        var membership = membershipData.GetMembershipById(ApplicationUser.MembershipId.Value);
                        ApplicationUser.Membership = membership;
                        TotalPrice = cartBL.TotalPrice(CartItems, ApplicationUser.Membership.Discount);
                    }
                    else
                    {
                        TotalPrice = cartBL.TotalPrice(CartItems, 0);
                    }
                }
                else
                {
                    TotalPrice = cartBL.TotalPrice(CartItems, 0);
                }
                HttpContext.Session.SetString("TotalPrice", TotalPrice.ToString());
            }
            return(Page());
        }
Exemplo n.º 29
0
 public string GetFormattedTotalPrice()
 => TotalPrice.ToString("0.00");
Exemplo n.º 30
0
 public void UpdateTotalPrice()
 {
     TotalPrice       = ShoppingCart.TotalPrice;
     TotalPriceString = $"{TotalPrice.ToString()} kr.";
 }