diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json index ab51f88..82df575 100644 --- a/.vs/VSWorkspaceState.json +++ b/.vs/VSWorkspaceState.json @@ -1,7 +1,9 @@ { "ExpandedNodes": [ - "" + "", + "\\database", + "\\database\\modelos" ], - "SelectedNode": "\\compabetov2.sln", + "SelectedNode": "\\database\\DAO.cs", "PreviewInSolutionExplorer": false } \ No newline at end of file diff --git a/.vs/compabetoOG/v17/.wsuo b/.vs/compabetoOG/v17/.wsuo index 4445312..4a738b9 100644 Binary files a/.vs/compabetoOG/v17/.wsuo and b/.vs/compabetoOG/v17/.wsuo differ diff --git a/database/DAO.cs b/database/DAO.cs index 567f2ff..2759ea4 100644 --- a/database/DAO.cs +++ b/database/DAO.cs @@ -109,8 +109,13 @@ namespace compabetov2.database string sql = "INSERT INTO Producto (nombre, descripcion, precio, img, stock, 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)) { @@ -118,7 +123,7 @@ namespace compabetov2.database command.Parameters.AddWithValue("@descripcion", producto.descripcion); command.Parameters.AddWithValue("@precio", producto.precion); command.Parameters.AddWithValue("@stock", producto.stock); - command.Parameters.AddWithValue("@img", rutaDestino); + command.Parameters.AddWithValue("@img", producto.img); command.Parameters.AddWithValue("@idcategoria", producto.categoria.idCategoria); int filasAfectadas = command.ExecuteNonQuery();