Click here to Skip to main content
15,303,310 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on a POS system with winforms. To create a items list for a guest I selected the select the selected items from a table in my database (products) then display them a gridview with it corresponding info. So the the guest table which was just created is not paid it’s then saved into another table in my database (unpaidchecks).

When a user login to the application and there are unpaidchecks under the user’s name a dynamic button is created to show all the unpaidchecks in ascending order.

Then I created a click event for the dynamic button. When it’s clicked it show the data of that particular unpaidcheck.

But when I want to update it, as in add new items from product, a new row is not added for the new item to be displayed.

The gridview is bounded to productbindingsource at design time and when the dynamic button is clicked the gridview is bounded to (unpaidchecks). I need help on how to navigate this.

What I have tried:

I use this to open a table when a guest places an order.
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();
            string may = Formq.mark1;
            dataGridView2.Rows[dataGridView2.Rows.Count - 1].Cells[1].Value = dataGridView1.Rows[i].Cells[1].Value.ToString();
            dataGridView2.Rows[dataGridView2.Rows.Count - 1].Cells[2].Value = dataGridView1.Rows[i].Cells[2].Value.ToString();
            dataGridView2.Rows[dataGridView2.Rows.Count - 1].Cells[3].Value = dataGridView1.Rows[i].Cells[3].Value.ToString();
            dataGridView2.Rows[dataGridView2.Rows.Count - 1].Cells[4].Value = dataGridView1.Rows[i].Cells[4].Value.ToString();
            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;

And this when the dynamic button is clicked.
private void btn_Click(object sender, EventArgs e)
    salesitems op = new salesitems();
    int i = 0;
   Button btn = sender as Button;
   string btntext = btn.Text;
   op.dataGridView2.DataSource = kk.getunpaid(int.Parse(btn.Text));
    foreach (var  dy in kk.getunpaid(int.Parse(btn.Text)))
        op.dataGridView2.Rows[i].Cells["quantity"].Value = dy.quantity.ToString();
        op.dataGridView2.Rows[i].Cells["Tprice"].Value = dy.tprice.ToString();
        op.libtabsno.Text = dy.tabel_sno_.ToString();
        op.libuser.Text = dy.user.ToString();
        op.libtno.Text = dy.tabel_no_.ToString();
        op.libt2.Text =
Updated 15-Dec-20 22:02pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900