Weeman Osekre

Weeman Osekre

  • NA
  • 56
  • 3.4k

Data gridview operations

Nov 7 2020 9:25 AM
I working on a pos system , which at design time I have two datagridviews one which shows the searched product and one which shows the added products . The one which shows the added product has 6 columns 4 are bounded to a databondinging source and the other two are unbounded because they accept input from the user . So when the transection is done but the bill not paid and the table is reopened the gridview is not bounded to another data source . But the code I have to add rows (products) does not work any more it does add a new row . private void btnadd_Click(object sender, EventArgs e){for (int i = dataGridView1.RowCount - 1; i <= 0; i++){DataGridViewRow row = dataGridView1.Rows[i];if (Convert.ToBoolean(row.Cells["selectrow"].Value = true)){Formq pan = new Formq();pan.Show();string may = Formq.mark1;productBindingSource4.Add((Product)row.DataBoundItem);dataGridView2.Rows[dataGridView2.Rows.Count-1].Cells["quantity"].Value = may;int qu = Int32.Parse(dataGridView2.Rows[dataGridView2.Rows.Count - 1].Cells["quantity"].Value.ToString());string pp = dataGridView2.Rows[dataGridView2.Rows.Count - 1].Cells[3].Value.ToString();Double rpp = Double.Parse(pp);Decimal rrpp = (decimal)rpp;Decimal tp = rrpp * qu;dataGridView2.Rows[dataGridView2.Rows.Count - 1].Cells["tprice"].Value = tp+".00";Double sum = 0;for (int f = 0; f < dataGridView2.Rows.Count; f++){sum += double.Parse(dataGridView2.Rows[f].Cells[6].Value.ToString());}string msun =( sum.ToString());libt2.Text = msun ;

Answers (2)