Пример #1
0
 public Usuario buscarUsuario(string cuentaUsuario, string claveUsuario)
 {
     try
     {
         Usuario       usuario     = null;
         string        consultaSQL = "SELECT codigousuario, nombreusuario, cuentausuario, claveusuario  FROM usuario where cuentausuario=@cuentausuario and claveusuario=@claveusuario ";
         SqlCommand    sentencia;
         SqlDataReader resultado;
         sentencia = gestorODBC.prepararSentencia(consultaSQL);
         sentencia.Parameters.Add("@cuentausuario", VarChar, 100).Value = cuentaUsuario;
         sentencia.Parameters.Add("@claveusuario", VarChar, 100).Value  = claveUsuario;
         resultado = sentencia.ExecuteReader();
         if (resultado.Read())
         {
             usuario = new Usuario();
             usuario.codigoUsuario = (int)resultado[0];
             usuario.nombreUsuario = (string)resultado[1];
             usuario.cuentaUsuario = (string)resultado[2];
             usuario.claveUsuario  = (string)resultado[3];
         }
         resultado.Close();
         return(usuario);
     }
     catch (Exception)
     {
         throw ExcepcionSQL.crearErrorConsultar();
     }
 }
Пример #2
0
 public ProductoImagen buscarImagenPrincipalProducto(Producto producto)
 {
     try
     {
         ProductoImagen productoImagen = null;
         string         consultaSQL    = "SELECT img.codigoimagenproducto,  img.direccionimagenproducto, img.nombreimagenproducto, img.principalimagenproducto  FROM imagenproducto img where img.codigoproducto=@codigoproducto and img.principalimagenproducto='TRUE'";
         SqlDataReader  resultado;
         SqlCommand     sentencia;
         sentencia = gestorODBC.prepararSentencia(consultaSQL);
         sentencia.Parameters.Add("@codigoproducto", Int).Value = producto.codigoProducto;
         resultado = sentencia.ExecuteReader();
         if (resultado.Read())
         {
             productoImagen = new ProductoImagen();
             productoImagen.codigoimagen = (int)resultado[0];
             productoImagen.urlimagen    = (string)resultado[1];
             productoImagen.nombreimagen = (string)resultado[2];
             productoImagen.principal    = (bool)resultado[3];
         }
         resultado.Close();
         return(productoImagen);
     }
     catch (Exception)
     {
         throw ExcepcionSQL.crearErrorConsultar();
     }
 }
Пример #3
0
 public Producto buscarProducto(int codigoProducto)
 {
     try
     {
         Producto      producto    = null;
         string        consultaSQL = "select  p.codigoproducto, p.nombreproducto, p.descripcionproducto,p.detallesproducto, p.precioproducto  from producto p where p.codigoproducto= @codigoProducto ";
         SqlCommand    sentencia;
         SqlDataReader resultado;
         sentencia = gestorODBC.prepararSentencia(consultaSQL);
         sentencia.Parameters.Add("@codigoProducto", Int).Value = codigoProducto;
         resultado = sentencia.ExecuteReader();
         if (resultado.Read())
         {
             producto = new Producto();
             producto.codigoProducto      = (int)resultado[0];
             producto.nombreProducto      = (string)resultado[1];
             producto.descripcionProducto = (string)resultado[2];
             producto.detalleProducto     = (string)resultado[3];
             producto.precioProducto      = (decimal)resultado[4];
             ImagenProductoDAOSqlServer imagenProductoDAO = new ImagenProductoDAOSqlServer(gestorODBC);
             producto.listaImagenes = imagenProductoDAO.listarImagenesPorProducto(producto);
         }
         resultado.Close();
         return(producto);
     }
     catch (Exception)
     {
         throw ExcepcionSQL.crearErrorConsultar();
     }
 }
 public SubCategoria buscarProductosPorSubCategoria(int codigoSubCategoria)
 {
     try
     {
         SubCategoria  subCategoria = null;
         string        consultaSQL  = "SELECT sc.codigosubcategoria,sc.nombresubcategoria FROM subcategoria sc where sc.codigosubcategoria=@codigosubcategoria";
         SqlDataReader resultado;
         SqlCommand    sentencia;
         sentencia = gestorODBC.prepararSentencia(consultaSQL);
         sentencia.Parameters.Add("@codigosubcategoria", Int).Value = codigoSubCategoria;
         resultado = sentencia.ExecuteReader();
         if (resultado.Read())
         {
             subCategoria = new SubCategoria();
             subCategoria.codigosubcategoria     = (int)resultado[0];
             subCategoria.nombresubcategoria     = (string)resultado[1];
             subCategoria.listaLineaSubCategoria = listaLineaSubCategoria(subCategoria);
         }
         resultado.Close();
         return(subCategoria);
     }
     catch (Exception)
     {
         throw ExcepcionSQL.crearErrorConsultar();
     }
 }
 public Categoria buscarCategoria(int codigocategoria)
 {
     try
     {
         Categoria     categoria   = null;
         string        consultaSQL = "select codigocategoria,nombrecategoria from categoria where codigocategoria = @codigocategoria";
         SqlDataReader resultado;
         SqlCommand    sentencia;
         sentencia = gestorODBC.prepararSentencia(consultaSQL);
         sentencia.Parameters.Add("@codigocategoria", Int).Value = codigocategoria;
         resultado = sentencia.ExecuteReader();
         if (resultado.Read())
         {
             categoria = new Categoria();
             categoria.codigocategoria = (int)resultado[0];
             categoria.nombrecategoria = (string)resultado[1];
         }
         resultado.Close();
         return(categoria);
     }
     catch (Exception)
     {
         throw ExcepcionSQL.crearErrorConsultar();;
     }
 }
 public void agregarVisto(Contacto contacto)
 {
     try
     {
         string     sentenciaSQL = "UPDATE contacto  SET vistocontacto='TRUE' WHERE codigocontacto = @codigocontacto";
         SqlCommand sentencia;
         sentencia = gestorODBC.prepararSentencia(sentenciaSQL);
         sentencia.Parameters.Add("@codigocontacto", Int).Value = contacto.codigoContacto;
         sentencia.ExecuteNonQuery();
     }
     catch (Exception)
     {
         throw ExcepcionSQL.crearErrorModificar();
     }
 }
 public LineaSubCategoria buscarLineaSubCategoria(int codigoLineaSubCategoria)
 {
     try
     {
         LineaSubCategoria lineaSubCategoria = null;
         string            consultaSQL       = "SELECT codigolineasubcategoria, nombrelineasubcategoria  FROM lineasubcategoria where codigolineasubcategoria=@codigolineasubcategoria";
         SqlDataReader     resultado;
         SqlCommand        sentencia;
         sentencia = gestorODBC.prepararSentencia(consultaSQL);
         sentencia.Parameters.Add("@codigolineasubcategoria", Int).Value = codigoLineaSubCategoria;
         resultado = sentencia.ExecuteReader();
         if (resultado.Read())
         {
             lineaSubCategoria             = new LineaSubCategoria();
             lineaSubCategoria.codigolinea = (int)resultado[0];
             lineaSubCategoria.nombrelinea = (string)resultado[1];
         }
         resultado.Close();
         return(lineaSubCategoria);
     }
     catch (Exception)
     {
         throw ExcepcionSQL.crearErrorConsultar();
     }
 }