I have a ListBox
, Button
and RadioButton
. When I click a button
, different kind of drink will list out on the ListBox
.
I want let user select drinks size and show out the price. When user check large radio button
large size price will show out. The price was link with the database.
The problem is when I select the radio button, the price won't show until I click the drinks button again. I want the price show when then radio button was checked.
Here is my coding
private void signatureMilkTeaButton_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
string constring = "datasource=localhost;port=3306;username=root;password=000";
string Query = "select* from database.drinks where drinks_Type ='M';";
MySqlConnection connectDatabase = new MySqlConnection(constring);
MySqlCommand commandDataBase = new MySqlCommand(Query, connectDatabase);
MySqlDataReader myReader;
try
{
connectDatabase.Open();
myReader = commandDataBase.ExecuteReader();
while (myReader.Read())
{
string sName = myReader.GetString("drinks_Name");
listBox1.Items.Add(sName);
}
{
decimal MMPrice = myReader.GetDecimal("drinks_MPrice");
decimal MLPrice = myReader.GetDecimal("drinks_LPrice");
if (MediumButton.Checked == true )
{
textBox1.Text = MMPrice.ToString();
}
else if (largeButton.Checked == true)
{
textBox1.Text = MLPrice.ToString();
}
}*/
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}