예제 #1
0
        //http://forums.xamarin.com/discussion/19362/xamarin-forms-splashscreen-in-android
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            string databasePath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal);
            string databaseFull = System.IO.Path.Combine (databasePath, Global.databaseName);

            if (File.Exists (databaseFull) == true) {
                //it's not the first time
                var plat = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid ();
                var cn = new SQLite.Net.SQLiteConnection (plat, databaseFull);
                var m = cn.Table<MacroCategories> ().ToList ();
                Global.k_MacroCategories = new MyObservableCollection<MacroCategories> (m);
                var c = cn.Table<Categories> ().ToList ();
                Global.K_Categories = new MyObservableCollection<Categories> (c);
                var p = cn.Table<POIs> ().ToList ();
                Global.K_POIs = new MyObservableCollection<POIs> (p);
                var cp = cn.Table<Categories_POIs> ().ToList ();
                Global.K_Categories_POIs = new MyObservableCollection<Categories_POIs> (cp);
                var pg = cn.Table<POIsPictures> ().ToList ();
                Global.K_POIsPictures = new MyObservableCollection<POIsPictures> (pg);
                Global.K_CCFs = Global.createCCFs ();
                Thread.Sleep (1); // Simulate a long loading process on app startup
            } else {
                Thread.Sleep (2000); // Simulate a long loading process on app startup
            }

            var intent = new Intent (this, typeof(MainActivity));
            StartActivity (intent);

            Finish ();
            // Create your application here
        }
예제 #2
0
 public T First <T>(bool WithChildren) where T : class
 {
     if (WithChildren)
     {
         return(connection.GetAllWithChildren <T>().FirstOrDefault());
     }
     else
     {
         return(connection.Table <T>().FirstOrDefault());
     }
 }
예제 #3
0
        public List <Book> getBooks()
        {
            var query = con.Table <Book>();

            try
            {
                List <Book> books = query.ToList <Book>();
                return(books);
            }
            catch (System.MissingMethodException ex)
            {
                return(new List <Book>());
            }
        }
예제 #4
0
 private static void CreateDatabase()
 {
     try
     {
         string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
         System.IO.Directory.CreateDirectory(folderPath);
         string databaseFilePath = System.IO.Path.Combine(folderPath, "FinancialProfile.db");
         using (var db = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.XamarinIOS.SQLitePlatformIOS(), databaseFilePath))
         {
             db.CreateTable <FinancialProfileDomain>();
             if (db.Table <FinancialProfileDomain>().Count() == 0)
             {
                 var FinancialProfile = new FinancialProfileDomain()
                 {
                     Question = "When is your birthday?",
                     DataType = "DateTime"
                 };
                 db.Insert(FinancialProfile);
                 var question = db.Get <FinancialProfileDomain>(1);
                 FinancialProfile = new FinancialProfileDomain()
                 {
                     Question = "What is your net worth?",
                     DataType = "Int"
                 };
                 db.Insert(FinancialProfile);
                 FinancialProfile = new FinancialProfileDomain()
                 {
                     Question = "How much do you make each month after taxes including 1099, w2, 401k, and ira contributions?",
                     DataType = "Int"
                 };
                 db.Insert(FinancialProfile);
                 FinancialProfile = new FinancialProfileDomain()
                 {
                     Question = "How much do you spend each month on your house?",
                     DataType = "Int"
                 };
                 db.Insert(FinancialProfile);
                 FinancialProfile = new FinancialProfileDomain()
                 {
                     Question = "How much do you spend each month on your car?",
                     DataType = "Int"
                 };
                 db.Insert(FinancialProfile);
                 FinancialProfile = new FinancialProfileDomain()
                 {
                     Question = "How much do you spend each month on everything else?",
                     DataType = "Int"
                 };
                 db.Insert(FinancialProfile);
             }
         }
     }
     catch (SQLiteException ex)
     {
         var t = ex;
     }
 }
예제 #5
0
파일: Data.cs 프로젝트: andreszb/Point
 //Return all customers whose name has string.
 public static List <Customer> Contains(String search)
 {
     using (var db = new SQLite.Net.SQLiteConnection(new
                                                     SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
     {
         var query = (from s in db.Table <Customer>() where s.Name.Contains(search) select s);
         try { return(new List <Customer>(query)); }
         catch { return(null); }
     }
 }
예제 #6
0
        public void Results()
        {
            conn.CreateTable <Appointments>();
            var query = conn.Table <Appointments>();

            ApptList1.ItemsSource = query.ToList();
            ApptList.ItemsSource  = query.ToList();

            conn.CreateTable <Accounts>();
            var accupdate = conn.Table <Accounts>();

            AccountSelct.ItemsSource = accupdate.ToList();
        }
예제 #7
0
파일: Data.cs 프로젝트: andreszb/Point
 //Gets sales for a specific date as a list.
 public static List <StringItem> Sales(this DateTime date)
 {
     using (var db = new SQLite.Net.SQLiteConnection(new
                                                     SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
     {
         var        stringDate = date.ToLocalTime().ToString("s").Substring(2, 8);
         SalesByDay today      = new SalesByDay();
         today = (from s in db.Table <SalesByDay>() where s.Day == stringDate select s).FirstOrDefault();
         //Return list if found
         return(today != null ? today.Table : null);
     }
 }
예제 #8
0
파일: Data.cs 프로젝트: andreszb/Point
 public static String TotalOwed(this DateTime date)
 {
     using (var db = new SQLite.Net.SQLiteConnection(new
                                                     SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
     {
         var         stringDate = date.ToLocalTime().ToString("s").Substring(2, 8);
         SalesByDay  today      = (from s in db.Table <SalesByDay>() where s.Day == stringDate select s).FirstOrDefault();
         Double      val        = today != null ? today.TotalOwed : 0;
         CultureInfo culture    = new CultureInfo("es-MX");
         return(String.Format(culture, "{0:C2}", val));
     }
 }
예제 #9
0
        public static string DoSomeDataAccess()
        {
            Console.WriteLine("Creating database, if it doesn't already exist");

            SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid plat = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();

            string dbPath = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.Personal),
                "ormdemo.db3");

            var db = new SQLite.Net.SQLiteConnection(plat, dbPath);

            db.CreateTable <Stock>();

            if (db.Table <Stock>().Count() == 0)
            {
                // only insert the data if it doesn't already exist
                var newStock = new Stock();
                newStock.Symbol = "AAPL";
                db.Insert(newStock);
                newStock        = new Stock();
                newStock.Symbol = "GOOG";
                db.Insert(newStock);
                newStock        = new Stock();
                newStock.Symbol = "MSFT";
                db.Insert(newStock);
            }
            Console.WriteLine("Reading data");
            var    table = db.Table <Stock>();
            string data  = string.Empty;

            foreach (var s in table)
            {
                Console.WriteLine(s.Id + " " + s.Symbol);

                data += s.Id + " " + s.Symbol + " :: ";
            }

            return(data);
        }
예제 #10
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            var query = conn.Table <TransactionsTable>();
            int k     = 0;

            // if (query.Count() > 0)
            //    k = query.Count();
            foreach (var item1 in query)
            {
                k = item1.ID;
            }
            var    query2 = conn.Table <CarTable>().Where(t => t.Availability == "A" && t.CarType == "Micro - NON - AC");
            string j      = "";

            foreach (var item in query2)
            {
                j = item.RegistrationNumber;
            }
            var query3 = conn.Table <CarTable>().Where(t => t.Availability == "A" && t.RegistrationNumber == j);


            Debug.WriteLine("tRANSACTIONStABLEcOUNT = " + k);
            conn.Execute("UPDATE TransactionsTable SET CarType = ? Where ID = ?", "Micro - NON - AC", k);
            conn.Execute("UPDATE TransactionsTable SET Fare = ? Where ID = ?", txtblk_Mic_Non_Ac.Text, k);
            conn.Execute("UPDATE TransactionsTable SET CabID = ? Where ID = ?", j, k);
            conn.Execute("UPDATE CarTable SET Availability= ? Where RegistrationNumber = ?", "B", j);

            this.Frame.Navigate(typeof(BookDriver), usr);
        }
예제 #11
0
파일: Data.cs 프로젝트: andreszb/Point
 // Returns total from SalesByDay Table for a specific date.
 public static String Total(this DateTime date)
 {
     using (var db = new SQLite.Net.SQLiteConnection(new
                                                     SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
     {
         var stringDate = date.ToLocalTime().ToString("s").Substring(2, 8);
         //Search for date in table
         SalesByDay today = (from s in db.Table <SalesByDay>() where s.Day == stringDate select s).FirstOrDefault();
         //Set value to total property if not null
         Double      val     = today != null ? today.Total : 0;
         CultureInfo culture = new CultureInfo("es-MX");
         //Return as string formated as currency.
         return(String.Format(culture, "{0:C2}", val));
     }
 }
예제 #12
0
        /// <summary>
        /// 在应用程序由最终用户正常启动时进行调用。
        /// 将在启动应用程序以打开特定文件等情况下使用。
        /// </summary>
        /// <param name="e">有关启动请求和过程的详细信息。</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            //清空磁贴
            TileUpdateManager.CreateTileUpdaterForApplication().Clear();
            Frame rootFrame = Window.Current.Content as Frame;
            //加载数据库
            List <Models.Member> datalist = conn.Table <Models.Member>().ToList();

            //将数据库内容添加到内存中
            for (int i = 0; i < datalist.Count; i++)
            {
                ViewModel.Re(datalist[i].name);
            }

            // 不要在窗口已包含内容时重复应用程序初始化,
            // 只需确保窗口处于活动状态
            if (rootFrame == null)
            {
                // 创建要充当导航上下文的框架,并导航到第一页
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: 从之前挂起的应用程序加载状态
                }

                // 将框架放在当前窗口中
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // 当导航堆栈尚未还原时,导航到第一页,
                    // 并通过将所需信息作为导航参数传入来配置
                    // 参数
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // 确保当前窗口处于活动状态
                Window.Current.Activate();
            }
        }
예제 #13
0
파일: Data.cs 프로젝트: andreszb/Point
 //Inserts a new customer if the customer is not already in the table, if it is, it updates it.
 public void AddToTable()
 {
     using (var db = new SQLite.Net.SQLiteConnection(new
                                                     SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
     {
         //Look for customer in table
         Customer returnedCustomer = (from s in db.Table <Customer>() where s.Id.Equals(Id) select s).FirstOrDefault();
         if (returnedCustomer != null)
         {
             //Add new items to items in items column.
             this.Items = returnedCustomer.Items + "\r(" + DateTime.Now.ToLocalTime().ToString("d") + ")\r" + this.Items;
             db.Update(this);
         }
         else
         {
             db.Insert(this);
         }
     }
 }
예제 #14
0
        private async void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (Home.IsSelected)
            {
                RootObject myPage = await Paper.GetPaper();

                string image = String.Format(myPage.image);
                ImageResult.Source = new BitmapImage(new Uri(image, UriKind.Absolute));
                DateResult.Text    = myPage.date;
                TitleResult.Text   = myPage.title;
                string description = myPage.content.description;
                ContentResult1.Text       = description;
                TitleTextBlock.Text       = "Home";
                ImageResult.Visibility    = Visibility.Visible;
                DateResult.Visibility     = Visibility.Visible;
                TitleResult.Visibility    = Visibility.Visible;
                ContentResult1.Visibility = Visibility.Visible;
                Button.Visibility         = Visibility.Visible;
                Button2.Visibility        = Visibility.Collapsed;
                LinkBookMark.Visibility   = Visibility.Collapsed;
            }
            else if (Bookmark.IsSelected)
            {
                var    querry = connect.Table <Page>();
                string link   = "";
                foreach (var q in querry)
                {
                    link = "BookMark: " + q.title;
                }
                LinkBookMark.Text         = link;
                LinkBookMark.Visibility   = Visibility.Visible;
                ImageResult.Visibility    = Visibility.Collapsed;
                DateResult.Visibility     = Visibility.Collapsed;
                TitleResult.Visibility    = Visibility.Collapsed;
                ContentResult1.Visibility = Visibility.Collapsed;
                Button.Visibility         = Visibility.Collapsed;
                Button2.Visibility        = Visibility.Visible;
                TitleTextBlock.Text       = "Bookmark";
            }
        }
예제 #15
0
파일: Data.cs 프로젝트: andreszb/Point
 public static SalesByDay Today()
 {
     using (var db = new SQLite.Net.SQLiteConnection(new
                                                     SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
     {
         String today = DateTime.Now.ToLocalTime().ToString("s").Substring(2, 8);
         new SalesByDay();
         var query = (from s in db.Table <SalesByDay>() where s.Day == today select s).FirstOrDefault();
         if (query == null)
         {
             SalesByDay newDay = new SalesByDay()
             {
                 Day = today, ItemsString = String.Empty, Total = 0, TotalOwed = 0
             };
             db.Insert(newDay);
             return(SalesByDay.Today());
         }
         else
         {
             return(query);
         }
     }
 }
예제 #16
0
 public Contato ObterPorID(int id)
 {
     return(_connection.Table <Contato>().FirstOrDefault(c => c.Id == id));
 }
 public List <Cliente> Listar()
 {
     return(_conexao.Table <Cliente>().OrderBy(c => c.Nome).ToList());
 }
 static public User GetUser(int id)
 {
     return(SQConnection.GetWithChildren <User>(SQConnection.Table <User>().ElementAt(id).Name));
 }