Exemplo n.º 1
0
        private async void BtCadastrar_Clicked(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(EntryDescricao.Text))
            {
                await DisplayAlert("Error", "Preencha o Nome", "OK");

                EntryDescricao.Focus();
                return;
            }
            var produto = new AppLoja.Model.Produto()
            {
                Descricao  = EntryDescricao.Text,
                Preco      = Convert.ToDouble(EntryPreco.Text),
                IconSource = Icons[ImagePicker.SelectedIndex]
            };

            using (var dados = new DataAccess())
            {
                dados.InsertProduto(produto);
            }
            EntryDescricao.Text       = string.Empty;
            EntryPreco.Text           = string.Empty;
            ImagePicker.SelectedIndex = -1;
            await DisplayAlert("Mensagem", "Produto Cadastrado", "OK");
        }
Exemplo n.º 2
0
        private async void BtCadastrar_Clicked(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(EntryDescricao.Text))
            {
                await DisplayAlert("Error", "Preencha o Nome", "OK");

                EntryDescricao.Focus();
                return;
            }
            var fornecedor = new AppLoja.Model.Fornecedor()
            {
                Descricao = EntryDescricao.Text,
                CNPJ      = EntryCNPJ.Text
            };

            using (var dados = new DataAccess())
            {
                dados.InsertFornecedor(fornecedor);
            }
            EntryDescricao.Text = string.Empty;
            EntryCNPJ.Text      = string.Empty;
            await DisplayAlert("Mensagem", "Fornecedor Cadastrado", "OK");
        }