Advertisement
Guest User

Table Ingredientes

a guest
Jun 5th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Xamarin.Forms;
  7. using Xamarin.Forms.Xaml;
  8.  
  9. namespace OrganizeSe
  10. {
  11.     [XamlCompilation(XamlCompilationOptions.Compile)]
  12.     public partial class NewIngPage : ContentPage
  13.     {
  14.         public NewIngPage ()
  15.         {
  16.             InitializeComponent ();
  17.         }
  18.  
  19.         private void Button_Clicked(object sender, EventArgs e)
  20.         {
  21.             Ingredientes ing = new Ingredientes()
  22.             {
  23.                 Nome = nameEntry.Text,
  24.                 Preco = precoEntry.Text,
  25.                 Qnt = qntEntry.Text
  26.             };
  27.  
  28.             using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_PATH))
  29.             {
  30.                 conn.CreateTable<Ingredientes>();
  31.                 var numberOfRows = conn.Insert(ing);
  32.  
  33.                 if (numberOfRows>0)                
  34.                     DisplayAlert("Salvo!", "O ingrediente foi salvo com sucesso.", "Ok");
  35.                 else
  36.                     DisplayAlert("Falha!", "O ingrediente NÃO foi salvo.", "Ok");
  37.             }                        
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement