SHARE
TWEET

GetAllCompaniesPage

pabloducato May 12th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Text;
  5. using CRUD.Models;
  6. using Xamarin.Forms;
  7. using SQLite;
  8. using Xamarin.Forms.Xaml;
  9. using System.Linq;
  10.  
  11. namespace CRUD.Views
  12. {
  13.     [XamlCompilation(XamlCompilationOptions.Compile)]
  14.     public partial class GetAllCompaniesPage : ContentPage
  15.     {
  16.         string _dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "myDB.db3");
  17.         private ListView _listView;
  18.         private Company _company;
  19.         private object _idEntry;
  20.         private object _nameEntry;
  21.         private object _addressEntry;
  22.  
  23.         public GetAllCompaniesPage()
  24.         {
  25.             this.Title = "Companies";
  26.  
  27.             var db = new SQLiteConnection(_dbPath);
  28.  
  29.             StackLayout stackLayout = new StackLayout();
  30.  
  31.             _listView = new ListView();
  32.             _listView.ItemsSource = db.Table<Company>().OrderBy(x => x.Name).ToList();
  33.             _listView.ItemSelected += _listView_ItemSelected;
  34.             stackLayout.Children.Add(_listView);
  35.  
  36.             Content = stackLayout;
  37.         }
  38.  
  39.         private void _listView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
  40.         {
  41.             _company = (Company)e.SelectedItem;
  42.         }
  43.     }
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top