public List <Produto> SelectXML(int codigoMercado, double p1, string p2) { List <Produto> lista = new List <Produto>(); SqlCommand command = new SqlCommand(); command.CommandText = "SELECT Produto FROM Setor where codigomercado = @cod "; command.Parameters.AddWithValue("@cod", codigoMercado); List <string> xml = new DBExecuter().GetStringXML(command); foreach (string item in xml) { XmlSerializer serializer = new XmlSerializer(typeof(List <Produto>)); byte[] buffer = Encoding.UTF8.GetBytes(item); using (MemoryStream memory = new MemoryStream(buffer)) { List <Produto> produtos = (List <Produto>)serializer.Deserialize(memory); foreach (var p in produtos) { if (p.Nome == p2 && p.Peso == p1) { lista.Add(p); } } } } return(lista); }
public List <Produto> SelectXML(SqlCommand Where) { List <Produto> lista = new List <Produto>(); SqlCommand command = new SqlCommand(); command.CommandText = "SELECT Produto FROM Setor "; command.CommandText += Where.CommandText; foreach (SqlParameter item in Where.Parameters) { command.Parameters.Add(new SqlParameter(item.ParameterName, item.Value)); } List <string> xml = new DBExecuter().GetStringXML(command); //XmlSerializer serializer = new XmlSerializer(typeof(Produto)); foreach (string item in xml) { XmlSerializer serializer = new XmlSerializer(typeof(List <Produto>)); byte[] buffer = Encoding.UTF8.GetBytes(item); using (MemoryStream ms = new MemoryStream(buffer)) { lista.AddRange((List <Produto>)serializer.Deserialize(ms)); } } return(lista); }
public List <Supermercado> GetALL() { SqlCommand command = new SqlCommand(); command.CommandText = "SELECT * FROM Supermercado"; DataTable table = new DBExecuter().GetData(command); if (table.Rows.Count == 0) { return(null); } return(table.ToObjectCollection <Supermercado>()); }
public List <string> SelectSetores(SqlCommand Where) { SqlCommand command = new SqlCommand(); command.CommandText = "SELECT Nome FROM Setor "; command.CommandText += Where.CommandText; foreach (SqlParameter item in Where.Parameters) { command.Parameters.Add(new SqlParameter(item.ParameterName, item.Value)); } List <string> lista = new DBExecuter().GetSetorString(command); //XmlSerializer serializer = new XmlSerializer(typeof(Produto)); return(lista); }
public List <Supermercado> GetALL(SqlCommand Where) { SqlCommand command = new SqlCommand(); command.CommandText = "SELECT * FROM Supermercado "; command.CommandText += Where.CommandText; foreach (SqlParameter item in Where.Parameters) { command.Parameters.Add(new SqlParameter(item.ParameterName, item.Value)); } DataTable table = new DBExecuter().GetData(command); if (table.Rows.Count == 0) { return(null); } return(table.ToObjectCollection <Supermercado>()); }
public List <Produto> SelectXML(string where) { List <Produto> lista = new List <Produto>(); SqlCommand command = new SqlCommand(); command.CommandText = "SELECT Produto FROM Setor " + where; string xml = new DBExecuter().GetStringXML(command); //XmlSerializer serializer = new XmlSerializer(typeof(Produto)); XmlSerializer serializer = new XmlSerializer(typeof(List <Produto>)); byte[] buffer = Encoding.UTF8.GetBytes(xml); using (MemoryStream ms = new MemoryStream(buffer)) { lista = (List <Produto>)serializer.Deserialize(ms); } return(lista); }