cuenta a la mitad
This commit is contained in:
@@ -989,6 +989,31 @@ namespace compabetov2.database
|
||||
}
|
||||
}
|
||||
|
||||
public static SQLiteDataReader conseguirDetalleCuanteDAO(int idCuenta)
|
||||
{
|
||||
SQLiteDataReader reader = null;
|
||||
var db_conexion = new Conexion();
|
||||
try
|
||||
{
|
||||
SQLiteConnection conexion = db_conexion.get_connection();
|
||||
|
||||
conexion.Open();
|
||||
|
||||
string sql = "Select p.nombre , dc.cantidad from detalle_cuenta dc, Producto p WHERE dc.fk_producto = p.idproducto and dc.fk_cuenta = @fk_cuenta;";
|
||||
SQLiteCommand command = new SQLiteCommand(sql, conexion);
|
||||
command.Parameters.AddWithValue("@fk_cuenta", idCuenta);
|
||||
reader = command.ExecuteReader();
|
||||
|
||||
return reader;
|
||||
|
||||
}
|
||||
catch (SQLiteException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
return reader;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void crearDB()
|
||||
{
|
||||
|
||||
@@ -14,13 +14,15 @@ namespace compabetov2.database.modelos
|
||||
public string fecha;
|
||||
public string estado;
|
||||
public string descripcion;
|
||||
public string cliente;
|
||||
|
||||
public Cuenta(decimal total = 0, string fecha = "", string estado = "", string descripcion = "", int id = -1) {
|
||||
public Cuenta(decimal total = 0, string fecha = "", string estado = "", string descripcion = "", string cliente = "",int id = -1) {
|
||||
this.id = id;
|
||||
this.total = total;
|
||||
this.fecha = fecha;
|
||||
this.estado = estado;
|
||||
this.descripcion = descripcion;
|
||||
this.cliente = cliente;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,13 +11,14 @@ namespace compabetov2.database.modelos
|
||||
public int idCuenta;
|
||||
public Producto producto;
|
||||
public int cantidad;
|
||||
public string nombreProducto;
|
||||
|
||||
|
||||
public DetalleCuentaModel(Producto producto, int cantidad, int idCuenta =-1)
|
||||
public DetalleCuentaModel(Producto producto, int cantidad, int idCuenta =-1, string nombreProducto = "")
|
||||
{
|
||||
this.idCuenta = idCuenta;
|
||||
this.producto = producto;
|
||||
this.cantidad = cantidad;
|
||||
this.nombreProducto = nombreProducto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,17 +240,37 @@ namespace compabetov2.database
|
||||
string fecha = reader["fecha"].ToString();
|
||||
string estado = reader["estado"].ToString();
|
||||
string descripcion = reader["descripcion"].ToString();
|
||||
string cliente = reader["cliente"].ToString();
|
||||
|
||||
Cuenta cuenta = new Cuenta(
|
||||
(int) total,
|
||||
fecha,
|
||||
estado,
|
||||
descripcion,
|
||||
cliente,
|
||||
(int)idCuenta
|
||||
);
|
||||
cuentas.Add(cuenta);
|
||||
}
|
||||
return cuentas;
|
||||
}
|
||||
|
||||
public static List<DetalleCuentaModel> conseguirDetalleCuante(int idCuenta)
|
||||
{
|
||||
List<DetalleCuentaModel> detallesCuentas = new List<DetalleCuentaModel>();
|
||||
|
||||
SQLiteDataReader reader = DAO.conseguirDetalleCuanteDAO(idCuenta);
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
DetalleCuentaModel detalleCuenta = new DetalleCuentaModel(
|
||||
new Producto(0, reader["nombre"].ToString()),
|
||||
(int)reader.GetInt64(1)
|
||||
);
|
||||
detallesCuentas.Add(detalleCuenta);
|
||||
}
|
||||
|
||||
return detallesCuentas;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user