Create an function and call that function.
public void Foo()
{
string istrue = "true";
bool mybool = Convert.ToBoolean(istrue);
trans.ADD_NEW_TRANS(Convert.ToInt32(txtID.Text), dtTransDate.Value, txtVibNO.Text, cmbSenderSite.Text, cmbRecievedSite.Text,
Convert.ToInt32(txtWorkHours.Text), Convert.ToInt32(cmbTrans.SelectedValue), Program.userInfo.UserName);
vib.UPDATE_TRANS_ISOFF(txtVibNO.Text, mybool);
MessageBox.Show("done", "done", MessageBoxButtons.OK, MessageBoxIcon.Information);
btnSave.Enabled = false;
}
And you can use switch like this
switch (cmbTrans.Text)
{
case "Good": //this is mean if(cmbTrans.Text == "Good")
{
Foo();
//code
break;
}
default:
break;
}
solved How to use Switch in C# [closed]