scannedBarcode = textBoxScanBarcode.Text; string query = "SELECT Pid,Pname,ScQty As Qty,Price,Discount As Disc_Limit,ActualDiscount, Price As Sub_Total,Percentage,Barcode FROM products,CostAndPrice WHERE products.Pid=CostAndPrice.Fpid AND Barcode='" + scannedBarcode + "'"; dbObject.readDatathroughAdapter(query, dtScannedProduct); //Boolean to check if he has row has been bool Found = false; if (dataGridViewPurchasedItems.Rows.Count > 0) { //Check if the product Id exists with the same Price foreach (DataGridViewRow row in dataGridViewPurchasedItems.Rows) { if (Convert.ToString(row.Cells[9].Value) == scannedBarcode) { //Update the Quantity of the found row row.Cells[3].Value = Convert.ToString(1 + Convert.ToInt16(row.Cells[3].Value)); Found = true; } } if (!Found) { //Add the row to grid view dataGridViewPurchasedItems.DataSource = dtScannedProduct; } } else { //Add the row to grid view for the first time dataGridViewPurchasedItems.DataSource = dtScannedProduct; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)