I have a login form (user, password, permission) that has a combobox, which allows you to choose what type of user to start the session, depending on the type of user selected, validates the data from 2 different tables, but it gives me error:
the final code of the enter button is as follows:
private void btnIngresar_Click(object sender, EventArgs e)
{
//RECIBMOS EL VALOR QUE VIENE DESDE EL COMBOBOX
if (permisoCombo == "Funcionario")
{
DataTable datos = CapaNegocios.negocioLoginProf.ingresar(txtUsuario.Text, txtClave.Text);
//verificamos la existencia del usuario
if (datos.Rows.Count == 0)
{
MessageBox.Show("NO EXISTE NINGUN USUARIO CON ESOS DATOS", "Centro Medico Chilhue", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
frmPrincipal frm = new frmPrincipal();
frm.idRegistro = datos.Rows[0][0].ToString();
frm.rut = datos.Rows[0][1].ToString();
frm.nombre = datos.Rows[0][2].ToString();
frm.apePat = datos.Rows[0][3].ToString();
frm.usuario = datos.Rows[0][5].ToString();
frm.permiso = datos.Rows[0][7].ToString();
frm.Show();
this.Hide();
}
}else if(permisoCombo == "Profesional")
{
DataTable datos = CapaNegocios.negocioLoginProf.ingresar(txtUsuario.Text, txtClave.Text);
//verificamos la existencia del usuario
if (datos.Rows.Count == 0)
{
MessageBox.Show("NO EXISTE NINGUN USUARIO CON ESOS DATOS", "Centro Medico Chilhue", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
frmPrincipal frm = new frmPrincipal();
frm.idRegistro = datos.Rows[0][0].ToString();
frm.rut = datos.Rows[0][1].ToString();
frm.nombre = datos.Rows[0][2].ToString();
frm.apePat = datos.Rows[0][3].ToString();
frm.usuario = datos.Rows[0][5].ToString();
frm.permiso = datos.Rows[0][7].ToString();
frm.Show();
this.Hide();
}
}
}
and in the SelectIndexChange event of the combobox (to see what type of user it was selected) I have:
permisoCombo = Convert.ToString(this.cmbRoles.SelectedItem);
Greetings to all and thanks