I have a program that allow customer to vote for the drinks. Order one drink equal to one vote. Order two drink equal to two votes and so on. Enter Order_ID to check the vote counts. Customer vote by selecting the radio buttons and click submit button. After submit, vote count should be -1. Message box will display vote count remained. (eg ordered 5 drinks, after one vote submit should be showing "vote count remained is 4" and stop program when vote count is 0).
My question is how to make the above happen? I have tried using loop but does not pause in between to let customer to resubmit again. Loop will countinously display MessageBox until vote count reached 0.
Second question, can I use groupbox? but how to write the code if apply groupbox.
Third question or I should not use loop at all?
private void btnSubmitVote_Click(object sender, EventArgs e)
{
for (int i = OrdersQty; OrdersQty > 0 ; OrdersQty-- )
{
if (radAmericano.Checked)
{
conn.Open();
MySqlCommand comm2a = new MySqlCommand(sql2a, conn);
MySqlDataReader reader2a = comm2a.ExecuteReader();
comm2c.ExecuteDataReader()
comm2a.Dispose();
conn.Close();
conn.Open();
MySqlCommand comm2b = new MySqlCommand(sql2b, conn);
comm2b.ExecuteNonQuery();
comm2b.Dispose();
conn.Close();
MessageBox.Show("You have " + OrdersQty + " vote left")
}
if (radCappuccino.Checked)
{
conn.Open();
MySqlCommand comm2c = new MySqlCommand(sql2c, conn);
MySqlDataReader reader2a = comm2a.ExecuteReader();
comm2c.ExecuteDataReader()
comm2c.Dispose();
conn.Close();
conn.Open();
MySqlCommand comm2d = new MySqlCommand(sql2d, conn);
comm2d.ExecuteNonQuery();
comm2d.Dispose();
conn.Close();
MessageBox.Show("You have " + OrdersQty + " vote left")
}
}
MessageBox.Show("You have " + OrdersQty + " vote left" + "Thank you")
this.Close();
}