コード例 #1
0
ファイル: OrdersView.cs プロジェクト: qhtml5/X-O-Genesis
        public bool queryProduct()
        {
            bool success = false;

            try
            {
                barcode = txtEncode.Text;
                int quantity = 1;

                if (string.IsNullOrWhiteSpace(txtQuantity.Text))
                {
                    MessageBox.Show("Please enter quantity");
                }
                else
                {
                    quantity = int.Parse(txtQuantity.Text);
                }

                currentProduct = dbController.getProductFromBarcode(barcode);
                int stock = dbController.getCurrentStockCountFromBarCode(currentProduct);
                if (stock >= quantity)
                {
                    if (!string.IsNullOrWhiteSpace(currentProduct.Barcode))
                    {
                        Decimal totalPrice = currentProduct.UnitPrice * quantity;
                        lblPOSmsg.Text = String.Format("{0} x{1} @{2}", currentProduct.Description, quantity, totalPrice);
                        success        = true;
                        addRowInDatagrid(quantity);
                    }
                    else
                    {
                        lblPOSmsg.Text = "Item not found";
                    }
                }
                else
                {
                    MessageBox.Show("Out of stock. Only " + stock + " left");
                }
            }
            catch (Exception) { lblPOSmsg.Text = "Item not found"; }

            return(success);
        }