private void btnGoback_Click(object sender, EventArgs e) { frmStaff newform = new frmStaff(); this.Hide(); newform.Show(); }
private void btnLogin_Click(object sender, EventArgs e) { OpenSqlConnection(); string query = "Select TENDANGNHAP from NHANVIEN where TENDANGNHAP='" + txtUsername.Text + "'and MATKHAU='" + txtPassword.Text + "'and IDCHUCVU='QL'"; string query1 = "Select TENDANGNHAP from NHANVIEN where TENDANGNHAP='" + txtUsername.Text + "' and MATKHAU='" + txtPassword.Text + "'and IDCHUCVU='NV'"; SqlCommand cmd = new SqlCommand(query, conn); SqlCommand cmd1 = new SqlCommand(query1, conn); var verify = cmd.ExecuteScalar(); var verify1 = cmd1.ExecuteScalar(); conn.Close(); if (verify != null) { frmAdmin newform = new frmAdmin(); this.Hide(); newform.Show(); } else if (verify1 != null) { frmStaff newfrm = new frmStaff(); this.Hide(); newfrm.Show(); } else { MessageBox.Show("Log in failed!", "Retry", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); } }