示例#1
0
        private async void PopularLista()
        {
            var api = new ApiCall();

            await api.GetResponse <ObservableCollection <Estoque> >("estoques").ContinueWith((t) =>
            {
                if (t.IsCompleted)
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        ListaEstoque = t.Result;
                        Estoques     = ListaEstoque.Select(e => $"{e.Nome} - R$ {e.Valor.ToString("N2")}").ToArray();
                    });
                }
            });

            await api.GetResponse <ObservableCollection <Cliente> >("clientes").ContinueWith((t) =>
            {
                if (t.IsCompleted)
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        ListaCliente = t.Result;
                        Clientes     = ListaCliente.Select(e => e.Nome).ToArray();
                    });
                }
            });
        }
示例#2
0
        public void OnEditar(int id)
        {
            var item = ListaEstoque.First(e => e.Id == id);

            var cadastroPage = new CadastroEstoquePage(item);

            Navigation.PushAsync(cadastroPage);
        }
示例#3
0
            public static ListaEstoque RetornarEstoque(string Tipo)
            {
                con = ConnectionFactory.getConnection();
                con.Open();
                try
                {
                    SqlCommand cmd = new SqlCommand("SELECT CodigoProduto, Nome, Preco, QtdEstoque, QtdMaxima, QtdMinima, UnidadeMedida,Tipo " +
                                                    "FROM Produto INNER JOIN Estoque " +
                                                    "on Produto.IdProduto = Estoque.IdProduto WHERE Tipo = @Tipo;", con);
                    cmd.Parameters.AddWithValue("@Tipo", Tipo);


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

                    using (var rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                        {
                            list.Items.Add(new Estoque
                            {
                                Codigo     = rdr.GetString(0),
                                Nome       = rdr.GetString(1),
                                Preco      = rdr.GetDouble(2),
                                QtdEstoque = rdr.GetDouble(3),
                                QtdMaxima  = rdr.GetDouble(4),
                                QtdMinima  = rdr.GetDouble(5),
                                UM         = rdr.GetString(6)
                            });
                        }
                    }
                    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());
                    }
                }
            }