I am getting issue while tab reach to next new row after loading data from database.
Can anyone please correct the code
- private void dataGridSALEITEM_CellValueChanged(object sender, DataGridViewCellEventArgs e) {
- decimal TOTALAMOUNT = 0;
- decimal TOTALCGST = 0;
- decimal TOTALSGST = 0;
- decimal NETTOTAL = 0;
- foreach(DataGridViewRow row in dataGridSALEITEM.Rows) {
- row.Cells[dataGridSALEITEM.Columns[7].Index].Value = (Convert.ToInt32(row.Cells[dataGridSALEITEM.Columns[3].Index].Value) * Convert.ToInt32(row.Cells[dataGridSALEITEM.Columns[4].Index].Value));
- row.Cells[dataGridSALEITEM.Columns[8].Index].Value = (Convert.ToInt32(row.Cells[dataGridSALEITEM.Columns[7].Index].Value) / 200 * Convert.ToInt32(row.Cells[dataGridSALEITEM.Columns[5].Index].Value));
- row.Cells[dataGridSALEITEM.Columns[9].Index].Value = (Convert.ToInt32(row.Cells[dataGridSALEITEM.Columns[7].Index].Value) / 200 * Convert.ToInt32(row.Cells[dataGridSALEITEM.Columns[5].Index].Value));
- row.Cells[dataGridSALEITEM.Columns[10].Index].Value = (Convert.ToInt32(row.Cells[dataGridSALEITEM.Columns[7].Index].Value) + Convert.ToInt32(row.Cells[dataGridSALEITEM.Columns[8].Index].Value) + Convert.ToInt32(row.Cells[dataGridSALEITEM.Columns[9].Index].Value));
- TOTALAMOUNT += Convert.ToDecimal(row.Cells[dataGridSALEITEM.Columns[7].Index].Value);
- TOTALCGST += Convert.ToDecimal(row.Cells[dataGridSALEITEM.Columns[8].Index].Value);
- TOTALSGST += Convert.ToDecimal(row.Cells[dataGridSALEITEM.Columns[9].Index].Value);
- NETTOTAL += Convert.ToDecimal(row.Cells[dataGridSALEITEM.Columns[10].Index].Value);
- }
- txtSUBTOTAL.Text = TOTALAMOUNT.ToString();
- txtCGST.Text = TOTALCGST.ToString();
- txtSGST.Text = TOTALSGST.ToString();
- txtGTOTAL.Text = NETTOTAL.ToString();
- }