public static M_ListaPedido ConvertToDomain(ListaPedido c)
 {
     return(new M_ListaPedido
     {
         IDPedido = c.IDPedido,
         IDProducto = c.IDProducto,
         cantidad = c.cantidad,
     });
 }
Beispiel #2
0
        private List <ListaPedido> Converter(DataSet ds)
        {
            List <ListaPedido> lista = new List <ListaPedido>();

            if (ds != null && ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    ListaPedido listaPedido = new ListaPedido
                    {
                        ID_PEDIDO = row.Field <int>("ID_PEDIDO"),
                        ID_LANCHE = row.Field <int>("ID_LANCHE"),
                        NM_LANCHE = row.Field <string>("NM_LANCHE").Trim(),
                        QT_LANCHE = row.Field <int>("QT_LANCHE"),
                        VL_TOTAL  = row.Field <decimal>("VL_TOTAL")
                    };
                    lista.Add(listaPedido);
                }
            }
            return(lista);
        }
Beispiel #3
0
            public static ListaPedido RetornarPedido()
            {
                try
                {
                    con = ConnectionFactory.getConnection();
                    con.Open();

                    comando = "SELECT IdPedido, u.Nome AS Nome_Solicitante, p.Descricao AS Nome_Produto, e.CEP, e.Estado, e.Cidade, e.Bairro, e.Logradouro, e.Numero, e.Complemento, DataDeEntrega " +
                              "FROM Pedido pe INNER JOIN Produto p  ON pe.IdProduto = p.IdProduto  " +
                              "INNER JOIN Endereco e ON e.IdEndereco = pe.IdEndereco " +
                              "INNER JOIN Usuario u ON pe.IdUsuario = u.IdUsuario  " +
                              "ORDER BY DataDeEntrega; ";

                    XmlSerializer ser = new XmlSerializer(typeof(ListaPedido));
                    list = new ListaPedido();

                    using (var cmd = con.CreateCommand())
                    {
                        cmd.CommandText = comando.ToString();
                        using (var rdr = cmd.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                list.Items.Add(new Pedido
                                {
                                    IdPedido        = rdr.GetInt32(0),
                                    NomeSolicitante = rdr.GetString(1),
                                    NomeProduto     = rdr.GetString(2),
                                    CEP             = rdr.GetString(3),
                                    Estado          = rdr.GetString(4),
                                    Cidade          = rdr.GetString(5),
                                    Bairro          = rdr.GetString(6),
                                    Logradouro      = rdr.GetString(7),
                                    Numero          = rdr.GetInt32(8),
                                    Complemento     = rdr.GetString(9),
                                    DataDeEntrega   = rdr.GetDateTime(10).ToString("dd/MM/yyyy").Replace("-", "/"),
                                });
                            }
                        }
                        cmd.Dispose();
                    }

                    return(list);
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.ToString());
                }
                finally
                {
                    try
                    {
                        if (con != null)
                        {
                            con.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.ToString());
                    }

                    try
                    {
                        if (rdr != null)
                        {
                            rdr.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.ToString());
                    }
                    try
                    {
                        if (cmd != null)
                        {
                            cmd.Dispose();
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.ToString());
                    }
                }
            }