Beispiel #1
0
        void updateProductTransaction(string name, int transaction_id, int qty, decimal grp_price)
        {
            Product product     = dbController.getProductThroughName(name);
            Invoice transaction = new Invoice()
            {
                InvoiceId = transaction_id,
            };

            ProductInvoice productInvoice = new ProductInvoice()
            {
                product      = product,
                invoice      = transaction,
                QuantitySold = -qty,
                GroupPrice   = grp_price,
            };

            int quantity = 0;

            if (int.TryParse(getValueFromDatagridCell(2), out quantity))
            {
                if (qty > quantity)
                {
                    return;
                }
            }

            dbController.insertProductInvoice(productInvoice);
        }
 public bool checkIfAlreadyConsumed(ProductInvoice productInvoice)
 {
     object foo = readScalar("id", string.Format("invoice_id = {0} AND consumed= 1", productInvoice.invoice.InvoiceId));
     if (foo != null)
         return true;
     else
         return false;
 }
Beispiel #3
0
        public void addRowInDatagrid(ProductInvoice productInvoice)
        {
            var row = dt.NewRow();

            row["Product"]    = currentProduct.Description;
            row["Quantity"]   = productInvoice.QuantitySold;
            row["Unit price"] = currentProduct.UnitPrice.ToString("N");
            row["Net price"]  = productInvoice.GroupPrice.ToString("N");
            dt.Rows.Add(row);
        }
        public bool checkIfAlreadyConsumed(ProductInvoice productInvoice)
        {
            object foo = readScalar("id", string.Format("invoice_id = {0} AND consumed= 1", productInvoice.invoice.InvoiceId));

            if (foo != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #5
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);
        }
Beispiel #6
0
        void updateProductTransaction(string name, int transaction_id, int qty, decimal grp_price)
        {
            Product product     = dbController.getProductThroughName(name);
            Invoice transaction = new Invoice()
            {
                InvoiceId = transaction_id,
            };

            ProductInvoice productInvoice = new ProductInvoice()
            {
                product      = product,
                invoice      = transaction,
                QuantitySold = -qty,
                GroupPrice   = grp_price,
            };

            dbController.insertProductInvoice(productInvoice);
        }
Beispiel #7
0
 public void addRowInDatagrid(ProductInvoice productInvoice)
 {
     var row = dt.NewRow();
     row["Product"] = currentProduct.Description;
     row["Quantity"] = productInvoice.QuantitySold;
     row["Unit price"] = currentProduct.UnitPrice.ToString("N");
     row["Net price"] = productInvoice.GroupPrice.ToString("N");
     dt.Rows.Add(row);
 }
        void updateProductTransaction(string name, int transaction_id, int qty, decimal grp_price)
        {
            Product product = dbController.getProductThroughName(name);
            Invoice transaction = new Invoice()
            {
                InvoiceId = transaction_id,
            };

            ProductInvoice productInvoice = new ProductInvoice()
            {
                product = product,
                invoice = transaction,
                QuantitySold = -qty,
                GroupPrice = grp_price,
            };

            dbController.insertProductInvoice(productInvoice);
        }
Beispiel #9
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;
        }
Beispiel #10
0
        void updateProductTransaction(string name, int transaction_id, int qty, decimal grp_price)
        {

            Product product = dbController.getProductThroughName(name);
            Invoice transaction = new Invoice()
            {
                InvoiceId = transaction_id,
            };

            ProductInvoice productInvoice = new ProductInvoice()
            {
                product = product,
                invoice = transaction,
                QuantitySold = -qty,
                GroupPrice = grp_price,
            };

            int quantity = 0;
            if (int.TryParse(getValueFromDatagridCell(2), out quantity))
            {
                if (qty > quantity)
                    return;
            }

            dbController.insertProductInvoice(productInvoice);

        }
 public bool insertProductInvoice(ProductInvoice productInvoice)
 {
     return productInvoiceMapper.insertProductInvoice(productInvoice);
 }
Beispiel #12
0
 public bool consumeProductInvoice(ProductInvoice productInvoice)
 {
     return(productInvoiceMapper.consumeProductInvoice(productInvoice));
 }
Beispiel #13
0
 public bool checkIfAlreadyConsumed(ProductInvoice productInvoice)
 {
     return(productInvoiceMapper.checkIfAlreadyConsumed(productInvoice));
 }
        public bool consumeProductInvoice(ProductInvoice productInvoice)
        {
            string condition = string.Format("invoice_id = {0}", productInvoice.invoice.InvoiceId);

            return(update(updateSet(condition, "consumed = 1")));
        }
 public bool insertProductInvoice(ProductInvoice productInvoice)
 {
     return(productInvoiceMapper.insertProductInvoice(productInvoice));
 }
 public bool insertProductInvoice(ProductInvoice productInvoice)
 {
     return(insertProductInvoice(productInvoice.invoice, productInvoice.product, productInvoice.QuantitySold));
 }
 public bool checkIfAlreadyConsumed(ProductInvoice productInvoice)
 {
     return productInvoiceMapper.checkIfAlreadyConsumed(productInvoice);
 }
 public bool consumeProductInvoice(ProductInvoice productInvoice)
 {
     return productInvoiceMapper.consumeProductInvoice(productInvoice);
 }
Beispiel #19
0
        public void addRowInDatagrid(int quantity)
        {
            ProductInvoice productTransaction = new ProductInvoice(){
                invoice = currentTransaction,
                product = currentProduct,
                QuantitySold = quantity,
                GroupPrice = (currentProduct.UnitPrice * quantity),
            };

            bool items_already_in_cart = false;
            int sum_of_qty = 0;
            decimal sum_of_price = 0M;

            foreach (ProductInvoice item in carts){
                if (item.product.Barcode == productTransaction.product.Barcode){
                    int old_qty = item.QuantitySold;
                    int new_qty = productTransaction.QuantitySold;
                    sum_of_qty = old_qty + new_qty;
                    item.QuantitySold = sum_of_qty;

                    decimal old_price = item.GroupPrice;
                    decimal new_price = productTransaction.GroupPrice;
                    sum_of_price = old_price + new_price;
                    item.GroupPrice = sum_of_price;

                    items_already_in_cart = true;
                    break;
                }
            }

            if (!items_already_in_cart){
                carts.Add(productTransaction);
                try{
                    var row = dt.NewRow();
                    row["Product"] = currentProduct.Description;
                    row["Quantity"] = quantity;
                    row["Price"] = productTransaction.GroupPrice;
                    dt.Rows.Add(row);
                }
                catch (Exception ex){
                    MessageBox.Show(ex.Message);
                }
                lblPOSmsg.Text = String.Format("{0} x{1} @{2}", currentProduct.Description, quantity, productTransaction.GroupPrice);
            }
            else{
                try{
                    foreach (DataGridViewRow row in dgTransaction.Rows){
                        if (row.Cells[DESCRIPTION_INDEX].Value.ToString() == productTransaction.product.Description){
                            row.Cells[QTY_INDEX].Value = sum_of_qty;
                            row.Cells[PRICE_INDEX].Value = sum_of_price;
                            break;
                        }
                    }
                }
                catch (Exception)
                {

                }
                lblPOSmsg.Text = String.Format("{0} x{1} @{2}", currentProduct.Description, sum_of_qty, sum_of_price);
            }

            totalAmount += productTransaction.GroupPrice;
            poSlbl2.Text = totalAmount.ToString();
            txtEncode.Clear();
            txtQuantity.Clear();
            txtQuantity.Focus();
        }
 public bool insertProductInvoice(ProductInvoice productInvoice)
 {
     return insertProductInvoice(productInvoice.invoice, productInvoice.product, productInvoice.QuantitySold);
 }
Beispiel #21
0
        public void addRowInDatagrid(int quantity)
        {
            ProductInvoice productTransaction = new ProductInvoice()
            {
                invoice      = currentTransaction,
                product      = currentProduct,
                QuantitySold = quantity,
                GroupPrice   = (currentProduct.UnitPrice * quantity),
            };

            bool    items_already_in_cart = false;
            int     sum_of_qty            = 0;
            decimal sum_of_price          = 0M;

            foreach (ProductInvoice item in carts)
            {
                if (item.product.Barcode == productTransaction.product.Barcode)
                {
                    int old_qty = item.QuantitySold;
                    int new_qty = productTransaction.QuantitySold;
                    sum_of_qty        = old_qty + new_qty;
                    item.QuantitySold = sum_of_qty;

                    decimal old_price = item.GroupPrice;
                    decimal new_price = productTransaction.GroupPrice;
                    sum_of_price    = old_price + new_price;
                    item.GroupPrice = sum_of_price;

                    items_already_in_cart = true;
                    break;
                }
            }

            if (!items_already_in_cart)
            {
                carts.Add(productTransaction);
                try{
                    var row = dt.NewRow();
                    row["Product"]  = currentProduct.Description;
                    row["Quantity"] = quantity;
                    row["Price"]    = productTransaction.GroupPrice;
                    dt.Rows.Add(row);
                }
                catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                }
                lblPOSmsg.Text = String.Format("{0} x{1} @{2}", currentProduct.Description, quantity, productTransaction.GroupPrice);
            }
            else
            {
                try{
                    foreach (DataGridViewRow row in dgTransaction.Rows)
                    {
                        if (row.Cells[DESCRIPTION_INDEX].Value.ToString() == productTransaction.product.Description)
                        {
                            row.Cells[QTY_INDEX].Value   = sum_of_qty;
                            row.Cells[PRICE_INDEX].Value = sum_of_price;
                            break;
                        }
                    }
                }
                catch (Exception)
                {
                }
                lblPOSmsg.Text = String.Format("{0} x{1} @{2}", currentProduct.Description, sum_of_qty, sum_of_price);
            }

            totalAmount += productTransaction.GroupPrice;
            poSlbl2.Text = totalAmount.ToString();
            txtEncode.Clear();
            txtQuantity.Clear();
            txtQuantity.Focus();
        }
 public bool consumeProductInvoice(ProductInvoice productInvoice)
 {
     string condition = string.Format("invoice_id = {0}", productInvoice.invoice.InvoiceId);
     return update(updateSet(condition, "consumed = 1"));
 }