public List <Categoria> BuscarCategorias(string ToSearch) { DDBBGateway ddbbData = new DDBBGateway(); Categoria aux; List <Categoria> Resultados = new List <Categoria>(); ToSearch = ToSearch.ToLower(); try { ddbbData.prepareQuery("select Id, Descripcion from CATEGORIAS where Descripcion like lower('%" + ToSearch + "%');"); ddbbData.sendQuery(); while (ddbbData.getReader().Read()) { aux = new Categoria((Int32)ddbbData.getReader()["Id"], ddbbData.getReader()["Descripcion"].ToString()); Resultados.Add(aux); } return(Resultados); } catch (Exception) { throw; } finally { ddbbData.closeConnection(); } }
public List <Cliente> getCliente(string toSearch) { try { DDBBGateway data = new DDBBGateway(); List <Cliente> aux = new List <Cliente>(); data.prepareQuery("select Id, DNI, Nombre, Apellido, Email, Direccion, Ciudad, CodigoPostal, FechaRegistro from Clientes where DNI = " + toSearch); data.sendQuery(); while (data.getReader().Read()) { aux.Add(new Cliente( (Int64)data.getReader()["Id"], (int)data.getReader()["DNI"], data.getReader()["Nombre"].ToString(), data.getReader()["Apellido"].ToString(), data.getReader()["Email"].ToString(), data.getReader()["Direccion"].ToString(), data.getReader()["Ciudad"].ToString(), data.getReader()["CodigoPostal"].ToString(), (DateTime)data.getReader()["FechaRegistro"] )); } data.closeConnection(); return(aux); } catch (Exception ex) { throw ex; } }
public List <Marca> buscarMarca(string toSearch) { Marca reg; List <Marca> results = new List <Marca>(); DDBBGateway ddbbData = new DDBBGateway(); try { ddbbData.prepareQuery("select Id ,Descripcion from MARCAS where LOWER(Descripcion) like '%" + toSearch.ToLower() + "%';"); ddbbData.sendQuery(); while (ddbbData.getReader().Read()) { reg = new Marca((Int32)ddbbData.getReader()["Id"], ddbbData.getReader()["Descripcion"].ToString()); results.Add(reg); } return(results); } catch (Exception ex) { throw ex; } finally { ddbbData = null; } }
public List <Categoria> listarCategorias() { DDBBGateway ddbbData = new DDBBGateway(); Categoria aux; List <Categoria> resultados = new List <Categoria>(); try { ddbbData.prepareQuery("select id, Descripcion from CATEGORIAS;"); ddbbData.sendQuery(); while (ddbbData.getReader().Read()) { aux = new Categoria((Int32)ddbbData.getReader()["id"], ddbbData.getReader()["Descripcion"].ToString()); resultados.Add(aux); } return(resultados); } catch (Exception ex) { throw ex; } finally { ddbbData.closeConnection(); } }
public List <Marca> listarMarcas() { Marca aux; List <Marca> listaMarcas = new List <Marca>(); DDBBGateway ddbbData = new DDBBGateway(); try { ddbbData.prepareQuery("select Id, Descripcion from MARCAS"); ddbbData.sendQuery(); while (ddbbData.getReader().Read()) { aux = new Marca((Int32)ddbbData.getReader()["Id"], ddbbData.getReader()["Descripcion"].ToString()); listaMarcas.Add(aux); } return(listaMarcas); } catch (Exception ex) { throw ex; } finally { ddbbData = null; } }
public List <Voucher> getVoucherByID(string voucherCode) { try { DDBBGateway DDBB = new DDBBGateway(); DDBB.prepareQuery("select Id, CodigoVoucher, Estado, IdCliente, IdProducto, FechaRegistro from Vouchers where Estado = 0 and Id = '" + voucherCode + "'"); DDBB.sendQuery(); List <Voucher> vouchersList = new List <Voucher>(); Voucher aux = new Voucher(); while (DDBB.getReader().Read()) { aux.ID = (Int64)DDBB.getReader()["Id"]; aux.CodigoVoucher = DDBB.getReader()["CodigoVoucher"].ToString(); aux.Estado = (bool)DDBB.getReader()["Estado"]; if (!Convert.IsDBNull(DDBB.getReader()["IdCliente"])) { aux.IdCliente = (int)DDBB.getReader()["IdCliente"]; } else { aux.IdCliente = null; } if (!Convert.IsDBNull(DDBB.getReader()["IdProducto"])) { aux.IdProducto = (int)DDBB.getReader()["IdProducto"]; } else { aux.IdProducto = null; } if (!Convert.IsDBNull(DDBB.getReader()["FechaRegistro"])) { aux.FechaRegistro = (DateTime)DDBB.getReader()["FechaRegistro"]; } else { aux.FechaRegistro = null; } vouchersList.Add(aux); } return(vouchersList); } catch (Exception ex) { throw ex; } }
public List <Articulo> BuscarArticulos(string ToSearch) { DDBBGateway ddbbData = new DDBBGateway(); List <Articulo> aux = new List <Articulo>(); try { ddbbData.prepareQuery("select A.Id, A.Codigo, A.Nombre, A.Descripcion, " + "M.Id as 'IdMarca', M.Descripcion as 'Marca', " + "C.Id as 'IdDescripcion', C.Descripcion as 'Categoria', " + "A.Imagen, A.Precio from ARTICULOS as A inner join MARCAS" + " as M on (A.IdMarca = M.Id) inner join CATEGORIAS as C on " + "( A.IdCategoria = C.Id )" + "where A.Descripcion like lower('%" + ToSearch + "%') or Nombre like lower('%" + ToSearch + "%'); "); ddbbData.sendQuery(); while (ddbbData.getReader().Read()) { aux.Add(new Articulo( (Int32)ddbbData.getReader()["Id"], ddbbData.getReader()["Codigo"].ToString(), ddbbData.getReader()["Nombre"].ToString(), ddbbData.getReader()["Descripcion"].ToString(), (Int32)ddbbData.getReader()["IdMarca"], ddbbData.getReader()["Marca"].ToString(), (Int32)ddbbData.getReader()["IdDescripcion"], ddbbData.getReader()["Categoria"].ToString(), ddbbData.getReader()["Imagen"].ToString(), (Decimal)ddbbData.getReader()["Precio"] )); } return(aux); } catch (Exception) { throw; } finally { ddbbData.closeConnection(); } }
public bool eliminaciónFisicaArticulo(Articulo aBorrar) { try { DDBBGateway data = new DDBBGateway(); data.prepareQuery("delete from ARTICULOS where Codigo = @codigo"); data.addParameter("@codigo", aBorrar.codigo); data.sendStatement(); if (data.getAffectedRows() <= 0) { return(false); } else { return(true); } } catch (Exception ex) { throw ex; } }
public List <Articulo> getArticulosBySearch(string term) { try { List <Articulo> resultados = new List <Articulo>(); DDBBGateway data = new DDBBGateway(); data.prepareQuery("select ARTICULOS.Id, ARTICULOS.Codigo, ARTICULOS.Nombre, ARTICULOS.Descripcion, " + "MARCAS.Id as 'IdMarca', MARCAS.Descripcion as 'DescripcionMarca', CATEGORIAS.Id as 'IdCategoria'," + " CATEGORIAS.Descripcion as 'DescripcionCategoria', ARTICULOS.ImagenUrl, ARTICULOS.Precio from ARTICULOS " + "inner join MARCAS on ( ARTICULOS.IdMarca = MARCAS.Id ) inner join CATEGORIAS on ( ARTICULOS.IdCategoria " + "= CATEGORIAS.Id ) where ARTICULOS.Codigo like '%' + @termino+ '%' or ARTICULOS.Nombre like '%' + @termino+ '%' or " + "MARCAS.Descripcion like '%' + @termino+ '%' or CATEGORIAS.Descripcion like '%' + @termino+ '%' or ARTICULOS.Precio " + "like '%' + @termino+ '%'"); data.addParameter("@termino", term); data.sendQuery(); while (data.getReader().Read()) { Articulo aux = new Articulo(); aux.id = (int)data.getReader()["Id"]; aux.codigo = (string)data.getReader()["Codigo"]; aux.nombre = (string)data.getReader()["Nombre"]; aux.descripcion = (string)data.getReader()["Descripcion"]; aux.marca.id = (int)data.getReader()["IdMarca"]; aux.marca.descripcion = (string)data.getReader()["DescripcionMarca"]; aux.categoria.id = (int)data.getReader()["IdCategoria"]; aux.categoria.descripcion = (string)data.getReader()["DescripcionCategoria"]; aux.imagen = (string)data.getReader()["ImagenUrl"]; aux.precio = double.Parse(data.getReader()["Precio"].ToString()); resultados.Add(aux); } return(resultados); } catch (Exception ex) { throw ex; } }
public List <Categoria> getCategorias() { try { DDBBGateway data = new DDBBGateway(); data.prepareQuery("select id, Descripcion from CATEGORIAS"); data.sendQuery(); List <Categoria> categorias = new List <Categoria>(); while (data.getReader().Read()) { Categoria aux = new Categoria(); aux.id = (int)data.getReader()["id"]; aux.descripcion = (string)data.getReader()["Descripcion"]; categorias.Add(aux); } return(categorias); } catch (Exception ex) { throw ex; } }
public List <Marca> getMarcas() { try { DDBBGateway data = new DDBBGateway(); data.prepareQuery("select id, Descripcion from MARCAS"); data.sendQuery(); List <Marca> marcas = new List <Marca>(); while (data.getReader().Read()) { Marca aux = new Marca(); aux.id = (int)data.getReader()["id"]; aux.descripcion = (string)data.getReader()["Descripcion"]; marcas.Add(aux); } return(marcas); } catch (Exception ex) { throw ex; } }
public Articulo getArticuloByID(int idABuscar) { try { Articulo articulo = new Articulo(); DDBBGateway data = new DDBBGateway(); data.prepareQuery("select ARTICULOS.Id, ARTICULOS.Codigo, ARTICULOS.Nombre, ARTICULOS.Descripcion, MARCAS.Id as 'IdMarca', " + "MARCAS.Descripcion as 'DescripcionMarca', CATEGORIAS.Id as 'IdCategoria', CATEGORIAS.Descripcion as " + "'DescripcionCategoria', ARTICULOS.ImagenUrl, ARTICULOS.Precio from ARTICULOS inner join MARCAS on ( " + "ARTICULOS.IdMarca = MARCAS.Id ) inner join CATEGORIAS on ( ARTICULOS.IdCategoria = CATEGORIAS.Id ) " + "where ARTICULOS.ID = @buscarID"); data.addParameter("@buscarID", idABuscar); data.sendQuery(); while (data.getReader().Read()) { Articulo aux = new Articulo(); aux.id = (int)data.getReader()["Id"]; aux.codigo = (string)data.getReader()["Codigo"]; aux.nombre = (string)data.getReader()["Nombre"]; aux.descripcion = (string)data.getReader()["Descripcion"]; aux.marca.id = (int)data.getReader()["IdMarca"]; aux.marca.descripcion = (string)data.getReader()["DescripcionMarca"]; aux.categoria.id = (int)data.getReader()["IdCategoria"]; aux.categoria.descripcion = (string)data.getReader()["DescripcionCategoria"]; aux.imagen = (string)data.getReader()["ImagenUrl"]; aux.precio = double.Parse(data.getReader()["Precio"].ToString()); articulo = aux; } return(articulo); } catch (Exception ex) { throw ex; } }
public string getProductoTituloByID(string _ID) { try { DDBBGateway data = new DDBBGateway(); List <Producto> aux = new List <Producto>(); data.prepareQuery("select Id, Titulo, Descripcion, URLImagen from Productos where Id = '" + _ID + "'"); data.sendQuery(); while (data.getReader().Read()) { aux.Add(new Producto( (Int64)data.getReader()["Id"], data.getReader()["Titulo"].ToString(), data.getReader()["Descripcion"].ToString(), data.getReader()["URLImagen"].ToString())); } return(aux[0].Titulo.ToString()); } catch (Exception ex) { throw ex; } }
public List <Articulo> getArticulos() { try { List <Articulo> articulos = new List <Articulo>(); DDBBGateway data = new DDBBGateway(); data.prepareQuery("select ARTICULOS.Id, ARTICULOS.Codigo, ARTICULOS.Nombre, ARTICULOS.Descripcion, MARCAS.Id as 'IdMarca', " + "MARCAS.Descripcion as 'DescripcionMarca', CATEGORIAS.Id as 'IdCategoria', CATEGORIAS.Descripcion as " + "'DescripcionCategoria', ARTICULOS.ImagenUrl, ARTICULOS.Precio from ARTICULOS inner join MARCAS on ( " + "ARTICULOS.IdMarca = MARCAS.Id ) inner join CATEGORIAS on ( ARTICULOS.IdCategoria = CATEGORIAS.Id )"); data.sendQuery(); while (data.getReader().Read()) { Articulo aux = new Articulo(); aux.id = (int)data.getReader()["Id"]; aux.codigo = (string)data.getReader()["Codigo"]; aux.nombre = (string)data.getReader()["Nombre"]; aux.descripcion = (string)data.getReader()["Descripcion"]; aux.marca.id = (int)data.getReader()["IdMarca"]; aux.marca.descripcion = (string)data.getReader()["DescripcionMarca"]; aux.categoria.id = (int)data.getReader()["IdCategoria"]; aux.categoria.descripcion = (string)data.getReader()["DescripcionCategoria"]; aux.imagen = (string)data.getReader()["ImagenUrl"]; aux.precio = double.Parse(data.getReader()["Precio"].ToString()); articulos.Add(aux); } return(articulos); } catch (Exception ex) { throw ex; } }