I think you want something like following
private void Common_btn_click_event_Click(object sender, EventArgs e)
{
Button btn=((Button)sender);
string btn_text= btn.text;
if (btn.Text == "Room 1")
{
Frm_Customer _Frm_Customer = new Frm_Customer();
_Frm_Customer.refToFrm_Rooms = this;
_Frm_Customer.ButtonBase = btn.text;
btn_Room1.BackColor = Color.Red;
this.Visible = true;
_Frm_Customer.Show();
}
else if (btn.Text == "Reserved")
{
DialogResult dlgResult = MessageBox.Show("You Have More Time?", "Do You wnat to Vocate?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dlgResult == DialogResult.Yes)
{
{
btn.BackColor = Color.Red;
if(btn.Name=="btn_Room1")
btn.Text = "Room 1";
else if(btn.Name=="btn_Room2")
btn.Text = "Room 2";
SqlConnection con = new SqlConnection();
string[] conString = DBSettings.connectionStringValues();
string connectionString = string.Format(@"server=" + conString[0] + ";database=Restaurant;uid=" + conString[2] + ";pwd=" + conString[3]);
con.ConnectionString = connectionString;
con.Open();
SqlCommand cmd = new SqlCommand("update AllRooms set RunFlag=0 where RoomName='"+ btn.Text +"'", con);
SqlDataReader _sqldatareader = cmd.ExecuteReader();
_sqldatareader.Read();
con.Close();
}
}
else if(dlgResult==DialogResult.No)
{
}
}
}