失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > java管理员和用户登录注册_如何让我的登录识别用户是管理员还是普通用户?...

java管理员和用户登录注册_如何让我的登录识别用户是管理员还是普通用户?...

时间:2022-06-04 10:47:45

相关推荐

java管理员和用户登录注册_如何让我的登录识别用户是管理员还是普通用户?...

我有一个登录,根据用户的类型,它将打开一个不同的菜单,但我不知道如何让它识别类型而不指定它,这是我得到的代码:

private void btnaceptar_Click(object sender,EventArgs e){if(txtusuario.Text ==“”||txtcontraseña.Text==“”){MessageBox.Show(“TODOS LOS CAMPOS DEBEN ESTAR LLENOS . ”,“ERROR”,MessageBoxButtons .OK,MessageBoxIcon.Error); txtusuario.Clear(); txtusuario.Focus(); }

n = n - 1;

if (n <= 3 && n >= 0)

{

if (n == 1)

{

MessageBox.Show("Solo le quedan 1 intento, porfavor asegurese de poner los datos correctos!", "AVISO!", MessageBoxButtons.OK, MessageBoxIcon.Warning);

MessageBox.Show("Usuario y/o contraseña incorrectos, verifique porfavor", "Error al ingresar datos.", MessageBoxButtons.OK, MessageBoxIcon.Error);

this.txtusuario.Clear();

this.txtcontraseña.Clear();

this.txtusuario.Focus();

}

else

{

SqlConnection miconexion = new SqlConnection(@"Data Source=USER-PC;Initial Catalog=dbpuntodeventa;Integrated Security=True");

miconexion.Open();

SqlCommand comando1 = new SqlCommand("select * from usuarios where usuario='" + txtusuario.Text + "'and contraseña='" + txtcontraseña.Text + "'", miconexion);

SqlDataReader Ejecuta = comando1.ExecuteReader();

if (Ejecuta.Read() == true)

{

MessageBox.Show("Bienvenido Administrador , Ingreso de datos correctos", "Ingreso exitoso!", MessageBoxButtons.OK, MessageBoxIcon.Information);

this.Hide();

frmmenuadmin frmprincipal = new frmmenuadmin();

frmprincipal.Show();

frmprincipal.lblid.Text = txtusuario.Text;

}

else

{

SqlConnection miconexion2 = new SqlConnection(@"Data Source=USER-PC;Initial Catalog=dbpuntodeventa;Integrated Security=True");

miconexion2.Open();

SqlCommand comando = new SqlCommand("select * from usuarios where usuario='" + txtusuario.Text + "'and contraseña='" + txtcontraseña.Text + "'", miconexion2);

SqlDataReader ejecutar1 = comando.ExecuteReader();

if (ejecutar1.Read() == true)

{

MessageBox.Show("Bienvenido Empleado , Ingreso de datos correctos", "Ingreso exitoso!", MessageBoxButtons.OK, MessageBoxIcon.Information);

this.Hide();

frmmenu frm2 = new frmmenu();

frm2.Show();

frm2.lblnombre.Text = txtusuario.Text;

}

else

{

if (n == 0)

{

MessageBox.Show("Error,se han agotado los intentos", "AVISO!", MessageBoxButtons.OK, MessageBoxIcon.Warning);

Application.Exit();

}

MessageBox.Show("Usuario y/o contraseña incorrectos, verifique porfavor", "Error al ingresar datos.", MessageBoxButtons.OK, MessageBoxIcon.Error);

this.txtusuario.Clear();

this.txtcontraseña.Clear();

this.txtusuario.Focus();

}

}

}

}

}

}

}

对于那些不讲西班牙语的人,usuario意味着用户和contraseña意味着密码现在我需要实现tipo,这意味着类型

如果觉得《java管理员和用户登录注册_如何让我的登录识别用户是管理员还是普通用户?...》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。