private void txtProductDiscount_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (order.VERIFYQTY(txtProductID.Text, Convert.ToInt32(txtProductQTE.Text)).Rows.Count < 1) { MessageBox.Show("الكميه المدخله لهذا المنتج غير متاحه", "اضافه الاصناف", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // this for check if this product found or not for (int i = 0; i < DGVNEWOrders.Rows.Count - 1; i++) { if (DGVNEWOrders.Rows[i].Cells[0].Value.ToString() == txtProductID.Text) { MessageBox.Show("تم اضافه هذا الصنف من قبل", "اضافه الاصناف", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } DataRow r = dt.NewRow(); r[0] = txtProductID.Text; r[1] = txtProductName.Text; r[2] = txtProductPrice.Text; r[3] = txtProductQTE.Text; r[4] = txtProductQTEPrice.Text; r[5] = txtProductDiscount.Text; r[6] = txtProductTotal.Text; dt.Rows.Add(r); DGVNEWOrders.DataSource = dt; ClearBoxes(); btnProductSearch.Focus(); txtOrderSUM.Text = (from DataGridViewRow row in DGVNEWOrders.Rows where row.Cells[6].FormattedValue.ToString() != String.Empty select Convert.ToDouble(row.Cells[6].FormattedValue)).Sum().ToString(); } }