public SingleCollectionViewModel GetSingleCollection(int collectionId)
        {
            SingleCollectionViewModel collection = new SingleCollectionViewModel();

            using (var db = new SQLite.SQLiteConnection(app.DBPath))
            {
                var _collection = (db.Table<Collection>().Where(
                    c => c.Id == collectionId)).FirstOrDefault();
                collection.Id = _collection.Id;
                collection.Title = _collection.Title;
                collection.DateCreated = _collection.DateCreated;
                collection.Void = _collection.Void;

                // GET ALBUMS
                var _albums = (db.Table<Album>().Where(
                    c => c.CollectionId == collectionId)).ToList();

                List<lfm> albumList = new List<lfm>();
                foreach (var _album in _albums)
                {
                    lfm album = LastGetAlbum(_album.MusicBrainzId);
                    albumList.Add(album);
                }
                collection.Albums = albumList;
            }
            return collection;
        }
Exemplo n.º 2
0
 public IEnumerable<Source> FindAll(int projectId)
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         return db.Query<Source>("select * from Source where ProjectId = ?", projectId);
     }
 }
Exemplo n.º 3
0
        public int AddPet(Pet _pet)
        {
            //returns new ID
            int success;
            using (var db = new SQLite.SQLiteConnection(Constants.DbPath))
            {
                success = db.Insert(new Pet()
                {
                    PetStageId = _pet.PetStageId,
                    FavoriteGameObjectId = _pet.FavoriteGameObjectId,
                    DislikeGameObjectId = _pet.DislikeGameObjectId,
                    Name = _pet.Name,
                    Health = _pet.Health,
                    Hygene = _pet.Hygene,
                    Hunger = _pet.Hunger,
                    Energy = _pet.Energy,
                    Discipline = _pet.Discipline,
                    Mood = _pet.Mood,
                    Gender = _pet.Gender,
                    Age = _pet.Age,
                    Sleeping = _pet.Sleeping,
                    Current = _pet.Current,
                    BirthDate = _pet.BirthDate,
                    LastUpdated = _pet.LastUpdated,
                    Dead = false
                });

            }
            return success;
        }
        public SQLite.SQLiteConnection GetConnection()
        {
            var sqliteFilename = "TodoSQLite.db3";
            var  documentsPath =  System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal); // Documents folder

            // string documentsPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal); // Documents folder
            var path = Path.Combine(documentsPath, sqliteFilename);

            // This is where we copy in the prepopulated database
            Console.WriteLine (path);

            /*
             * nel caso dovessi usare un database pre-popolato
            if (!File.Exists(path))
            {
                var s = Forms.Context.Resources.OpenRawResource(Resource.Raw.TodoSQLite);  // RESOURCE NAME ###
                // create a write stream
                FileStream writeStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);
                // write to the stream
                ReadWriteStream(s, writeStream);
            }
            */

            var conn = new SQLite.SQLiteConnection(path);

            // Return the database connection
            return conn;
        }
Exemplo n.º 5
0
        public static SQLite.SQLiteConnection Connection()
        {
            var conn = new SQLite.SQLiteConnection(DBPath);
            if (!Initialized)
            {
                conn.CreateTable<Car.Car>();
                conn.CreateTable<Fillup.Fillup>();
                conn.CreateTable<Maintenance.Maintenance>();
                conn.CreateTable<Reminder.Reminder>();

                var cars = conn.Table<Car.Car>();

                if (cars.Count() == 0)
                {
                    Car.Car car = new Car.Car();
                    conn.Insert(car);
                }

                var firstCar = cars.First();

                if (cars.Where(vehicle => vehicle.ID == Settings.CurrentCarID).Count() == 0)
                    Settings.CurrentCarID = firstCar.ID;




                Initialized = true;
            }
            return conn;
        }
        public ObservableCollection<MealViewModel> GetMeals()
        {
            meals = new ObservableCollection<MealViewModel>();
            using (var db = new SQLite.SQLiteConnection(App.DBPath))
            {
                var query = db.Table<Meal>().OrderBy(c => c.Name);
                foreach (var _meal in query)
                {
                    var meal = new MealViewModel()
                    {
                        Id = _meal.Id,
                        DeliveryNoteId = _meal.DeliveryNoteId,
                        Name = _meal.Name,
                        DeliveryDate = _meal.DeliveryDate,
                        DeliveryTime = _meal.DeliveryTime,
                        DeliveryLocation = _meal.DeliveryLocation,
                        PickupDate = _meal.PickupDate,
                        Contact = _meal.Contact,
                        ContactId = _meal.ContactId,
                        NumberOfGuests = _meal.NumberOfGuests,
                        SilverWare = _meal.SilverWare,
                        MealItemIDs = (List<int>)_converter.ConvertBack(_meal.MealItemIDs, null, null, ""),
                        MealItemIDsWithWeight = (Dictionary<float,float>)_dictionaryConverterFloat.ConvertBack(_meal.MealItemIDsWithWeight, null, null, "")
                    };

                    meals.Add(meal);
                }
            }

            return meals;
        }
Exemplo n.º 7
0
 public ObservableCollection<SubjectViewModel> getEnglishQuestions1(string gr)
 {
     string no = "no";
     string yes = "yes";
     subject = new ObservableCollection<SubjectViewModel>();
     using (var db = new SQLite.SQLiteConnection(app.dbPath))
     {
         //var query = db.Table<English>();
         var query = db.Query<English>("select * from english where GRADE ='" + gr + "' and read ='" + no + "'");
         foreach (var j in query)
         {
             var sub = new SubjectViewModel()
             {
                 ID = j.Id,
                 QUESTION = j.question,
                 ANSWER = j.answer,
                 ANSWER1 = j.answer2,
                 ANSWER2 = j.answer3,
                 GRADE = j.GRADE,
                 READ = j.read
             };
             subject.Add(sub);
         }
     }
     return subject;
 }
Exemplo n.º 8
0
 private void butSaveClick(object sender,EventArgs e)
 {
     TextView txtprinter =FindViewById<TextView> (Resource.Id.txtad_printer);
     TextView txtprefix =FindViewById<TextView> (Resource.Id.txtad_prefix);
     TextView txttitle =FindViewById<TextView> (Resource.Id.txtad_title);
     pathToDatabase = ((GlobalvarsApp)this.Application).DATABASE_PATH;
     AdPara apra = new AdPara ();
     apra.Prefix = txtprefix.Text.ToUpper();
     apra.PrinterName = txtprinter.Text.ToUpper();
     using (var db = new SQLite.SQLiteConnection(pathToDatabase))
     {
         var list  = db.Table<AdPara> ().ToList<AdPara> ();
         if (list.Count == 0) {
             db.Insert (apra);
         } else {
             apra = list [0];
             apra.Prefix = txtprefix.Text.ToUpper();
             apra.PrinterName = txtprinter.Text.ToUpper();
             apra.PaperSize = spinner.SelectedItem.ToString ();
             apra.ReceiptTitle =txttitle.Text.ToUpper();
             db.Update (apra);
         }
     }
     base.OnBackPressed();
 }
Exemplo n.º 9
0
 private void Update(Source model)
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         db.Update(model);
     }
 }
Exemplo n.º 10
0
 public IEnumerable<Item> FindAll(int sourceId)
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         return db.Query<Item>("select * from Item where SourceId = ?", sourceId);
     }
 }
Exemplo n.º 11
0
 public IEnumerable<Preference> FindAll()
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         return db.Query<Preference>("select * from Preference");
     }
 }
Exemplo n.º 12
0
        public void update(string name,string address)
        {          
            using (var db = new SQLite.SQLiteConnection(app.dbPath))
            {
                try
                {//db.Execute("update meterbox set currentUnits = currentUnits -" + used);
                    var existing = db.Query<Job>("select * from Job").First();

                    if (existing != null)
                    {
                        existing.name = name;
                        existing.address = address;
                        db.RunInTransaction(() =>
                        {
                            db.Update(existing);
                        });
                    }
                }

                catch (Exception e)
                {

                }
            }
        }
Exemplo n.º 13
0
        public bool AddAlbum(AlbumViewModel model)
        {
            try
            {
                using (var db = new SQLite.SQLiteConnection(app.DBPath))
                {
                    int success = db.Insert(new Album()
                    {
                        CollectionId = model.CollectionId,
                        Title = model.Title,
                        Artist = model.Artist,
                        LastFmId = model.LastFmId,
                        MusicBrainzId = model.MusicBrainzId,
                        DateAdded = DateTime.Now,
                        Void = false
                    });
                    if (success != 0)
                        return true;
                }
                return false;
            }

            catch
            {
                return false;
            }
        }
Exemplo n.º 14
0
 public void Insert(Locale model)
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         db.Insert(model);
     }
 }
Exemplo n.º 15
0
 public void UpdateText(string newText, int id)
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         db.Execute("update Item set Text = ? where Id = ?", newText, id);
     }
 }
Exemplo n.º 16
0
		private void CreateTable()
		{
			using (var conn = new SQLite.SQLiteConnection(GetDatabasePath()))
			{
				conn.CreateTable<Person>();
			}
		}
Exemplo n.º 17
0
 public void Delete(int translationId)
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         db.Execute("delete from Translation where Id = ?", translationId);
     }
 }
Exemplo n.º 18
0
 private void Insert(Translation model)
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         db.Insert(model);
     }
 }
Exemplo n.º 19
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			ShareActivityContext = this; // HACK: for SpeakButtonRenderer to get an Activity/Context reference

			Xamarin.Forms.Forms.Init (this, bundle);
			//Xamarin.QuickUIMaps.Init (this, bundle);

			var sqliteFilename = "EvolveSQLite.db3";
			string documentsPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal); // Documents folder
			var path = Path.Combine(documentsPath, sqliteFilename);

			// This is where we copy in the prepopulated database
			Console.WriteLine (path);
			if (!File.Exists(path))
			{
				var s = Resources.OpenRawResource(Evolve13.Resource.Raw.EvolveSQLite);  // RESOURCE NAME ###

				// create a write stream
				FileStream writeStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write);
				// write to the stream
				ReadWriteStream(s, writeStream);
			}


			var conn = new SQLite.SQLiteConnection(path);

			// Set the database connection string
			App.SetDatabaseConnection (conn);

			SetPage (App.GetMainPage ());
		}
Exemplo n.º 20
0
		//
		// This method is invoked when the application has loaded and is ready to run. In this
		// method you should instantiate the window, load the UI into it and then make the window
		// visible.
		//
		// You have 17 seconds to return from this method, or iOS will terminate your application.
		//
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			Forms.Init ();
			Xamarin.FormsMaps.Init ();

			// create a new window instance based on the screen size
			window = new UIWindow (UIScreen.MainScreen.Bounds);

			var sqliteFilename = "EvolveSQLite.db3";
			string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder
			string libraryPath = Path.Combine (documentsPath, "..", "Library"); // Library folder
			var path = Path.Combine(libraryPath, sqliteFilename);

			// This is where we copy in the prepopulated database
			Console.WriteLine (path);
			if (!File.Exists (path)) {
				File.Copy (sqliteFilename, path);
			}

			var conn = new SQLite.SQLiteConnection(path);

			// Set the database connection string
			App.SetDatabaseConnection (conn);

			LoadApplication (new App ());

			return base.FinishedLaunching (app, options);
		}
Exemplo n.º 21
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {

            if (FieldValidationExtensions.GetIsValid(AddressbookUserName) && FieldValidationExtensions.GetIsValid(AddressbookEmail))
            {

                var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
                using (var db = new SQLite.SQLiteConnection(dbPath))
                {
                    db.CreateTable<AddressBookEntree>();

                    User addressbookuser = new User();
                    addressbookuser.UserName = AddressbookUserName.Text;
                    addressbookuser.EmailAddress = AddressbookEmail.Text;

                    db.RunInTransaction(() =>
                    {
                        db.Insert(addressbookuser);

                        db.Insert(new AddressBookEntree() { OwnerUserID = App.loggedInUser.Id, EntreeUserID = addressbookuser.Id });
                    });
                }

            }

            this.Frame.Navigate(typeof(Dashboard));

        }
Exemplo n.º 22
0
 public IEnumerable<Project> FindAllExcept(int projectId)
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         return db.Query<Project>("select * from Project where Id <> ?", projectId);
     }
 }
Exemplo n.º 23
0
 public Project Get(int projectId)
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         return db.Find<Project>(projectId);
     }
 }
Exemplo n.º 24
0
 public IEnumerable<Locale> FindAll(int projectId)
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         return db.Query<Locale>("select * from Locale where ProjectId = ? order by DisplayName", projectId);
     }
 }
Exemplo n.º 25
0
        public static void Delete()
        {
            using (Siaqodb siaqodb = new Siaqodb())
            {
                siaqodb.Open(siaqodbPath, 100 * OneMB, 20);
                Console.WriteLine("DeleteSiaqodb...");
                var all = siaqodb.LoadAll<MyEntity>();
                var stopwatch = new Stopwatch();
                stopwatch.Start();
                foreach(MyEntity en in all)
                {
                    siaqodb.Delete(en);
                }

                stopwatch.Stop();
                Console.WriteLine("DeleteSiaqodb took:" + stopwatch.Elapsed);

            }

            using (var dbsql = new SQLite.SQLiteConnection(sqLitePath))
            {
                Console.WriteLine("DeleteSQLite...");
                var all = dbsql.Query<MyEntity>("select * from MyEntity");

                var stopwatch = new Stopwatch();
                stopwatch.Start();
                foreach (MyEntity en in all)
                {
                    dbsql.Delete(en);
                }
                stopwatch.Stop();
                Console.WriteLine("DeleteSQLite took:" + stopwatch.Elapsed);
            }
        }
Exemplo n.º 26
0
		//
		// This method is invoked when the application has loaded and is ready to run. In this
		// method you should instantiate the window, load the UI into it and then make the window
		// visible.
		//
		// You have 17 seconds to return from this method, or iOS will terminate your application.
		//
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			Forms.Init ();
			Xamarin.FormsMaps.Init ();

			// create a new window instance based on the screen size
			window = new UIWindow (UIScreen.MainScreen.Bounds);

			var sqliteFilename = "EvolveSQLite.db3";
			string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder
			string libraryPath = Path.Combine (documentsPath, "..", "Library"); // Library folder
			var path = Path.Combine(libraryPath, sqliteFilename);

			// This is where we copy in the prepopulated database
			Console.WriteLine (path);
			if (!File.Exists (path)) {
				File.Copy (sqliteFilename, path);
			}

			var conn = new SQLite.SQLiteConnection(path);

			// Set the database connection string
			App.SetDatabaseConnection (conn);

			// If you have defined a view, add it here:
			// window.RootViewController  = navigationController;
			window.RootViewController = App.GetMainPage ().CreateViewController ();

			// make the window visible
			window.MakeKeyAndVisible ();

			return true;
		}
Exemplo n.º 27
0
        private void RemptionLoaded(object sender, RoutedEventArgs e)
        {
            try
            {
                var path = Path.Combine(ApplicationData.Current.LocalFolder.Path, "Shopping.db3");

                using (var db = new SQLite.SQLiteConnection(path))
                {
                    var a = from x in db.Table<ShopLists>() where x.AdminName == AdminName && x.Condition == 1 select x;
                    //MessageBox.Show(a.Count().ToString());

                    foreach (var v in a)
                    {
                        RedemptionShopList.Add(v);
                    }

                }

                RedemptionList.ItemsSource = RedemptionShopList;
            }
            catch
            {

            }
        }
Exemplo n.º 28
0
		public IPage<Artist> Page(ICriteria<Artist> criteria) {
			using (var cn = new SQLite.SQLiteConnection(_dbConnectionString)) {
				var query = cn.Table<Artist>().AsQueryable();

				if (criteria.Keywords.Any()) {
					criteria.Keywords.ToList().ForEach(word => query = query.Where(a => a.Name.ToLower().Contains(word.ToLower())));
				}

				var totalRecords = query.Count();

				if (criteria.SortBy.Any()) {
					foreach (var kvp in criteria.SortBy) {
						switch (kvp.Value) {
							case ListSortDirection.Ascending:
								query = query.OrderBy(kvp.Key);
								break;
							case ListSortDirection.Descending:
								query = query.OrderBy(kvp.Key + " descending");
								break;
						}
					}
				}

				if (criteria.Page.HasValue) {
					query = query.Skip((criteria.Page.Value - 1) * criteria.PageSize.GetValueOrDefault());
				}

				if (criteria.PageSize.HasValue) {
					query = query.Take(criteria.PageSize.Value);
				}

				return new Page<Artist>(criteria.Page ?? 0, criteria.PageSize ?? totalRecords, totalRecords, query.ToList());
			}
		}
Exemplo n.º 29
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Get a reference to the SQLite database
                this.DBPath = Path.Combine(
                    Windows.Storage.ApplicationData.Current.LocalFolder.Path, "budget.sqlite");

                // Initialize the database if necessary
                using (var db = new SQLite.SQLiteConnection(this.DBPath))
                {
                    // Create the tables if they don't exist
                    db.CreateTable<Budget>();
                    db.CreateTable<BudgetEnvelope>();
                    db.CreateTable<Account>();
                    db.CreateTable<Transaction>();

                    db.DeleteAll<Budget>();

                    db.Insert(new Budget()
                    {
                        Id = 1,
                        PaycheckAmount = 1000.0f,
                        Frequency = PaycheckFrequency.SemiMonthly,
                        Name = "My New Budget"
                    });

                    Budget b = db.Table<Budget>().First();
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
Exemplo n.º 30
0
        public string SaveProject(ProjectViewModel project)
        {
            string result = string.Empty;

            using (var db = new SQLite.SQLiteConnection(App.DBPath))
            {
                string change = string.Empty;
                try
                {
                    var existingProject = (db.Table <Project>().Where(
                                               c => c.Id == project.Id)).SingleOrDefault();

                    if (existingProject != null)
                    {
                        existingProject.Name        = project.Name;
                        existingProject.Description = project.Description;
                        existingProject.DueDate     = project.DueDate;
                        int success = db.Update(existingProject);
                    }
                    else
                    {
                        int success = db.Insert(new Project()
                        {
                            CustomerId  = project.CustomerId,
                            Name        = project.Name,
                            Description = project.Description,
                            DueDate     = project.DueDate
                        });
                    }
                    result = "Success";
                }
                catch
                {
                    result = "This project was not saved.";
                }
            }
            return(result);
        }
Exemplo n.º 31
0
        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            try
            {
                var    db     = new SQLite.SQLiteConnection(App.DBPath);
                string a      = t3.Text.ToString();
                var    emptab = (db.Table <registration>().Where(em => em.username == a)).Single();

                if (t4.Text == "" || t3.Text == "")
                {
                    var var_name = new MessageDialog("Fill all the details");
                    var_name.Commands.Add(new UICommand("OK"));
                    var_name.ShowAsync();
                }
                else
                {
                    var      db1 = new SQLite.SQLiteConnection(App.DBPath);
                    feedback fb  = new feedback();

                    fb.consumer_name = t2.Text;
                    fb.lawyer_name   = t3.Text;
                    fb.description   = t4.Text;
                    db.Insert(fb);
                    l1.Text = "Thank You for your feedback.";
                    // t1.Text = "";
                    t2.Text = "";
                    t3.Text = "";
                    t4.Text = "";
                }
            }

            catch (Exception ex)
            {
                var var_name = new MessageDialog("Invalid username");
                var_name.Commands.Add(new UICommand("OK"));
                var_name.ShowAsync();
            }
        }
Exemplo n.º 32
0
        void EditItem(string invno, int id)
        {
            using (var db = new SQLite.SQLiteConnection(pathToDatabase))
            {
                var list = db.Table <InvoiceDtls>().Where(x => x.invno == invno && x.ID == id).ToList <InvoiceDtls>();
                if (list.Count > 0)
                {
                    txtqty.Text   = list [0].qty.ToString();
                    txtprice.Text = list [0].price.ToString("n2");
                    int pos1 = 0;
                    if (list [0].description.Length > 40)
                    {
                        pos1 = dAdapterItem.GetPosition(list [0].icode + " | " + list [0].description.Substring(0, 40) + "...");
                    }
                    else
                    {
                        pos1 = dAdapterItem.GetPosition(list [0].icode + " | " + list [0].description);
                    }

                    spinItem.SetSelection(pos1);
                    spinItem.Enabled    = false;
                    butFindItem.Enabled = false;
                    IsEdit          = true;
                    IDdtls          = list [0].ID;
                    txtInvMode.Text = "EDIT";
                    spinQty.SetSelection(0);
                    if (list [0].qty < 0)
                    {
                        spinQty.SetSelection(1);
                    }

                    if (list [0].price == 0)
                    {
                        spinQty.SetSelection(2);
                    }
                }
            }
        }
Exemplo n.º 33
0
 private void DeleteInv()
 {
     try {
         using (var db = new SQLite.SQLiteConnection(pathToDatabase)) {
             var list  = db.Table <InvoiceDtls> ().Where(x => x.invno == invno).ToList <InvoiceDtls> ();
             var list2 = db.Table <Invoice> ().Where(x => x.invno == invno).ToList <Invoice> ();
             if (list2.Count > 0)
             {
                 string    trxtype = "CS";
                 AdNumDate adNum   = DataHelper.GetNumDate(pathToDatabase, list2 [0].invdate, trxtype);
                 if (invno.Length > 5)
                 {
                     string snum = invno.Substring(invno.Length - 4);
                     int    num;
                     if (int.TryParse(snum, out num))
                     {
                         if (adNum.RunNo == num)
                         {
                             adNum.RunNo = num - 1;
                             db.Update(adNum);
                             db.Delete(list2 [0]);
                             if (list.Count > 0)
                             {
                                 foreach (var itmdtls in list)
                                 {
                                     db.Delete(itmdtls);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } catch (Exception ex)
     {
         Toast.MakeText(this, ex.Message, ToastLength.Long).Show();
     }
 }
        private void AddMerchandiser_Clicked(object sender, EventArgs e)
        {
            Merchandiser merchandiser = new Merchandiser()
            {
                Name    = nameEntry.Text,
                Contact = contactEntry.Text
            };

            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_PATH))
            {
                conn.CreateTable <Merchandiser>();
                var numberOfRows = conn.Insert(merchandiser);

                if (numberOfRows > 0)
                {
                    DisplayAlert("Success!", "New Merchandiser Added", "Ok");
                }
                else
                {
                    DisplayAlert("Failure", "Merchandiser Not Added", "Ok");
                }
            }
        }
Exemplo n.º 35
0
        void BuildDatabase(bool fetchIconsOnly)
        {
            var realm   = new SaintCoinach.ARealmReversed(Config.GamePath, "SaintCoinach.History.zip", SaintCoinach.Ex.Language.English, "app_data.sqlite");
            var libra   = new SQLite.SQLiteConnection("app_data.sqlite", SQLite.SQLiteOpenFlags.ReadOnly);
            var builder = new DatabaseBuilder(libra, realm);

            DatabaseBuilder.PrintLine($"Game version: {realm.GameVersion}");
            DatabaseBuilder.PrintLine($"Definition version: {realm.DefinitionVersion}");

            OneTimeExports.Run(realm);

            var processing = Stopwatch.StartNew();

            builder.Build(fetchIconsOnly);

            if (!fetchIconsOnly)
            {
                SpecialOutput.Run();
            }

            processing.Stop();
            DatabaseBuilder.PrintLine($"Processing elapsed: {processing.Elapsed}");
        }
Exemplo n.º 36
0
        private void Button_Clicked(object sender, EventArgs e)
        {
            Bar bar = new Bar()
            {
                Name     = nameEntry.Text,
                Location = locationEntry.Text
            };

            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_PATH))
            {
                conn.CreateTable <Bar>();
                var numberOfRows = conn.Insert(bar);

                if (numberOfRows > 0)
                {
                    DisplayAlert("Success", "Bar saved successful", "ok");
                }
                else
                {
                    DisplayAlert("Failure", "Bar failed to be inserted", "X");
                }
            }
        }
Exemplo n.º 37
0
        public void ReadNotes()
        {
            try
            {
                using (SQLite.SQLiteConnection connection = new SQLite.SQLiteConnection(DatabaseHelper.dbFile))
                {
                    if (SelectedNotebook != null)
                    {
                        var notes = connection.Table <Note>().Where(n => n.NotebookId == SelectedNotebook.Id).ToList();

                        Notes.Clear();
                        foreach (var note in notes)
                        {
                            Notes.Add(note);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 38
0
        }                                                            //conexao com o banco de dados

        public App()
        {
            var pasta = new LocalRootFolder();

            ////crio o arquivo do banco (se ele não existir)
            ////Se ele existir, só quero que abra

            var arquivo = pasta.CreateFile("confrariapp.db", PCLExt.FileStorage.CreationCollisionOption.OpenIfExists);

            ////faço a "conexao"
            conexao = new SQLite.SQLiteConnection(arquivo.Path);

            ////criar a tabela, se ela não existir
            conexao.Execute("CREATE TABLE IF NOT EXISTS CadastroCliente (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, nome TEXT NOT NULL, login TEXT NOT NULL, data TEXT NOT NULL, telefone INTEGER NOT NULL, senha TEXT NOT NULL)");
            conexao.Execute("CREATE TABLE IF NOT EXISTS CadastroBebida (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, nome TEXT NOT NULL, descricao TEXT NOT NULL, valor TEXT NOT NULL, categoria TEXT NOT NULL)");
            conexao.Execute("CREATE TABLE IF NOT EXISTS CadastroPorcao (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, nome TEXT NOT NULL, descricao TEXT NOT NULL, valor TEXT NOT NULL, categoria TEXT NOT NULL)");
            conexao.Execute("CREATE TABLE IF NOT EXISTS CadastroSuvenir (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, nome TEXT NOT NULL, descricao TEXT NOT NULL, valor TEXT NOT NULL, categoria TEXT NOT NULL)");
            conexao.Execute("CREATE TABLE IF NOT EXISTS CadastroReserva (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, nomeCliente TEXT NOT NULL, qtdpessoas INTEGER NOT NULL, data TEXT NOT NULL, observacao TEXT NOT NULL)");
            conexao.Execute("CREATE TABLE IF NOT EXISTS CadastroProgramacao (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, nomeprog TEXT NOT NULL, data TEXT NOT NULL, descricao TEXT NOT NULL)");

            InitializeComponent();
            MainPage = new NavigationPage(new LoginPage());
        }
Exemplo n.º 39
0
        public void Push()
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                using (var db = new SQLite.SQLiteConnection(AppState.State.Instance.DbPath))
                {
                    var challengeProgresses = db.Table <ChallengeProgress>().ToList()
                                              .Where((c) => c.LastModified > _lastSyncTime);

                    var taskProgresses = db.Table <TaskProgress>().ToList()
                                         .Where((t) => t.LastModified > _lastSyncTime);

                    _client.PutCollectionByElements("progress/challenges", challengeProgresses, (c) => c.Id.ToString());
                    _client.PutCollectionByElements("progress/tasks", taskProgresses, (t) => t.Id.ToString());
                }

                PushSuccess?.Invoke(this, null);
            }
            else
            {
                throw new NotConnectedException();
            }
        }
Exemplo n.º 40
0
        private void backToHome(object sender, EventArgs args)
        {
            Data userdata = new Data()
            {
                //I have no idea what the end of Slider should be so i'm leaving it
                //SliderDataDistressed = Slider.Text
            };

            using (SQLite.SQLiteConnection connect = new SQLite.SQLiteConnection(App.DataBase_Path))
            {
                connect.CreateTable <Data>();
                var numberOfRows = connect.Insert(userdata);

                if (numberOfRows > 0)
                {
                    DisplayAlert("Success", "Data successfully saved", "Close");
                }
                else
                {
                    DisplayAlert("Failed", "Data not saved", "Close");
                }
            }
        }
Exemplo n.º 41
0
        private void Button_Clicked(object sender, EventArgs e)
        {
            using (var conn = new SQLite.SQLiteConnection(App.DB_PATH))
            {
                conn.CreateTable <Word>();

                var word = new Word()
                {
                    WordInEnglish  = englishEntry.Text,
                    WordInJapanese = japaneseEntry.Text,
                };

                var numberOfRows = conn.Insert(word);
                if (numberOfRows > 0)
                {
                    DisplayAlert("Success", $"{japaneseEntry.Text}:{englishEntry.Text} が登録されました!", "OK");
                }
                else
                {
                    DisplayAlert("Failure", "登録に失敗しました……", "OK");
                }
            }
        }
        async void UpdateFunction(object sender, EventArgs e)
        {
            if (entry_en.Text != "" && entry_tr.Text != "")
            {
                var db = new SQLite.SQLiteConnection(_dbPath);

                WordPair wp = new WordPair()
                {
                    ID = item.ID,
                    TR = entry_tr.Text,
                    EN = entry_en.Text
                };
                db.Update(wp);

                await DisplayAlert("Info", wp.TR + "-" + wp.EN + " pair is updated successfully.", "OK");

                await Navigation.PopModalAsync();
            }
            else
            {
                await DisplayAlert("Warning!", "Lack of entry.", "OK");
            }
        }
Exemplo n.º 43
0
        private void Button_Clicked(object sender, EventArgs e)
        {
            Book book = new Book()
            {
                Name   = nameEntry.Text,
                Author = authorEntry.Text
            };

            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_PATH))
            {
                conn.CreateTable <Book>();
                var numberOfRows = conn.Insert(book);

                if (numberOfRows > 0)
                {
                    DisplayAlert("Success!", "Book inserted!", "Great");
                }
                else
                {
                    DisplayAlert("Failure", "Book failed to be inserted", "Damn it");
                }
            }
        }
Exemplo n.º 44
0
        private async void CreateTask_Clicked(object sender, EventArgs e)
        {
            if (Projects.SelectedItem != null)
            {
                Project p = (Project)Projects.SelectedItem;

                Tasks task = new Tasks()
                {
                    Title         = TaskTitle.Text,
                    Description   = TaskDescription.Text,
                    Project_ID    = p.ID,
                    Project_title = p.Title
                };

                using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "ToDoAppDB.db")))
                {
                    conn.CreateTable <Tasks>();
                    conn.Insert(task);
                }

                await DisplayAlert(null, task.Title + " Saved", "Ok");
            }
        }
Exemplo n.º 45
0
 public static bool InsertSafe(this SQLite.SQLiteConnection conn, object obj)
 {
     while (true)
     {
         try
         {
             conn.Insert(obj);
             return(true);
         }
         catch (SQLite.SQLiteException ex)
         {
             if (ex.Result == SQLite.SQLite3.Result.Constraint)
             {
                 return(false);
             }
             if (ex.Result != SQLite.SQLite3.Result.Busy)
             {
                 throw ex;
             }
             System.Threading.Thread.Sleep(10);
         }
     }
 }
Exemplo n.º 46
-1
 public bool Exists(string code, int projectId)
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         return db.ExecuteScalar<int>("select count(Code) from Locale where ProjectId = ? and Code = ?", projectId, code) > 0;
     }
 }