private void TXT_PASSWORD_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == Convert.ToChar(Keys.Enter)) { if (TXT_USER.Text == "" || TXT_USER == null) { MessageBox.Show("no puede quedar vacio el campo nombre de usuario", "ALFA ERP..", MessageBoxButtons.OK, MessageBoxIcon.Warning); TXT_USER.Focus(); return; } if (TXT_PASSWORD.Text == "" || TXT_PASSWORD == null) { MessageBox.Show("no puede quedar vacio el campo password", "ALFA ERP..", MessageBoxButtons.OK, MessageBoxIcon.Warning); TXT_USER.Focus(); return; } try { mtd.abrirConexion(); if (mtd.usuarioRegistrado(TXT_USER.Text.ToString().Trim()) == true) { string contra = mtd.existeContra(TXT_USER.Text.ToString().Trim()); if (contra.Equals(TXT_PASSWORD.Text.ToString().Trim()) == true) { this.Hide(); VISTAS.Menu frn_menu = new VISTAS.Menu(TXT_USER.Text.ToString().Trim()); frn_menu.Show(); } else { MessageBox.Show("CONTRASEÑA INVALIDA", "ALFA ERP..", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); TXT_USER.Focus(); } } else { MessageBox.Show("EL USUARIO:--" + TXT_USER.Text + "--NO SE ENCUENTRA REGISTRADO O SU CUENTA ESTA DESACTIVADA", "ALFA ERP..", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); TXT_USER.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message + " Ocurrio un error al entrar al sistema!!", "ALFA ERP..", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } finally { mtd.cerrarConexion(); TXT_PASSWORD.ResetText(); TXT_USER.ResetText(); } } }
private void ThongBaoLoi() { if (TXT_USER.Text == "") { MessageBox.Show("Bạn Chưa Nhập Tên Đăng Nhập!"); } TXT_USER.Focus(); if (TXT_PASS.Text == "") { MessageBox.Show("Bạn Chưa Nhập Mật Khẩu!"); } TXT_PASS.Focus(); //if ( TXT_USER.Text == "" || TXT_PASS.Text == "") //{ // MessageBox.Show("Bạn Chưa Nhập Tên Hoặc Mật Khẩu!"); //} //TXT_USER.Text = ""; //TXT_PASS.Text = ""; //TXT_USER.Focus(); }
private void DangNhapHeThong() { ThongBaoLoi(); DataTable DTT = MaHoa(); if (DTT.Rows.Count == 0) { MessageBox.Show("Sang!!!"); TXT_USER.Text = ""; TXT_PASS.Text = ""; TXT_USER.Focus(); } else { ThamSo.Admin = Convert.ToByte(DTT.Rows[0]["ADMIN"]); ThamSo.USERNAME = Convert.ToString(DTT.Rows[0]["USERNAME"]); ThamSo.PASSWORD = Convert.ToString(DTT.Rows[0]["PASSWORD"]); MessageBox.Show("Đăng Nhập Thành Công"); MessageBox.Show("SELECT * FROM USERS WHERE USENAME ='" + TXT_USER.Text.Trim() + "' AND PASSWORD = '******'"); this.Close(); status = true; } }
private void BTN_INGRESAR_Click(object sender, EventArgs e) { if (TXT_USER.Text == "" || TXT_USER == null) { MessageBox.Show("no puede quedar vacio el campo nombre de usuario", "ALFA ERP..", MessageBoxButtons.OK, MessageBoxIcon.Warning); TXT_USER.Focus(); return; } if (TXT_PASSWORD.Text == "" || TXT_PASSWORD == null) { MessageBox.Show("no puede quedar vacio el campo password", "ALFA ERP..", MessageBoxButtons.OK, MessageBoxIcon.Warning); TXT_USER.Focus(); return; } try { mtd.abrirConexion(); if (mtd.usuarioRegistrado(TXT_USER.Text.ToString().Trim()) == true) { MessageBox.Show("se encontro!!"); } else { MessageBox.Show("no se encontro!!"); } } catch (Exception ex) { MessageBox.Show(ex.Message + " Ocurrio un error al entrar al sistema!!", "ALFA ERP..", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } finally { mtd.cerrarConexion(); TXT_PASSWORD.ResetText(); TXT_USER.ResetText(); } }