private void btnok_Click(object sender, EventArgs e) { //validation if (txtusername.SelectedItem == "") { MessageBox.Show("Select username"); txtusername.Focus(); } else if (btnreset.Text == "") { MessageBox.Show("password is Required!"); btnreset.Focus(); } else { bool r = validate_login(txtusername.Text, btnreset.Text); if (r == true) { PharmSoft cs = new PharmSoft(); this.Hide(); cs.userid.Text = userid; cs.lblUsername.Text = username; cs.lblRole.Text = role; cs.lblFull_Name.Text = fullname; cs.Show(); } else { MessageBox.Show("incorrect login credentials"); txtusername.Text = ""; btnreset.Text = ""; txtusername.Focus(); } } }