caso de producto sin imagen
This commit is contained in:
@@ -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
@@ -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();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user