Esempio n. 1
0
        public bool queryProducts()
        {
            bool    success      = false;
            int     invoice_no   = 0;
            int     sum_of_qty   = 0;
            decimal sum_of_price = 0M;

            if (int.TryParse(txtEncode.Text, out invoice_no))
            {
                Invoice invoice = new Invoice()
                {
                    InvoiceId = invoice_no
                };

                ProductInvoice pI = new ProductInvoice()
                {
                    invoice = invoice
                };
                if (!dbController.checkIfAlreadyConsumed(pI))
                {
                    lblPOSmsg.Text = "PV-" + invoice.InvoiceId.ToString("00000");
                    carts          = dbController.getListOfProductInvoice(invoice);
                    int quantity = carts.Count;
                    dt.Clear();

                    foreach (ProductInvoice productInvoice in carts)
                    {
                        currentProduct = dbController.getProductFromBarcode(productInvoice.product.Barcode);
                        sum_of_qty    += productInvoice.QuantitySold;
                        sum_of_price  += productInvoice.GroupPrice;
                        addRowInDatagrid(productInvoice);
                    }

                    poSlbl2.Text = sum_of_price.ToString("N");
                    totalAmount  = sum_of_price;
                    success      = true;
                }
                else
                {
                    MessageBox.Show("Invoice transaction was already used or do not exist.");
                }
            }
            txtEncode.Clear();
            return(success);
        }