Пример #1
0
        public string ActualizarProducto(string idProdAnt, string idProdNuevo, string nombre, string stock, string precioReal, string precio, string nombreCategoria, DateTime fecha)
        {
            //Boolean guardar = false;
            string res = "";

            try
            {

                categoriaFacade ctf = new categoriaFacade();
                string idCategoria = ctf.getCategoriaByNombre(nombreCategoria);

                string consultinsert = "UPDATE  producto SET idProducto=@idProdNuevo,nombre=@nombre,stock=@stock,precioReal=@precioReal,precio=@precio,idCategoria=@idCategoria,fecha=@fecha WHERE idProducto=@idProdAnt";


                MySqlCommand comm = new MySqlCommand(consultinsert, getconexion.getConexion());
                comm.Parameters.AddWithValue("@idProdNuevo", idProdNuevo);
                comm.Parameters.AddWithValue("@nombre", nombre);
                comm.Parameters.AddWithValue("@stock", stock);
                comm.Parameters.AddWithValue("@PrecioReal", precioReal);
                comm.Parameters.AddWithValue("@precio", precio);
                comm.Parameters.AddWithValue("@idCategoria", idCategoria);
                comm.Parameters.AddWithValue("@fecha", fecha);
                comm.Parameters.AddWithValue("@idProdAnt", idProdAnt);

                MySqlDataReader MyReader2 = comm.ExecuteReader();
                ctf.actualizarFechaCategoria(idCategoria);
            }
            catch (Exception e)
            {
                res = e.ToString();
                getconexion.CerrarConexion();
            }
            finally
            {
                getconexion.CerrarConexion();
            }


            return res;

        }