コード例 #1
0
        private void refreshSalesGridView(List <CartDisplay> cartList, bool isTransaction)
        {
            TextBox textBox;
            Label   label;

            //zero totals
            SubTotalLabel.Text = "0";
            TotalLabel.Text    = "0";
            TaxTotal.Text      = "0";
            foreach (GridViewRow row in CartGridView.Rows)
            {
                CartDisplay cartItemTemp = new CartDisplay();

                label = (Label)row.FindControl("CategoryID");
                cartItemTemp.CategoryID = int.Parse(label.Text);

                label = (Label)row.FindControl("ProductID");
                cartItemTemp.ProductID = int.Parse(label.Text);

                label = (Label)row.FindControl("ProductName");
                cartItemTemp.ProductName = label.Text;

                textBox = (TextBox)row.FindControl("ProductRowQuantity");
                textBox.Attributes.Add("readonly", "true");
                cartItemTemp.ProductQuantity = int.Parse(textBox.Text);

                label = (Label)row.FindControl("PriceLabel");
                cartItemTemp.ProductPrice = Double.Parse(label.Text, System.Globalization.NumberStyles.Currency);

                cartList.Add(cartItemTemp);
                updateTotals(cartItemTemp);
            }
        }
コード例 #2
0
        private void refreshSalesGridView(List <CartDisplay> cartList)
        {
            TextBox textBox;
            Label   label;
            int     userInput;
            double  userInputDouble;

            //zero totals
            SubTotalLabel.Text = "0";
            TotalLabel.Text    = "0";
            TaxTotal.Text      = "0";
            foreach (GridViewRow row in CartGridView.Rows)
            {
                CartDisplay cartItemTemp = new CartDisplay();

                label = (Label)row.FindControl("CategoryID");
                cartItemTemp.CategoryID = int.Parse(label.Text);

                label = (Label)row.FindControl("ProductID");
                cartItemTemp.ProductID = int.Parse(label.Text);

                label = (Label)row.FindControl("ProductName");
                cartItemTemp.ProductName = label.Text;

                textBox = (TextBox)row.FindControl("ProductRowQuantity");
                if (int.TryParse(textBox.Text, out userInput) && userInput > 0)
                {
                    cartItemTemp.ProductQuantity = userInput;
                }
                else if (double.TryParse(textBox.Text, out userInputDouble) && userInputDouble > 0.0)
                {
                    cartItemTemp.ProductQuantity = (int)userInputDouble;
                }
                else
                {
                    cartItemTemp.ProductQuantity = 1;
                }

                label = (Label)row.FindControl("PriceLabel");
                cartItemTemp.ProductPrice = Double.Parse(label.Text, System.Globalization.NumberStyles.Currency);

                cartList.Add(cartItemTemp);
                updateTotals(cartItemTemp);
            }
        }
コード例 #3
0
        async void OnListItemSelected(object sender, ItemTappedEventArgs e)
        {
            CartDisplay dataItem = e.Item as CartDisplay;

            //(e.Item as InventorySearch).ID_BRG;
            if (dataItem.NM_BRG != null)
            {
                string tes    = dataItem.ID_BRG;
                var    result = await OpenAlertDialog(dataItem.NOM, dataItem.NM_BRG);

                if (result != null)
                {
                    int hasil = await App.Database.DeleteRecCartAsync(dataItem.NOM.ToString());

                    hasil = await App.Database.UpdateStok(dataItem.ID_BRG, dataItem.QTY, "+");

                    RefreshLV();
                }
            }
        }
コード例 #4
0
        private void updateTotals(CartDisplay item)
        {
            double subtotal, tax, total;

            if (!(Double.TryParse(SubTotalLabel.Text, NumberStyles.Currency, CultureInfo.CurrentCulture, out subtotal)))
            {
                subtotal = 0;
            }
            if (!(Double.TryParse(TaxTotal.Text, NumberStyles.Currency, CultureInfo.CurrentCulture, out tax)))
            {
                tax = 0;
            }
            if (!(Double.TryParse(TotalLabel.Text, NumberStyles.Currency, CultureInfo.CurrentCulture, out total)))
            {
                total = 0;
            }
            subtotal += item.ExtendedAmount;
            tax      += subtotal * 0.05;
            total    += subtotal + tax;

            SubTotalLabel.Text = string.Format("{0:c2}", subtotal);
            TaxTotal.Text      = string.Format("{0:c2}", tax);
            TotalLabel.Text    = string.Format("{0:c2}", total);
        }
コード例 #5
0
        public int Do_CartTransaction(List <CartDisplay> cartItems)
        {
            if (cartItems.Count < 1)
            {
                throw new BusinessRuleException("Cart Error: ", new List <string> {
                    "No Items in Cart"
                });
            }
            else
            {
                using (var context = new RaceContext())
                {
                    double subtotal = 0;
                    double total    = 0;
                    double tax      = 0;
                    foreach (CartDisplay item in cartItems)
                    {
                        CartDisplay tempItem = context.Products
                                               .Where(x => x.ProductID == item.ProductID && x.CategoryID == item.CategoryID)
                                               .Select(x => new CartDisplay {
                        }).Single();
                        if (tempItem == null)
                        {
                            throw new BusinessRuleException("Product not in database", new List <String> {
                                item.ProductName
                            });
                        }
                    }
                    // update product quantities
                    foreach (CartDisplay item in cartItems)
                    {
                        subtotal += item.ExtendedAmount;
                        tax      += subtotal * 0.05;
                        total    += subtotal + tax;
                        Product temp = context.Products
                                       .Where(x => x.CategoryID == item.CategoryID && x.ProductID == item.ProductID)
                                       .Single();
                        temp.QuantityOnHand      -= item.ProductQuantity;
                        context.Entry(temp).State = System.Data.Entity.EntityState.Modified;
                    }
                    // Create invoice
                    Invoice invoice = new Invoice();
                    invoice.EmployeeID  = cartItems[0].EmployeeID;
                    invoice.GST         = (decimal)tax;
                    invoice.InvoiceDate = DateTime.Now;
                    invoice.SubTotal    = (decimal)subtotal;
                    invoice.Total       = (decimal)total;

                    invoice = context.Invoices.Add(invoice);

                    // Create invoice details
                    foreach (CartDisplay item in cartItems)
                    {
                        InvoiceDetail temp = new InvoiceDetail();
                        temp.InvoiceID = invoice.InvoiceID;
                        temp.ProductID = item.ProductID;
                        temp.Quantity  = item.ProductQuantity;
                        temp.Price     = (decimal)item.ProductPrice;
                        context.InvoiceDetails.Add(temp);
                    }
                    int test = context.SaveChanges();
                    return(invoice.InvoiceID);
                }
            }
        }