private void txtQty_KeyDown(object sender, KeyEventArgs e) { /* if (raOR.Checked == true) * { * if (e.KeyCode == Keys.Enter && txtQty.Text != string.Empty) * { * txtDescount.Focus(); * } * } */ if (e.KeyCode == Keys.Enter) { if (raOR.Checked == true) { if (order.VarifyQty(txtIDproduct.Text, Convert.ToInt32(txtQty.Text)).Rows.Count < 1) { MessageBox.Show("cadadkaan kuma jiro baqaarka", "baqaarka", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } for (int i = 0; i < dataGridView1.Rows.Count - 1; i++) { if (dataGridView1.Rows[i].Cells[0].Value.ToString() == txtIDproduct.Text) { MessageBox.Show("agabkaan waa ku jiraa liiska", "iska jir", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } if (raOR.Checked == true && state == "add") { DataRow r = Dt.NewRow(); r[0] = txtIDproduct.Text; r[1] = txtNameProduct.Text; r[2] = txtPrice.Text; r[3] = txtQty.Text; r[4] = txtAmount.Text; r[5] = lbcost.Text; //r[6] = txtTotalAmount.Text; Dt.Rows.Add(r); dataGridView1.DataSource = Dt; } else if (raOR.Checked == true && state == "update") { DataRow r1 = Dt1.NewRow(); r1[0] = txtIDproduct.Text; r1[1] = txtNameProduct.Text; r1[2] = txtPrice.Text; r1[3] = txtQty.Text; r1[4] = txtAmount.Text; r1[5] = lbcost.Text; // r1[6] = txtTotalAmount.Text; Dt1.Rows.Add(r1); dataGridView1.DataSource = Dt1; } else { DataRow r2 = Dt2.NewRow(); r2[0] = txtIDproduct.Text; r2[1] = txtNameProduct.Text; r2[2] = txtPrice.Text; r2[3] = txtQty.Text; r2[4] = txtAmount.Text; // r1[5] = lbcost.Text; // r1[6] = txtTotalAmount.Text; Dt2.Rows.Add(r2); dataGridView1.DataSource = Dt2; } ClearBoxes(); txtSumTotals.Text = (from DataGridViewRow row in dataGridView1.Rows where row.Cells[4].FormattedValue.ToString() != string.Empty select Convert.ToDouble(row.Cells[4].FormattedValue)).Sum().ToString(); } }