bajar cambios 4
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Data.SQLite;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
@@ -75,6 +76,54 @@ namespace compabetov2.database
|
||||
}
|
||||
}
|
||||
|
||||
public static bool crearLoginDAO(LoginModel login)
|
||||
{
|
||||
var db_conexion = new Conexion();
|
||||
try
|
||||
{
|
||||
using (SQLiteConnection conexion = db_conexion.get_connection())
|
||||
{
|
||||
conexion.Open();
|
||||
|
||||
using (var transaccion = conexion.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
string sqlLogin = "INSERT INTO Login (tipo, usuario, contra) VALUES(@tipo, @usuario, @contra);";
|
||||
string sqlEmpleado = "UPDATE Empleado SET fk_idLogin = @fklogin WHERE idempleado = @idempleado";
|
||||
|
||||
|
||||
SQLiteCommand commandLogin = new SQLiteCommand(sqlLogin, conexion);
|
||||
commandLogin.Parameters.AddWithValue("@tipo", login.tipo);
|
||||
commandLogin.Parameters.AddWithValue("@usuario", login.usuario);
|
||||
commandLogin.Parameters.AddWithValue("@contra", login.contra);
|
||||
|
||||
SQLiteCommand commandEmpleado = new SQLiteCommand(sqlEmpleado, conexion);
|
||||
commandEmpleado.Parameters.AddWithValue("@fklogin", login.fkEmpleado);
|
||||
commandEmpleado.Parameters.AddWithValue("@idempleado", login.fkEmpleado);
|
||||
|
||||
commandLogin.ExecuteNonQuery();
|
||||
commandEmpleado.ExecuteNonQuery();
|
||||
|
||||
transaccion.Commit();
|
||||
return true;
|
||||
}
|
||||
catch (SQLiteException ex)
|
||||
{
|
||||
transaccion.Rollback();
|
||||
MessageBox.Show(ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLiteException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool insertarEmpleadoDAO(Empleado empleado)
|
||||
{
|
||||
var db_conexion = new Conexion();
|
||||
|
||||
Reference in New Issue
Block a user