Hi,
i want to display a text message before updating any value.it shows this error.here is my issue if i click on update button it will show message successfully.but,i dont want that if i click on update button it has to show please enter value for before update.i want like this.i wrote the following code it wont work.please do the needful.
private void btn_update_Click(object sender, EventArgs e)
{
if (txt_amount .Text ==string .Empty &&txt_customeraddress .Text ==string .Empty &&txt_invoicedate .Text ==string .Empty &&txt_invoiceno .Text ==string .Empty &&txt_netamount .Text ==string .Empty &&txt_ondate .Text ==string .Empty &&txt_orderno .Text ==string .Empty &&txt_perprice .Text ==string .Empty &&txt_quantity .Text ==string .Empty &&txt_totalamount .Text ==string .Empty &&txt_vat .Text ==string .Empty &&txt_vatpercentage .Text ==string .Empty )
{
MessageBox.Show("please change the value before update");
}
else
{
SqlConnection con = new SqlConnection("data source=mars-104;initial catalog=Sudheeptest;integrated security=true");
SqlCommand cmd = new SqlCommand("update tbl_report2 set compname=@compname,compaddress=@compaddress,orderno=@orderno,ondate=@ondate,invoicedate=@invoicedate,amountstatus=@amountstatus,netamount=@netamount,tamount=@tamount where invoiceno=@id", con);
cmd.Parameters.AddWithValue("@compname", cmb_companyname.Text);
cmd.Parameters.AddWithValue("@compaddress", txt_customeraddress.Text);
cmd.Parameters.AddWithValue("@orderno", txt_orderno.Text);
cmd.Parameters.AddWithValue("@id", id);
cmd.Parameters.AddWithValue("@amountstatus", rb_paid.Checked);
cmd.Parameters.AddWithValue("@netamount", txt_netamount.Text);
cmd.Parameters.AddWithValue("@tamount", txt_totalamount.Text);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
SqlConnection con1 = new SqlConnection("data source=mars-104;initial catalog=Sudheeptest;integrated security=true");
SqlCommand cmd1 = new SqlCommand("update tbl_report1 set compname=@compname,orderno=@orderno,invoicedate=@invoicedate,ondate=@ondate where invoiceid=@id", con1);
cmd1.Parameters.AddWithValue("@compname", cmb_companyname.Text);
cmd1.Parameters.AddWithValue("@orderno", txt_orderno.Text);
cmd1.Parameters.AddWithValue("@invoicedate", txt_invoicedate.Text);
cmd1.Parameters.AddWithValue("@ondate", txt_ondate.Text);
cmd1.Parameters.AddWithValue("@compaddress", txt_customeraddress.Text);
cmd1.Parameters.AddWithValue("@id", txt_invoiceno.Text);
con1.Open();
cmd1.ExecuteNonQuery();
con1.Close();
MessageBox.Show("updated successfully");
}
Best,
Sudheep.