public static bool setValueByKey(string key_, string value_) { bool res = false; var conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), FullPathSQLite); try { var row = conn.Query <Settings>("select * from Settings where Key=?", key_).FirstOrDefault(); if (row != null) { row.Value = value_; conn.RunInTransaction(() => { conn.Update(row); }); res = true; } else { Settings row_ = new Settings { Key = key_, Value = value_, DefaultValue = value_ }; conn.Insert(row_); res = true; } } catch (Exception ex) { res = false; } return(res); }
// Insert the new contact in the Contacts table. public void Insert(Contacts objContact) { using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH)) { conn.RunInTransaction(() => { conn.Insert(objContact); }); } }
//Update existing conatct public void UpdateRegular(RegularItem _RegularItem) { using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH)) { conn.RunInTransaction(() => { conn.Update(_RegularItem); }); } }
// Insert the new contact in the Contacts table. public void Insert(dynamic objUser) { using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH)) { conn.RunInTransaction(() => { int result = conn.Insert(objUser); System.Diagnostics.Debug.WriteLine("INSERT: " + result); }); } }
//Delete specific contact public void DeleteRegular(int _RegularItemID) { using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH)) { conn.RunInTransaction(() => { RegularItem ri = new RegularItem(_RegularItemID, "", REGULARS_PERIOD.DAYLY, 0); conn.Delete(ri); }); } }
// Insert the new contact in the Contacts table. public void InsertUniqueExpense(UniqueExpenseItem _Item) { using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH)) { conn.RunInTransaction(() => { conn.Insert(_Item); }); // after insert - update total UpdateTotal(conn); } }
//Update existing conatct public void UpdateDetails(ExpenseItem ObjContact) { using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH)) { conn.RunInTransaction(() => { conn.Update(ObjContact); }); // update average UpdateStatistics(conn); } }
//Update existing conatct public void UpdateDetails(Contacts ObjContact) { using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH)) { var existingconact = conn.Query <Contacts>("select * from Contacts where Id =" + ObjContact.Id).FirstOrDefault(); if (existingconact != null) { conn.RunInTransaction(() => { conn.Update(ObjContact); }); } } }
//Update existing Picture public void UpdateDetails(Picture ObjPicture) { using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH)) { var existingPicture = conn.Query <Picture>("select * from Picture where Id =" + ObjPicture.Id).FirstOrDefault(); if (existingPicture != null) { conn.RunInTransaction(() => { conn.Update(ObjPicture); }); } } }
//Delete specific Picture public void DeletePicture(int Id) { using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH)) { var existingconact = conn.Query <Picture>("select * from Picture where Id =" + Id).FirstOrDefault(); if (existingconact != null) { conn.RunInTransaction(() => { conn.Delete(existingconact); }); } } }
//Delete specific contact public void DeleteUniqueExpense(int _ItemID) { using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH)) { conn.RunInTransaction(() => { UniqueExpenseItem ri = new UniqueExpenseItem(_ItemID, DateTime.Now, 0, ""); conn.Delete(ri); }); // after insert - update total UpdateTotal(conn); } }
//Delete specific contact public void DeleteContact(int Id) { using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH)) { conn.RunInTransaction(() => { ExpenseItem ri = new ExpenseItem(Id, DateTime.Now, 0); conn.Delete(ri); }); // update average UpdateStatistics(conn); } }
private void UpdateContact(object sender, RoutedEventArgs e) { string NameValue = Name.Text; string PhoneNumberValue = Phone.Text; var updateContact = connect.Table <Contact>().Where(x => x.name == NameValue).FirstOrDefault(); if (updateContact != null) { updateContact.name = NameValue; updateContact.phonenumber = PhoneNumberValue; connect.RunInTransaction(() => { connect.Update(updateContact); }); } }
private async void syncProductData() { IsProgress = true; isHits = false; try { if (flag == false) { var x = ODataDynamic.Expression; var client = new ODataClient("https://services.odata.org/V4/(S(bnsnosiufp5dcvccgvqylhxc))/OData/OData.svc"); var sproductList = await client.For("Products").FindEntriesAsync(); foreach (var data in sproductList) { int ID = int.Parse(data["ID"].ToString()); using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH)) { conn.RunInTransaction(() => { conn.Insert(new Products(data["Name"].ToString(), ID, data["Description"].ToString())); }); } } flag = true; IsProgress = false; isHits = true; await _dialogService.ShowMessage("Sync Successfully Check Your Data Base..!", "Success"); ProductsListCollection = new DatabaseHelperClass().ReadAllProducts(); } else { await _dialogService.ShowMessage("Already Sync..!", "Warning"); IsProgress = false; isHits = true; } } catch (Exception e) { await _dialogService.ShowMessage(e.Message, "Warning"); } }
private static void Incluir(Deputado objDeputado) { using (SQLite.Net.SQLiteConnection conexao = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH)) { conexao.RunInTransaction(() => { for (int i = 0; i <= 10; i++) { try { conexao.Insert(objDeputado); break; } catch { Task.Delay(5000); continue; } } }); } }
private async void UpdateData(object data) { DetailSViewModel ObjContact = ((DetailSViewModel)data); using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.DB_PATH)) { var existingconact = conn.Query <ContactList>("select * from ContactList where Id =" + Id).FirstOrDefault(); if (existingconact != null) { existingconact.Name = Name; existingconact.Number = Number; existingconact.UpdateDate = DateTime.Now.ToString(); conn.RunInTransaction(() => { conn.Update(existingconact); }); } } MessageDialog messageDialog = new MessageDialog("Updated Successes fully"); await messageDialog.ShowAsync(); _navigationService.GoBack(); }