public bool queryProduct() { bool success = false; string 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); 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"; } return(success); }
void dbController_InsertEntity(object sender, EntityArgs e) { fillgdInventory(); IEntity entity = e.Entity; string nameField = string.Empty, message = string.Empty, action = string.Empty, petsize = string.Empty; if (entity is Product) { Product p = entity as Product; nameField = p.Description; message = string.Format("New product: {0} has been added", nameField); action = string.Format("has added a new product", nameField); } else if (entity is Inventory) { Inventory i = entity as Inventory; Product p = dbController.getProductFromBarcode(i.Barcode); nameField = p.Description; message = string.Format("New stock of product {0} has been added", nameField); action = string.Format("added a new stock of product", nameField); } MessageBanner banner = new MessageBanner(message, 2000); banner.Show(); dbController.insertAuditTrail(action); }
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); }
bool checkIfProductAlreadyExists(string barcode) { product = dbController.getProductFromBarcode(barcode); if (!string.IsNullOrEmpty(product.Barcode)) { return(true); } return(false); }