示例#1
0
        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);
        }
示例#2
0
 // 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);
         });
     }
 }
示例#3
0
 //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);
         });
     }
 }
示例#4
0
 // 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);
         });
     }
 }
示例#5
0
        //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);
            }
        }
示例#7
0
        //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);
            }
        }
示例#8
0
 //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);
             });
         }
     }
 }
示例#9
0
 //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);
             });
         }
     }
 }
示例#10
0
 //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);
            }
        }
示例#12
0
        //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);
            }
        }
示例#13
0
        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);
                });
            }
        }
示例#14
0
        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");
            }
        }
示例#15
0
 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;
                 }
             }
         });
     }
 }
示例#16
0
        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();
        }