Beispiel #1
0
        public int InsertarProducto(Producto producto, int idDetalleProducto)
        {
            SqlCommand cmd = new SqlCommand("_spInsertarProducto");

            try
            {
                cmd = _gestorDaoSql.ObtenerComandoSp(cmd);
                cmd.Parameters.AddWithValue("@prmstrNombre", producto.Nombre);
                cmd.Parameters.AddWithValue("@prmstrDescripcion", producto.Descripcion);
                cmd.Parameters.AddWithValue("@prmintIdCategoria", producto.Categoria.IdCategoria);
                cmd.Parameters.AddWithValue("@prmintIdDetalleProducto", idDetalleProducto);
                cmd.Parameters.Add(new SqlParameter("@IdProducto", DbType.Int32)
                {
                    Direction = ParameterDirection.ReturnValue
                });
                cmd.ExecuteNonQuery();

                var IdProducto = Convert.ToInt32(cmd.Parameters["@IdProducto"].Value);
                return(IdProducto);
            }
            catch (Exception x)
            {
                throw x;
            }
        }
Beispiel #2
0
        public int InsertarDetalleProducto(DetalleProducto detalleProducto)
        {
            SqlCommand cmd = new SqlCommand("_spInsertarDetalleProducto");

            try
            {
                cmd = _gestorDaoSql.ObtenerComandoSp(cmd);
                cmd.Parameters.AddWithValue("@prmdcmpreciocosto", detalleProducto.PrecioCosto);
                cmd.Parameters.AddWithValue("@prmdcmprecioventa", detalleProducto.PrecioVenta);
                cmd.Parameters.AddWithValue("@prmintstock", detalleProducto.Stock);

                cmd.Parameters.Add(new SqlParameter("@iddetalleproducto", DbType.Int32)
                {
                    Direction = ParameterDirection.ReturnValue
                });
                cmd.ExecuteNonQuery();

                int idDetalleProducto = Convert.ToInt32(cmd.Parameters["@iddetalleproducto"].Value);
                return(idDetalleProducto);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }