- Messages
- 165
- Reaction score
- 0
- Points
- 26
mga sir pahelp naman sa problema ko, ganto po yung flow, ang una po magaadd ako ng items sa listbox (for example "Package1" with price of 3999) & nagdagdag po ako ng panibagong items (ex. "Package2" price: 2999) kapag tinanggal ko po yung "Package1" sa listbox gamit po yung doubleclick event ang mangyayari mababwasan po yung Total, magiging 2999 na lang po ulet
eto po yung image ng form
View attachment 307324
eto po yung code ko:
Bali ang problem ko na lang po mga sir is yung pag remove ng items then deduction dun sa total sana matulungan nyo po ako, Thank you!
- - - Updated - - -
Up lang po need ko lang talaga
eto po yung image ng form
View attachment 307324
eto po yung code ko:
Code:
private void listBox1_DoubleClick(object sender, EventArgs e)
{
string constring = "server=localhost;port=3306;username=root;password=root";
string Query = "Select * from dbinfo.tbladvance;";
MySqlConnection con = new MySqlConnection(constring);
MySqlCommand cmdDB = new MySqlCommand(Query, con);
MySqlDataReader myReader;
con.Open();
myReader = cmdDB.ExecuteReader();
while (myReader.Read())
{
/* for (int n = listBox1.Items.Count - 1; n >= 0; --n)
{
string sName = myReader.GetString("Names");
string removelistitem = sName;
if (listBox1.Items[n].ToString().Contains(removelistitem))
{
listBox1.Items.RemoveAt(n);
}
} */
{
for (int i = 0; i < listBox1.SelectedItems.Count; i++)
listBox1.Items.Remove(listBox1.SelectedItems[i]);
}
}
con.Close();
}
void fillCombo()
{
string constring = "server=localhost;port=3306;username=root;password=root";
string Query = "Select * from dbinfo.tbladvance;";
MySqlConnection con = new MySqlConnection(constring);
MySqlCommand cmdDB = new MySqlCommand(Query, con);
MySqlDataReader myReader;
try
{
con.Open();
myReader = cmdDB.ExecuteReader();
while (myReader.Read())
{
string sName = myReader.GetString("Names");
comboBox1.Items.Add(sName);
}
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private void Trans_Load(object sender, EventArgs e)
{
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string constring = "server=localhost;port=3306;username=root;password=root";
string Query = "Select * from dbinfo.tbladvance where Names='" + comboBox1.Text + "' ;";
MySqlConnection con = new MySqlConnection(constring);
MySqlCommand cmdDB = new MySqlCommand(Query, con);
MySqlDataReader myReader;
try
{
con.Open();
myReader = cmdDB.ExecuteReader();
while (myReader.Read())
{
string sName = myReader.GetString("Names");
double sPrice = myReader.GetDouble("Price");
string sDesc = myReader.GetString("Description");
txtName.Text = sName;
txtPrice.Text = sPrice.ToString();
txtDesc.Text = sDesc;
}
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
int total;
private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Add(txtName.Text);
int num1 = int.Parse(txtPrice.Text);
int num2 = int.Parse(txtTotal.Text);
total = num1 + num2;
txtTotal.Text = total.ToString();
}
Bali ang problem ko na lang po mga sir is yung pag remove ng items then deduction dun sa total sana matulungan nyo po ako, Thank you!
- - - Updated - - -
Up lang po need ko lang talaga