Jyoti Jodha

Jyoti Jodha

  • NA
  • 1.7k
  • 396.8k

how to make textbox values Global Variable in windows form

Jun 22 2017 3:26 AM
private void button1_Click(object sender, EventArgs e)
{

if (txtcgst.Text != "")
GlobalVariable.CGST = Convert.ToDouble(txtcgst.Text);
else
GlobalVariable.CGST = 0.00;
if (txtsgst.Text != "")
GlobalVariable.SGST = Convert.ToDouble(txtsgst.Text);
else
GlobalVariable.SGST = 0.00;
if (txtigst.Text != "")
GlobalVariable.IGST = Convert.ToDouble(txtigst.Text);
else
GlobalVariable.IGST = 0.00;


if (txtsgst.Text == "")
{
MessageBox.Show("Please Provide Details!");
txt_note1.Focus();
return;
}

{
cmd = new SqlCommand("update GSTsetup set Sgst=@Sgst,Cgst=@Cgst,Igst=@Igst ", con);
con.Open();
//cmd.Parameters.AddWithValue("@id", ID);
cmd.Parameters.AddWithValue("@Sgst", txtsgst.Text);
cmd.Parameters.AddWithValue("@Cgst", txtcgst.Text);
cmd.Parameters.AddWithValue("@Igst", txtigst.Text);
cmd.ExecuteNonQuery();
MessageBox.Show("Record Updated Successfully");
con.Close();
}

//this.Close();
}
 
 
class GlobalVariable
{
public static double CGST { get; set; }
public static double SGST { get; set; }
public static double IGST { get; set; }

Answers (3)