public List <Clases.Productos> Consulta7(ref List <Clases.vendedores> vendedores, ref List <Clases.ventas> ventas, string nombre) { string query = "SELECT Vendedores.Nombre, Vendedores.Apellido, p.Nombre, v.Cantidad, v.MontoTotal FROM Vendedores, productos as p, ventas as v WHERE vendedores.nombre='" + nombre + "' and vendedores.idVendedores=v.idVendedor and v.idProducto=p.idProductos"; List <Clases.Productos> list = new List <Clases.Productos>(); MySqlCommand commandDatabase = new MySqlCommand(query, databaseConnection); commandDatabase.CommandTimeout = 60; MySqlDataReader reader; try { databaseConnection.Open(); reader = commandDatabase.ExecuteReader(); while (reader.Read()) { Clases.Productos productos = new Clases.Productos(); Clases.vendedores vendedor = new Clases.vendedores(); Clases.ventas venta = new Clases.ventas(); vendedor.Nombre = Convert.ToString(reader.GetValue(0)); vendedor.Apellido = Convert.ToString(reader.GetValue(1)); productos.Nombre = Convert.ToString(reader.GetValue(2)); venta.Cantidad = Convert.ToInt32(reader.GetValue(3)); venta.MontoTotal = Convert.ToInt32(reader.GetValue(4)); ventas.Add(venta); vendedores.Add(vendedor); list.Add(productos); } databaseConnection.Close(); return(list); } catch (Exception) { return(list); } }
public List <Clases.Productos> Consulta5(ref List <Clases.proveedores> proveedores) { string query = "select p.Nombre,prov.Nombre from Proveedores as prov,Productos as p,Compras as c where C.idProveedor =prov.idProveedores and c.idProductos=p.idProductos"; List <Clases.Productos> list = new List <Clases.Productos>(); MySqlCommand commandDatabase = new MySqlCommand(query, databaseConnection); commandDatabase.CommandTimeout = 60; MySqlDataReader reader; try { databaseConnection.Open(); reader = commandDatabase.ExecuteReader(); while (reader.Read()) { Clases.Productos productos = new Clases.Productos(); Clases.proveedores proveedor = new Clases.proveedores(); productos.Nombre = Convert.ToString(reader.GetValue(0)); proveedor.Nombre = Convert.ToString(reader.GetValue(1)); proveedores.Add(proveedor); list.Add(productos); } databaseConnection.Close(); return(list); } catch (Exception) { return(list); } }
public List <Clases.Productos> consultaProductos(string xquery) { List <Clases.Productos> lista = new List <Clases.Productos>(); string connectionString = "datasource=127.0.0.1;port=3306;username=root;password=;database=ferreteria;"; // Seleccionar todo string query = xquery; MySqlConnection databaseConnection = new MySqlConnection(connectionString); MySqlCommand commandDatabase = new MySqlCommand(query, databaseConnection); commandDatabase.CommandTimeout = 60; MySqlDataReader reader; try { databaseConnection.Open(); reader = commandDatabase.ExecuteReader(); Clases.Productos Producto = new Clases.Productos(); while (reader.Read()) //Linea sea null { Producto.IdProducto = reader.GetInt32(0); Producto.Nombre = Convert.ToString(reader.GetString(1)); Producto.Precio = Convert.ToInt32(reader.GetInt32(2)); Producto.Cantidad = Convert.ToInt32(reader.GetInt32(3)); Producto.Rubro = Convert.ToInt32(reader.GetInt32(4)); // lista.Add(Convert.ToString(reader.GetString(1)) + " " + Convert.ToString(reader.GetString(2)) + " " + "/"); lista.Add(Producto); } databaseConnection.Close(); return(lista); } catch (Exception ex) { return(lista); } }
public List <Clases.Productos> Consulta10(string nombre) { string query = "select nombre,cantidad,precio from Productos where not exists(select* from Rubro where not exists(select* from Productos as PX where(PX.nombre like '%" + nombre + "%' and Productos.nombre like '%" + nombre + "%') and PX.idRubro = Rubro.idRubro)) and nombre like '%" + nombre + "%'"; List <Clases.Productos> list = new List <Clases.Productos>(); MySqlCommand commandDatabase = new MySqlCommand(query, databaseConnection); commandDatabase.CommandTimeout = 60; MySqlDataReader reader; try { databaseConnection.Open(); reader = commandDatabase.ExecuteReader(); while (reader.Read()) { Clases.Productos productos = new Clases.Productos(); productos.Nombre = Convert.ToString(reader.GetValue(0)); productos.Cantidad = Convert.ToInt32(reader.GetValue(1)); productos.Precio = Convert.ToInt32(reader.GetValue(2)); list.Add(productos); } databaseConnection.Close(); return(list); } catch (Exception) { return(list); } }
public List <Clases.Productos> ConsultaProductosCarga() { string query = "SELECT * FROM Productos"; List <Clases.Productos> list = new List <Clases.Productos>(); MySqlCommand commandDatabase = new MySqlCommand(query, databaseConnection); commandDatabase.CommandTimeout = 60; MySqlDataReader reader; try { databaseConnection.Open(); reader = commandDatabase.ExecuteReader(); while (reader.Read()) { Clases.Productos Producto = new Clases.Productos(); Producto.IdProducto = Convert.ToInt32(reader.GetValue(0)); Producto.Nombre = Convert.ToString(reader.GetValue(1)); Producto.Precio = Convert.ToInt32(reader.GetValue(2)); Producto.Cantidad = Convert.ToInt32(reader.GetValue(3)); Producto.Rubro = Convert.ToInt32(reader.GetValue(4)); list.Add(Producto); } databaseConnection.Close(); return(list); } catch (Exception) { return(list); } }
public List <Clases.Productos> Consulta4() { string query = "SELECT Nombre, precio,cantidad FROM Productos WHERE cantidad = 0"; List <Clases.Productos> list = new List <Clases.Productos>(); MySqlCommand commandDatabase = new MySqlCommand(query, databaseConnection); commandDatabase.CommandTimeout = 60; MySqlDataReader reader; try { databaseConnection.Open(); reader = commandDatabase.ExecuteReader(); while (reader.Read()) { Clases.Productos productos = new Clases.Productos(); productos.Nombre = Convert.ToString(reader.GetValue(0)); productos.Precio = Convert.ToInt32(reader.GetValue(1)); productos.Cantidad = Convert.ToInt32(reader.GetValue(2)); list.Add(productos); } databaseConnection.Close(); return(list); } catch (Exception) { return(list); } }