cierre completo de las ventanas
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SQLite;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Policy;
|
||||
@@ -76,6 +77,31 @@ namespace compabetov2.database
|
||||
}
|
||||
}
|
||||
|
||||
public static SQLiteDataReader conseguirInicioSesionDAO(string usuario)
|
||||
{
|
||||
SQLiteDataReader reader = null;
|
||||
var db_conexion = new Conexion();
|
||||
try
|
||||
{
|
||||
SQLiteConnection conexion = db_conexion.get_connection();
|
||||
|
||||
conexion.Open();
|
||||
|
||||
string sql = "SELECT usuario, tipo FROM Login WHERE usuario = @param0";
|
||||
SQLiteCommand command = new SQLiteCommand(sql, conexion);
|
||||
command.Parameters.AddWithValue($"@param{0}", usuario);
|
||||
reader = command.ExecuteReader();
|
||||
|
||||
return reader;
|
||||
|
||||
}
|
||||
catch (SQLiteException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
return reader;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool verificarExistenciaLoginDAO(LoginModel loginModel)
|
||||
{
|
||||
SQLiteDataReader reader = null;
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace compabetov2.database.modelos
|
||||
{
|
||||
internal class LoginModel
|
||||
public class LoginModel
|
||||
{
|
||||
public string usuario;
|
||||
public string contra;
|
||||
|
||||
@@ -16,7 +16,21 @@ namespace compabetov2.database
|
||||
{
|
||||
return DAO.iniciarSesionDAO(usuario.nombreUsuario, usuario.contra);
|
||||
}
|
||||
public static LoginModel conseguirInicioSesion(string usuario)
|
||||
{
|
||||
SQLiteDataReader reader = DAO.conseguirInicioSesionDAO(usuario);
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
return new LoginModel(
|
||||
reader["usuario"].ToString(),
|
||||
"",
|
||||
reader["tipo"].ToString()
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public static bool crearLogin(LoginModel loginModel, int idEmpleado)
|
||||
{
|
||||
return DAO.crearLoginDAO(loginModel, idEmpleado);
|
||||
|
||||
Reference in New Issue
Block a user