breack
i need help because i dont why this is null
https://gyazo.com/0889d72ca63baef68474b665b61cc570 where is the error i think
46 replies
i need help because i dont why this is null
it should be looks like this https://gyazo.com/4863ad940a14e5930124ec292172af21
46 replies
i need help because i dont why this is null
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Negocio;
using Entidad;
namespace ProyectoBD
{
public partial class Login : Form
{
public Login()
{
InitializeComponent();
}
private void btnCancelar_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnIngresar_Click(object sender, EventArgs e)
{
List<Usuario> PRUEBA = new N_Usuario().listar();
Usuario osuario = new N_Usuario().listar().Where(u => u.Documento == txtdocumento.Text && u.Clave == txtclave.Text).FirstOrDefault();
if(osuario != null ) {
Inicio form = new Inicio();
form.Show();
this.Hide();
form.FormClosing += Frm_closing;
}else
{
MessageBox.Show("No se encontre el usuario","Mensaje",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
}
}
private void Frm_closing(object sender , FormClosingEventArgs e) {
txtdocumento.Text = "";
txtclave.Text = "";
this.Show();
}
}
}
46 replies
i need help because i dont why this is null
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using Entidad;
namespace Datos
{
public class D_Usuario
{
public List<Usuario> listar () {
List<Usuario> lista = new List <Usuario>();
using (SqlConnection oconexion = new SqlConnection(Conexion.cadena)) {
try {
string query = "Select Id_usuario,Documento,Nombre_Completo,correo,Clave,Estado from usuario";
SqlCommand cmd = new SqlCommand(query, oconexion);
cmd.CommandType = CommandType.Text;
oconexion.Open();
using (SqlDataReader dr = cmd.ExecuteReader()) {
while(dr.Read()) {
lista.Add(new Usuario()
{
Id_usuario = Convert.ToInt32(dr["Id_usuario"]),
Documento = dr["Documento"].ToString(),
Nombre_Completo = dr["Nombre_Completo"].ToString(),
correo = dr["correo"].ToString(),
Clave =dr["clave"].ToString(),
Estado = Convert.ToBoolean(dr["Estado"])
});
}
}
}
catch (Exception ex) {
lista = new List<Usuario>();
}
}
return lista;
}
}
}
46 replies