caso de producto sin imagen

This commit is contained in:
carlos
2023-12-23 00:10:07 -06:00
parent ef749cc9b1
commit cf45651854
3 changed files with 12 additions and 5 deletions
+4 -2
View File
@@ -1,7 +1,9 @@
{ {
"ExpandedNodes": [ "ExpandedNodes": [
"" "",
"\\database",
"\\database\\modelos"
], ],
"SelectedNode": "\\compabetov2.sln", "SelectedNode": "\\database\\DAO.cs",
"PreviewInSolutionExplorer": false "PreviewInSolutionExplorer": false
} }
Binary file not shown.
+7 -2
View File
@@ -110,7 +110,12 @@ namespace compabetov2.database
string sql = "INSERT INTO Producto (nombre, descripcion, precio, img, stock, idcategoria) "+ string sql = "INSERT INTO Producto (nombre, descripcion, precio, img, stock, idcategoria) "+
"VALUES (@nombre, @descripcion, @precio, @stock, @img, @idcategoria)"; "VALUES (@nombre, @descripcion, @precio, @stock, @img, @idcategoria)";
string rutaDestino = guardarImg(producto.img); if (!producto.img.Equals(""))
{
string rutaDestino = guardarImg(producto.img);
producto.img = rutaDestino;
}
using (SQLiteCommand command = new SQLiteCommand(sql, conexion)) using (SQLiteCommand command = new SQLiteCommand(sql, conexion))
{ {
@@ -118,7 +123,7 @@ namespace compabetov2.database
command.Parameters.AddWithValue("@descripcion", producto.descripcion); command.Parameters.AddWithValue("@descripcion", producto.descripcion);
command.Parameters.AddWithValue("@precio", producto.precion); command.Parameters.AddWithValue("@precio", producto.precion);
command.Parameters.AddWithValue("@stock", producto.stock); command.Parameters.AddWithValue("@stock", producto.stock);
command.Parameters.AddWithValue("@img", rutaDestino); command.Parameters.AddWithValue("@img", producto.img);
command.Parameters.AddWithValue("@idcategoria", producto.categoria.idCategoria); command.Parameters.AddWithValue("@idcategoria", producto.categoria.idCategoria);
int filasAfectadas = command.ExecuteNonQuery(); int filasAfectadas = command.ExecuteNonQuery();