private void ExportNumberTxt_TargetUpdated(object sender, DataTransferEventArgs e) { if (im.SourceTransaction == "Sales Order") { HavestorCbo.Focus(); } else { BarcodeTxt.Focus(); } }
private void BarcodeTxt_Validating(object sender, CancelEventArgs e) { if (BarcodeTxt.Text != "") { GrossTxt.Text = ""; TotDiscountTxt.Text = ""; AmountGiveTxt.Text = ""; ChangeGiveTxt.Text = ""; prodArr = r.getProductByBarcodeList(BarcodeTxt.Text); if (prodArr[0] != null) { if (prodArr[3].Length != 0) { productID = Convert.ToInt64(prodArr[0]); int quanCount = 0; int Quantity = 0; int newCount = 0; foreach (DataGridViewRow row in SalesdataGridView.Rows) { if (prodArr[0] == row.Cells["ProductIDGV"].Value.ToString()) { quanCount = quanCount + Convert.ToInt32(row.Cells["QuantityGV"].Value.ToString()); } } Quantity = Convert.ToInt32(r.getProductQuantity(productID)); newCount = Quantity - quanCount; if (newCount <= 0) { MainClass.ShowMSG(" no stock left now", "Alert", "Alert"); BarcodeTxt.Text = ""; BarcodeTxt.Focus(); } else { if (SalesdataGridView.RowCount == 0) { SalesdataGridView.Rows.Add(productID, prodArr[1], 1, Convert.ToSingle(prodArr[3]), prodArr[4], Convert.ToSingle(prodArr[3])); } else { foreach (DataGridViewRow row in SalesdataGridView.Rows) { if (row.Cells["ProductIDGV"].Value.ToString() == productID.ToString()) { productCheck = true; break; } else { productCheck = false; } } if (productCheck == true) { foreach (DataGridViewRow row in SalesdataGridView.Rows) { if (row.Cells["ProductIDGV"].Value.ToString() == productID.ToString()) { int quan = Convert.ToInt32(row.Cells["QuantityGV"].Value.ToString()); quan += 1; tot = Convert.ToSingle(row.Cells["PerUnitGV"].Value.ToString()) * quan; row.Cells["QuantityGV"].Value = quan; if (row.Cells["DiscountGV"].Value.ToString() != null) { //discount = Convert.ToSingle(row.Cells["DiscountGV"].Value.ToString()) * Convert.ToSingle(row.Cells["QuantityGV"].Value.ToString()); discount = Convert.ToSingle(row.Cells["DiscountGV"].Value.ToString()) + Convert.ToSingle(prodArr[4]); row.Cells["DiscountGV"].Value = Math.Round(discount, 2); } row.Cells["TotGV"].Value = Math.Round(tot, 2); } } } else { SalesdataGridView.Rows.Add(productID, prodArr[1], 1, Convert.ToSingle(prodArr[3]), prodArr[4], Convert.ToSingle(prodArr[3])); } } foreach (DataGridViewRow row1 in SalesdataGridView.Rows) { gt += Convert.ToSingle(row1.Cells["TotGV"].Value.ToString()); } GrossLbl.Text = Math.Round(gt, 2).ToString(); gt = 0; BarcodeTxt.Text = ""; BarcodeTxt.Focus(); } } else { MainClass.ShowMSG("Product Price is not set for this product choose other one", "Error", "Error"); BarcodeTxt.Text = ""; BarcodeTxt.Focus(); } } else { BarcodeTxt.Text = ""; BarcodeTxt.Focus(); } } }