示例#1
0
        private void BtnSalvar_OnClicked(object sender, EventArgs e)
        {
            try
            {
                var nota = new Nota
                {
                    Titulo   = txtTitulo.Text,
                    Dados    = txtDados.Text,
                    Favorito = swtFavorito.IsToggled
                };

                var dbNotasServices = new DbNotasServices();

                if (btnSalvar.Text.Equals("Salvar"))
                {
                    dbNotasServices.Insert(nota);
                }
                else if (btnSalvar.Text.Equals("Alterar"))
                {
                    nota.Id = int.Parse(txtCodigo.Text);
                    dbNotasServices.Update(nota);
                }

                DisplayAlert("Retorno da operção", dbNotasServices.StatusMessage, "OK");

                var page = (MasterDetailPage)Application.Current.MainPage;
                page.Detail = new NavigationPage(new ListarPage());
            }
            catch (Exception ex)
            {
                DisplayAlert("Erro", ex.Message, "Fechar");
            }
        }
 public void ListarNotas()
 {
     try
     {
         var dbNotasServices = new DbNotasServices();
         ListaNotas.ItemsSource = dbNotasServices.List();
     }
     catch (Exception e)
     {
         DisplayAlert("Erro", e.Message, "Fechar");
     }
 }
示例#3
0
        private async void BtnExcluir_OnClicked(object sender, EventArgs e)
        {
            var result = await DisplayAlert("Excluir", "Deseja excluir esta nota?", "Sim", "Não");

            if (result)
            {
                var dbNotasServices = new DbNotasServices();
                var id = int.Parse(txtCodigo.Text);
                dbNotasServices.Delete(id);
                await DisplayAlert("Retorno da operção", dbNotasServices.StatusMessage, "OK");

                var page = (MasterDetailPage)Application.Current.MainPage;
                page.Detail = new NavigationPage(new ListarPage());
            }
        }