private void btnUpdate_Click(object sender, EventArgs e)
{
if (txtSN.Text == "")
{
MessageBox.Show("Please input supplier's name..");
}
else if (txtSA.Text == "")
{
MessageBox.Show("Please input address..");
}
if (txtCN.Text == "")
{
MessageBox.Show("Please input Contact #..");
}
else
{
DialogResult dialog = MessageBox.Show("Do you really want to Update?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialog == DialogResult.Yes)
{
string constring = "datasource=localhost;port=3306;username=root;password=root;database=database2_db";
string Query = "update supplier_registration set SupplierID='" + this.lblID.Text + "',Supplier='" + this.txtSN.Text + "',Address='" + this.txtSA.Text + "',Email_address='" + this.txtEA.Text + "',Contact_number='" + this.txtCN.Text + "',Description='" + this.txtSD.Text + "'where SupplierID='" + this.lblID.Text + "';";
MySqlConnection MyConn = new MySqlConnection(constring);
MySqlCommand MyCommand = new MySqlCommand(Query, MyConn);
MySqlDataReader myReader;
try
{
MyConn.Open();
myReader = MyCommand.ExecuteReader();
if (MessageBox.Show("Successfully Update", "Success", MessageBoxButtons.OK, MessageBoxIcon.Asterisk) == DialogResult.OK)
while (myReader.Read())
{
string update = myReader.GetString("SupplierID");
lblID.Text = update;
}
MyConn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
}
}