示例#1
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>

        private void ResetData()
        {
            using (var db = new SQLite.SQLiteConnection(DBPath))
            {
                // Empty the Customer and Project tables
                db.DeleteAll <Customer>();
                db.DeleteAll <Project>();

                // Add seed customers and projects

                var newCustomer = new Customer()
                {
                    Name    = "Tailspin Toys",
                    City    = "Kent",
                    Contact = "Michelle Alexander"
                };
                db.Insert(newCustomer);

                db.Insert(new Project()
                {
                    CustomerId  = newCustomer.Id,
                    Name        = "Kids Game",
                    Description = "Windows Store app",
                    DueDate     = DateTime.Today.AddDays(60)
                });
            }
        }
示例#2
0
 public CredentialsService()
 {
     try
     {
         database = DependencyService.Get <ISQLiteSetup>().GetConnection();
         database.CreateTable <Person>();
         database.CreateTable <Verification>();
         if (database.Table <Person>().Count() == 0)
         {
             Person demo = new Person()
             {
                 Name = "John", Surname = "Doe", Admin = true, Position = "Manager"
             };
             database.Insert(demo);
             database.Insert(new Verification()
             {
                 Username = "******", Password = "******", PersonId = demo.Id
             });
         }
         database.CreateTable <CheckInOut>();
     }
     catch (Exception e)
     {
         Debug.WriteLine($"Error instantiating connection to the database!! {e.Message}");
     }
 }
示例#3
0
        private void PopulateTables(SQLite.SQLiteConnection connection, string jsonCallback)
        {
            /*
             *          Regex regex = new Regex("[(.*?)]");
             *          var v = regex.Match(jsonCallback);
             *          string json = v.Groups[1].ToString();
             */
            string json = jsonCallback.Replace("staticDataCallback([", "");

            json = json.Replace("])", "");

            StaticData staticData = JsonConvert.DeserializeObject <StaticData>(json);

            if (staticData != null)
            {
                if (staticData.MediaStatus != null)
                {
                    foreach (var item in staticData.MediaStatus)
                    {
                        var entity = new MediaStatusEntity {
                            ID = item.Id, Name = item.Name, Key = item.Key
                        };
                        connection.Insert(entity);
                    }
                }

                if (staticData.MediaType != null)
                {
                    foreach (var item in staticData.MediaType)
                    {
                        var entity = new MediaTypeEntity {
                            ID = item.Id, Name = item.Name, Key = item.Key
                        };
                        connection.Insert(entity);
                    }
                }

                if (staticData.FavoriteMusic != null)
                {
                    foreach (var item in staticData.FavoriteMusic)
                    {
                        var entity = new FavoriteMusicEntity {
                            ID = item.Id, Name = item.Name, Key = item.Key
                        };
                        connection.Insert(entity);
                    }
                }

                if (staticData.FavoriteSport != null)
                {
                    foreach (var item in staticData.FavoriteSport)
                    {
                        var entity = new FavoriteSportEntity {
                            ID = item.Id, Name = item.Name, Key = item.Key
                        };
                        connection.Insert(entity);
                    }
                }
            }
        }
示例#4
0
        private async System.Threading.Tasks.Task obtenerLiquidacionesAsync()
        {
            using (var client = new HttpClient())
            {
                try
                {
                    string url    = baseURL + "Liquidaciones/Listado/" + trabajador.Id;
                    var    result = await client.GetStringAsync(url);

                    List <MLiquidacion> liquidaciones = JsonConvert.DeserializeObject <List <MLiquidacion> >(result);
                    db.DeleteAll <MLiquidacion>();
                    db.DeleteAll <MDetalleLiquidacion>();
                    foreach (var a in liquidaciones)
                    {
                        db.Insert(a);
                        foreach (var b in a.Detalles)
                        {
                            db.Insert(b);
                        }
                    }
                    syncLiquidaciones = true;
                    TerminoSincronizacion();
                }
                catch (System.Exception ex)
                {
                    RunOnUiThread(() => Toast.MakeText(this.BaseContext, "Ocurrió el siguiente error al sincronizar idiomas: " + ex.Message, ToastLength.Long).Show());
                }
            }
        }
示例#5
0
 public bool SaveAdvice(ObservableCollection <Data.PadAdvice> ListNewAdvice, ref string exMsg)
 {
     using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(iDB.DbFile))
     {
         try
         {
             conn.BeginTransaction();
             foreach (Data.PadAdvice advice in ListNewAdvice)
             {
                 conn.Insert(advice);
                 Data.SyncLog slLog = new SyncLog()
                 {
                     LogID      = Guid.NewGuid().ToString(),
                     TableName  = "[PadAdvice]",
                     KeyField   = "PAID",
                     KeyValue   = advice.PAID,
                     ChangeType = "INSERT",
                     ChangeDate = iCommon.DateNow
                 };
                 conn.Insert(slLog);
             }
             conn.Commit();
         }
         catch (Exception ex)
         {
             exMsg = ex.Message;
             return(false);
         }
     }
     return(true);
 }
示例#6
0
        public bool InsertEvent(Event ae1)
        {
            try
            {
                //Create event
                if (db.GetTableInfo("Event").Count == 0)
                {
                    db.CreateTable <Event>();
                }



                int numberOfRows = db.Insert(ae1);
                //Inserted event
                if (numberOfRows > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
示例#7
0
 /// <summary>
 /// 将服务器最新费用信息与本地数据比较,同步至最新状态
 /// </summary>
 /// <param name="adviceList"></param>
 /// <param name="resultList"></param>
 /// <returns></returns>
 bool SyncDevicePatientFeeToLocal(List <Data.PatientFee> feeList, List <Data.PatientPrepay> prepayList)
 {
     using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(iDB.DbFile))
     {
         conn.BeginTransaction();
         foreach (PatientFee fee in feeList)
         {
             var existFee = conn.Table <PatientFee>().Where(f => f.InhosID == fee.InhosID && f.FeeTypeCode == fee.FeeTypeCode).SingleOrDefault();
             if (existFee == null)
             {
                 conn.Insert(fee);
             }
             else
             {
                 conn.Update(fee);
             }
         }
         foreach (PatientPrepay prepay in prepayList)
         {
             var existPrepay = conn.Table <PatientPrepay>().Where(pp => pp.InhosID == prepay.InhosID && pp.PayDate == prepay.PayDate).SingleOrDefault();
             if (existPrepay == null)
             {
                 conn.Insert(prepay);
             }
             else
             {
                 conn.Update(prepay);
             }
         }
         conn.Commit();
     }
     return(true);
 }
示例#8
0
        private void LoadInitialData()
        {
            using (var db = new SQLite.SQLiteConnection(DBPath))
            {
                ListItem li = new ListItem
                {
                    Id        = Guid.NewGuid(),
                    Title     = "Books",
                    CreatedOn = DateTime.Now,
                    SortBy    = ListSortType.CreationDate
                };

                db.Insert(li);
                li = new ListItem
                {
                    Id        = Guid.NewGuid(),
                    Title     = "Movies",
                    CreatedOn = DateTime.Now,
                    SortBy    = ListSortType.CreationDate
                };
                db.Insert(li);

                li = new ListItem
                {
                    Id        = Guid.NewGuid(),
                    Title     = "Songs",
                    CreatedOn = DateTime.Now,
                    SortBy    = ListSortType.CreationDate
                };
                db.Insert(li);
            }
        }
示例#9
0
        public static async Task NavigateToProfile(Models.FacebookResponse profile)
        {
            if (profile == null)
            {
                Application.Current.MainPage = new NavigationPage(new LoginPage());
                return;
            }

            var apiService = new ApiService();

            var apiSecurity = Application.Current.Resources["APISecurity"].ToString();
            var token       = await apiService.LoginFacebook(
                apiSecurity,
                "/api",
                "/Users/LoginFacebook",
                profile);

            if (token == null)
            {
                Application.Current.MainPage = new NavigationPage(new LoginPage());
                return;
            }

            var user = await apiService.GetUserByEmail(
                apiSecurity,
                "/api",
                "/Users/GetUserByEmail",
                token.TokenType,
                token.AccessToken,
                token.UserName);

            UserLocal userLocal = null;

            if (user != null)
            {
                userLocal = Converter.ToUserLocal(user);

                //Save Local User in SQLite
                using (var conn = new SQLite.SQLiteConnection(App.root_db))
                {
                    conn.CreateTable <UserLocal>();
                    conn.CreateTable <TokenResponse>();

                    conn.Insert(token);
                    conn.Insert(userLocal);
                }
            }

            var mainViewModel = MainViewModel.GetInstance();

            mainViewModel.Token = token;
            mainViewModel.User  = userLocal;

            mainViewModel.Lands          = new LandsViewModel();
            Application.Current.MainPage = new MasterPage();
            Settings.IsRemembered        = "true";

            mainViewModel.Lands          = new LandsViewModel();
            Application.Current.MainPage = new MasterPage();
        }
        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));
        }
示例#11
0
        void CreateNewInv()
        {
            DateTime  invdate = Utility.ConvertToDate(txtInvDate.Text);
            DateTime  tmr     = invdate.AddDays(1);
            AdNumDate adNum;            // = DataHelper.GetNumDate (pathToDatabase, invdate);

            apara = DataHelper.GetAdPara(pathToDatabase);
            string[] prefixs = apara.Prefix.Trim().ToUpper().Split(new char[] { '|' });
            string   prefix  = "";

            adNum = DataHelper.GetNumDate(pathToDatabase, invdate, "INV");
            if (prefixs.Length > 1)
            {
                prefix = prefixs [0];
            }
            else
            {
                prefix = prefixs [0];
            }

            invno = "";
            int runno        = adNum.RunNo + 1;
            int currentRunNo = DataHelper.GetLastInvRunNo(pathToDatabase, invdate, "INVOICE");

            if (currentRunNo >= runno)
            {
                runno = currentRunNo + 1;
            }

            invno = prefix + invdate.ToString("yyMM") + runno.ToString().PadLeft(4, '0');

            using (var db = new SQLite.SQLiteConnection(pathToDatabase)) {
                inv            = new Invoice();
                inv.invno      = invno;
                inv.invdate    = invdate;
                inv.trxtype    = "INVOICE";
                inv.created    = DateTime.Now;
                inv.amount     = 0;
                inv.isUploaded = false;
                inv.remark     = "";
                db.Insert(inv);
                adNum.RunNo = runno;
                if (adNum.ID >= 0)
                {
                    db.Update(adNum);
                }
                else
                {
                    db.Insert(adNum);
                }
            }
            txtInvNo.Text   = inv.invno;
            txtInvDate.Text = inv.invdate.ToString("dd-MM-yyyy");
            txtInvMode.Text = "NEW";
            IsSave          = false;
            IsFirePaid      = false;
            IsFirePaidOnly  = false;
            EnableControLs(true, true, false, true, false);
        }
示例#12
0
 public int SaveItem(Subjects item)
 {
     if (item.Id != 0)
     {
         database.Update(item);
         return(item.Id);
     }
     else
     {
         return(database.Insert(item));
     }
 }
 private void insertSQL()
 {
     using (var db = new SQLite.SQLiteConnection(DbPath))
     {
         db.Insert(new Todo()
         {
             Title = "おいしい牛乳", TimeStamp = DateTime.Now, Detail = "スーパーに5本買いに行く"
         });
         db.Insert(new Todo()
         {
             Title = "イヤーピース", TimeStamp = DateTime.Now, Detail = "スーパーに5本買いに行く"
         });
     }
 }
示例#14
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;
            }
        }
        private void Button_Clicked(object sender, EventArgs e)
        {
            Company company = new Company()
            {
                companyName = companyName.Text,
                email       = emailAddress.Text,
                address     = companyAddress.Text,
                city        = city.Text,
                feePerKm    = double.Parse(feePerKm.Text, System.Globalization.CultureInfo.InvariantCulture),
                password    = password.Text
            };

            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_PATH))
            {
                conn.CreateTable <Company>();
                var numberOfRows = conn.Insert(company);
                if (numberOfRows > 0)
                {
                    Navigation.PushAsync(new LoginPage());
                }
                else
                {
                    DisplayAlert("Failure", "Company not created", "Sorry");
                    clearFields();
                }
            }
        }
示例#16
0
 public void Insert(Locale model)
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         db.Insert(model);
     }
 }
示例#17
0
        private void Button_Clicked(object sender, EventArgs e)
        {
            Journal journal = new Journal()
            {
                JournalName   = titleEntry.Text,
                JournalDetail = detailEntry.Text,
                PostDate      = DateTime.Now
            };

            //create connection to database. when you use "using", you dont need close connection
            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_PATH))
            {
                //make sure the table exist
                conn.CreateTable <Journal>();
                //number of rows in table
                var numberOfRows = conn.Insert(journal);

                if (numberOfRows > 0)
                {
                    DisplayAlert("Success", "Journal succesfully inserted", "Great!");
                }
                else
                {
                    DisplayAlert("Failure", "Journal failed to be inserted", "Dang it!");
                }
            }

            Navigation.PushAsync(new MainPage());
        }
示例#18
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;
        }
示例#19
0
        private void Register_Clicked(object sender, EventArgs e)
        {
            try
            {
                //Navigation.PushModalAsync(new Views.HomePage());
                UserModel user = new UserModel();
                user.Fullname = fullnameEntry.Text;
                user.Email    = emailEntry.Text;
                user.Password = passwordEntry.Text;
                user.Username = usernameEntry.Text;
                user.MobileNo = mobilenoEntry.Text;

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

                    if (numberOfRows > 0)
                    {
                        DisplayAlert("Success", "You have registered successfully.", "OK");
                    }
                    else
                    {
                        DisplayAlert("Failed", "Failed to register user.", "Close");
                    }
                }
            }
            catch (Exception ex)
            {
                DisplayAlert("Success", ex.Message, "OK");
            }
        }
示例#20
0
        public void _saveCategory()
        {
            using (var db = new SQLite.SQLiteConnection(App.DBPath))
            {
                try
                {
                    var existingCategory = (db.Table <Category>().Where(
                                                c => c.ID == _cID)).SingleOrDefault();

                    if (existingCategory != null)
                    {
                        existingCategory.Name = _cName;
                        int success = db.Update(existingCategory);
                        _selectedCategory = existingCategory;
                    }
                    else
                    {
                        int success = db.Insert(new Category()
                        {
                            ID   = _cID,
                            Name = _cName
                        });
                    }
                }
                catch (Exception e)
                {
                    new Windows.UI.Popups.MessageDialog("Couldn't save category to database :(" + Environment.NewLine + e.Message).ShowAsync();
                }
            }
            RaisePropertyChangedEvent("FoodCategories");
        }
示例#21
0
 private void Insert(Source model)
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         db.Insert(model);
     }
 }
示例#22
0
        private void Button_Clicked(object sender, EventArgs e)
        {
            Task task = new Task()
            {
                taskName = taskEntry.Text,
                taskNote = noteEntry.Text,
                taskTime = timeEntry.Text
            };

            // Database Connection
            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_PATH))
            {
                //Generate Table
                conn.CreateTable <Task>();
                //Instert Values Into DB
                var numberOfRows = conn.Insert(task);

                if (numberOfRows > 0)
                {
                    DisplayAlert("Success", "Success", "Success");
                }
                else
                {
                    DisplayAlert("error", "error", "error");
                }
            }
        }
示例#23
0
        private void SendData(object sender, EventArgs args)
        {
            Data userdata = new Data()
            {
                NameOfContact = NameEntry1.Text,
                Relationship  = RelationshipEntry1.Text,
                MobileNumber  = MobileEntry1.Text,
                HomeNumber    = HomeEntry1.Text,

                NameOfContact2 = NameEntry1.Text,
                Relationship2  = RelationshipEntry1.Text,
                MobileNumber2  = MobileEntry1.Text,
                HomeNumber2    = HomeEntry1.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");
                }
            }
        }
示例#24
0
        private void butSaveClick(object sender, EventArgs e)
        {
            TextView txtprinter = FindViewById <TextView> (Resource.Id.txtad_printer);

            pathToDatabase = ((GlobalvarsApp)this.Application).DATABASE_PATH;
            AdPara apra = new AdPara();

            apra.PrinterName = txtprinter.Text.ToUpper();
            apra.PrinterType = spinPrType.SelectedItem.ToString();
            apra.PrinterIP   = txtPrinterIP.Text;
            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.PrinterType = spinPrType.SelectedItem.ToString();
                    apra.PrinterName = txtprinter.Text.ToUpper();
                    apra.PaperSize   = spinner.SelectedItem.ToString();
                    apra.PrinterIP   = txtPrinterIP.Text;
                    db.Update(apra);
                }
            }
            base.OnBackPressed();
        }
 void AgregarConsumo(int productId)
 {
     #region AgregarConsumo
     try
     {
         using (SQLite.SQLiteConnection con = new SQLite.SQLiteConnection(App.RutaDB))
         {
             var userSession        = (Models.User)App.Current.Properties["user"];
             var employee           = con.Table <Models.Employee>().FirstOrDefault(f => f.EmployeeNumber == txtEmployeeNumber.Text);
             var objEmployeeProduct = new Models.EmployeeProduct()
             {
                 CompanyId          = userSession.CompanyId,
                 EmployeeId         = employee != null ? employee.EmployeeId : 0,
                 EmployeeNumber     = employee != null ? employee.EmployeeNumber : string.Empty,
                 EmployeeName       = employee != null ? employee.Name : string.Empty,
                 EmployeeProductId  = 0,
                 CompanyDescription = "",
                 ProductDescription = "",
                 ProductId          = productId,
                 RegistrationDate   = DateTime.Now,
                 Status             = false,
                 StatusDescription  = string.Empty,
                 AddedToService     = false
             };
             con.Insert(objEmployeeProduct);
             listEmployeeProduct.Add(objEmployeeProduct);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     #endregion
 }
示例#26
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;
        }
示例#27
0
        private void Enter_Clicked(object sender, EventArgs e)
        {
            //calling the class Player
            Player player = new Player()
            {
                Name = namePlayer.Text
            };

            //using using method so that the dispose() will not overload.
            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DATABASE_PATH))
            {
                conn.CreateTable <Player>();
                var numberOfRows = conn.Insert(player);


                if (numberOfRows > 0)
                {
                    DisplayAlert("Success!", "Player successfully added ", "Great!");
                }
                else
                {
                    DisplayAlert("Failure!", "Player not added ", "Oh Dang!");
                }
            }
        }
示例#28
0
 /// <summary>
 /// 保存一个查房日志到本地
 /// </summary>
 /// <param name="CheckLog"></param>
 public void SaveCheckLogToLocal(Data.DoctorCheckLog CheckLog)
 {//To do:修改病人的同步标志,标识需同步查房日志
     using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(iDB.DbFile))
     {
         string SqlCheckLog                 = @"Select * From [DoctorCheckLog] Where [DCLID]=?";
         SQLite.SQLiteCommand cmd           = conn.CreateCommand(SqlCheckLog, CheckLog.DCLID);
         Data.DoctorCheckLog  existCheckLog = cmd.ExecuteQuery <DoctorCheckLog>().SingleOrDefault();
         Data.SyncLog         slCheckLog    = new SyncLog()
         {
             TableName  = "[DoctorCheckLog]",
             KeyField   = "DCLID",
             KeyValue   = CheckLog.DCLID,
             ChangeType = "INSERT"
         };
         if (existCheckLog == null)
         {
             conn.Insert(CheckLog);
         }
         else
         {
             conn.Update(CheckLog);
             slCheckLog.ChangeType = "UPDATE";
         }
         SaveSyncLog(conn, slCheckLog);
     }
 }
示例#29
0
 /// <summary>
 /// 保存设备信息至本地数据库
 /// </summary>
 /// <param name="device"></param>
 public void SaveDeviceInfoToLocal(iDevice device)
 {
     using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(iDB.DbFile))
     {
         conn.Insert(device);
     }
 }
示例#30
0
        private void OnButtonInsert(object sender, EventArgs e)
        {
            // 登録制限
            if (insertText.Text == null || insertText.Text == "")
            {
                // 登録成功アラート
                DisplayAlert("登録失敗", "入力文字が空です。", "OK");
                return;
            }

            DateTime temp_now  = DateTime.Now;
            String   temp_word = insertText.Text;

            // データ追加
            using (var db = new SQLite.SQLiteConnection(MainPage.DbPath))
            {
                db.Insert(new SearchWord()
                {
                    TimeStamp = temp_now, Word = temp_word
                });
                foreach (var row in db.Query <SearchWord>("select Id, Word, TimeStamp from SearchWord where ROWID = last_insert_rowid();"))
                {
                    MainPage.WordListData.Add(new SearchWordList(row.Id, row.Word, row.TimeStamp.ToString()));
                }
            }
            // 登録成功アラート
            DisplayAlert("登録成功", insertText.Text + "を登録しました。", "OK");
        }
        private void ColumnNumberSelectedEvent(object sender, EventArgs e)
        {
            Picker picker      = sender as Picker;
            var    selectedVal = picker.SelectedItem.ToString().Substring(0, 1);

            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_PATH))
            {
                conn.CreateTable <Preference>();

                var res = conn.Table <Preference>().FirstOrDefault(p => p.Key == "numOfCol");

                Preference pref = new Preference()
                {
                    Key   = "numOfCol",
                    Value = "3"
                };

                if (res == null && selectedVal != res.Value)
                {
                    conn.Insert(pref);
                }
                else if (selectedVal != res.Value)
                {
                    res.Value = selectedVal;
                    conn.Update(res);
                }
            }
        }
        public void GuardarList(List <Receta> Receta)
        {
            lock (locker) {
                foreach (Receta r in Receta)
                {
                    Receta receta = new Receta()
                    {
                        _IdReceta          = r._IdReceta,
                        _Titulo            = r._Titulo,
                        _Descripcion       = r._Descripcion,
                        _IdMomentoDia      = r._IdMomentoDia,
                        _IdEstacion        = r._IdEstacion,
                        _Dificultad        = r._Dificultad,
                        _TiempoPreparacion = r._TiempoPreparacion,
                        _CantCalorias      = r._CantCalorias,
                        _Email             = r._Email,
                        _CantPlatos        = r._CantPlatos,
                        _Costo             = r._Costo,
                        _FechaCreacion     = r._FechaCreacion,
                        _PuntajeTotal      = r._PuntajeTotal,
                        _AptoCeliacos      = r._AptoCeliacos,
                        _AptoDiabeticos    = r._AptoDiabeticos,
                        _AptoVegetarianos  = r._AptoVegetarianos,
                        _AptoVeganos       = r._AptoVeganos,
                    };

                    database.Insert(receta);
                }
            }
        }
示例#33
0
        async void ButtonClicked(object sender, EventArgs e)
        {
            User user = new User()
            {
                Name     = nameEntry.Text,
                Birthday = (bdayPick.Date).ToShortDateString(),
                Email    = emailEntry.Text,
            };

            if (user.Name == "")
            {
            }
            else
            {
                user.Appointments = new List <Appointment>
                {
                };
                user.Prescriptions = new List <Prescription>
                {
                };
                using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.FilePath))
                {
                    conn.CreateTable <User>();
                    conn.CreateTable <Appointment>();
                    conn.CreateTable <Prescription>();
                    conn.Insert(user);
                    await Navigation.PopModalAsync();
                }
            }
        }
示例#34
0
        private void Calc_Loan(object sender, EventArgs e)
        {
            Loan loan = new Loan()
            {
                name     = nameEntry.Text,
                amount   = Decimal.Parse(amountEntry.Text),
                interest = Decimal.Parse(interestEntry.Text),
                period   = Decimal.Parse(periodEntry.Text),
            };


            Double payment = CalcPayment((Double)loan.interest, (Double)loan.period, (Double)loan.amount);

            for (int i = 0; i < loan.period; i++)
            {
            }

            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_PATH)) {
                conn.CreateTable <Loan>();
                int cnt = conn.Insert(loan);

                if (cnt > 0)
                {
                    DisplayAlert("Saving loan", "Loan saved !", "Ok");
                }
            }
        }
示例#35
0
 public void AddBill(Bill bill)
 {
     using (var db = new SQLite.SQLiteConnection(DBPath))
     {
         db.Insert(bill);
     }
 }
示例#36
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();
 }
示例#37
0
            public void addMeterBox(string meterBoxNumber, double current)
            {
                
                string result = string.Empty;
                using (var db = new SQLite.SQLiteConnection(app.DBPath))
                    try
                    {
                        db.CreateTable<MeterBox>();
                        int success1 = db.Insert(new MeterBox()
                        {
                            ID = 0,
                            meterBoxNumber = meterBoxNumber,
                            currentUnits = current
                        });
                        var existing = db.Query<MeterBox>("select * from MeterBox").First();
                        if (existing == null)
                        {
                                int success = db.Insert(new MeterBox()
                            {
                                ID = 0,
                                meterBoxNumber = meterBoxNumber,
                                currentUnits = current
                            });
                        }
                        else if(existing != null)
                        {
                            existing.meterBoxNumber = meterBoxNumber;
                            existing.currentUnits = current;
                            db.RunInTransaction(() =>
                            {
                                db.Update(existing);
                            });
                        }
                  
                    }
                    catch (Exception e)
                    {

                    }
                //return "Success";
            }
        public void addInstitution(string name)
        {
            using (var db = new SQLite.SQLiteConnection(app.dbPath))
            {
                var insert = db.Insert(new Institution()
                {
                    Id = 0,
                    insitution = name
                });

            }
        }
示例#39
0
 public void InsertUserLikes(string recipeName, string memberName)
 {
     using (var db = new SQLite.SQLiteConnection(app.dbPath))
     {
         var query = db.Insert(new Likes()
         {
             likesId = 0,
             memName = memberName,
             recipeName = recipeName
         });
     }
 }
示例#40
0
       private void setLogIn(string pword, string userName,string id)
       {

           using (var db = new SQLite.SQLiteConnection(app.dbPath))
           {
               int success = db.Insert(new tblLogIn()
               {
                  ID = id,
                  Username = userName,
                  Password = pword,
               });
           }

       }
示例#41
0
 public void memberDetails(string _name, string _surname, string _email, string _password)
 {
     using (var db = new SQLite.SQLiteConnection(app.dbPath))
     {
         var query = db.Insert(new Member()
         {
             memId = 0,
             name = _name,
             surname = _surname,
             email = _email,
             password = _password
         });
     }
 }
示例#42
0
 public void savePowerballGeneratedNumbers(int first, int second, int third, int fourth, int fifth)
 {
     using (var db = new SQLite.SQLiteConnection(app.dbPath))
     {
         var query = db.Insert(new PowerBallSaved()
         {
             Id = 0,
             num1 = first,
             num2 = second,
             num3 = third,
             num4 = fourth,
             num5 = fifth
         });
     }
 }
示例#43
0
		public void InsertPerson()
		{
			if (!databaseCreated) 
			{
				if(File.Exists(GetDatabasePath ()))
					File.Delete (GetDatabasePath ());
				CreateTable ();
				databaseCreated = true;
			}

			var person = new Person { FirstName = "John", LastName = "Doe", TimeStamp = DateTime.Now.Ticks.ToString()};
			using (var db = new SQLite.SQLiteConnection(GetDatabasePath() ))
			{
				db.Insert(person);
			}
		}
示例#44
0
 public void setUserSavedNumbers(int a, int b, int c, int d, int e, int f)
 {
     using (var db = new SQLite.SQLiteConnection(app.dbPath))
     {
         var query = db.Insert(new LottoSaved()
         {
             Id = 0,
             num1 = a,
             num2 = b,
             num3 = c,
             num4 = d,
             num5 = e,
             num6 = f
         });
     }
 }
示例#45
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)
        {
            // Initialize the database if necessary
            using (var db = new SQLite.SQLiteConnection(DBPath))
            {
                // Create the tables if they don't exist
                db.CreateTable<Day>();
                db.CreateTable<Intake>();
                Day day = new Day();
                day.Date = DateTime.Today;
                db.Insert(day);
            }

            CurrentDay = DayViewModel.GetDayByDate(DateTime.Today);

            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
                }

                // 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();
        }
示例#46
0
 public void Save(Preference model)
 {
     using (var db = new SQLite.SQLiteConnection(Settings.DatabasePath))
     {
         var existingCount = db.ExecuteScalar<int>("select count(Name) from Preference where Name = ?",
            model.Name);
         if (existingCount == 0)
         {
             db.Insert(model);
         }
         else
         {
             db.Execute("update Preference set Value = ? where Name = ?",
                 model.Value, model.Name);
         }
     }
 }
示例#47
0
 public void addUser(string username, string password)
 {
     string result = string.Empty;
     using (var db = new SQLite.SQLiteConnection(app.DBPath))
     try {
         int success = db.Insert(new User() 
         {
             USER_EMAIL = username,
             PASSWORD = password
         });
     }
     catch (Exception e)
     {
         
     }
     //return "Success";
 }
示例#48
0
 public void setStoreLottoLiveResults(int one, int two, int three, int four, int five, int six, int bonus, string date)
 {
     using (var db = new SQLite.SQLiteConnection(app.dbPath))
     {
         var query = db.Insert(new LottoLiveResults()
         {
             Id = 0,
             date = date,
             num1 = one,
             num2 = two,
             num3 = three,
             num4 = four,
             num5 = five,
             num6 = six,
             bonus = bonus
         });
     }
 }
示例#49
0
        private void btnRegister_Click(object sender, RoutedEventArgs e)
        {
            if (FieldValidationExtensions.GetIsValid(RegisterUserName) && FieldValidationExtensions.GetIsValid(RegisterPassword) && FieldValidationExtensions.GetIsValid(RegisterEmail))
            {
                var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
                using (var db = new SQLite.SQLiteConnection(dbPath))
                {
                    db.CreateTable<User>();

                    db.RunInTransaction(() =>
                        {
                            db.Insert(new User() { UserName = RegisterUserName.Text, PassWord = RegisterPassword.Password, EmailAddress = RegisterEmail.Text });
                        });
                }

                this.Frame.Navigate(typeof(MainPage));
            }
        }
        public void addMeterBox(string meterBoxNumber,double current)
        {
            string result = string.Empty;
            using (var db = new SQLite.SQLiteConnection(app.DBPath))
                try
                {
                    int success = db.Insert(new MeterBox()
                    {
                        ID = 0,
                        meterBoxNumber = meterBoxNumber,
                        currentUnits = current
                    });
                }
                catch (Exception e)
                {

                }
            //return "Success";
        }
示例#51
0
       public void addOldAgeManually(string name,string loc)
        {
            using (var db = new SQLite.SQLiteConnection(app.dbPath))
            {
                try
                {
                    int data = db.Insert(new OldAge()
                    {
                        name = name,
                        location = loc
                    });
                }
                catch (Exception e)
                {

                }
            }

        }
示例#52
0
       // registration method
       public void setRegister(string IDnum, string name, string surname, string email,string cell, string gender, int age, string password)
       {

           using (var db = new SQLite.SQLiteConnection(app.dbPath))
           {
               int success = db.Insert(new tblRegister()
               {
                   ID = IDnum,
                   Name = name,
                   Surname = surname,
                   Email = email,
                   Gender = gender,
                   Age = age,
                   Province = "Gua",
               });
             
           }
           setLogIn(password, email, IDnum);

       }
示例#53
0
        public void addOphenagebManually(string name)
        {
            using (var db = new SQLite.SQLiteConnection(app.dbPath))
            {
                try
                {
                    int data = db.Insert(new Orphanage()
                    {
                        Id = 0,
                        name = name,
                      
                    });
                }
                catch (Exception e)
                {

                }
            }

        }
示例#54
0
 public void saveHistory(int numberOfAppliances, double usedWatts, double remaining_watts, string date)
 {
     using (var db = new SQLite.SQLiteConnection(app.DBPath))
     {
         try
         {
             int data = db.Insert(new History()
             {
                 ID = 0,
                 number_of_appliances = numberOfAppliances,
                 used_watts = usedWatts,
                 remaining_watts = remaining_watts,
                 date = date
             });
         }
         catch (Exception e)
         {
             //result = "This Appliance was not saved";
         }
     }
 }
        public bool AddCollection(CollectionViewModel model)
        {
            try
            {
                using (var db = new SQLite.SQLiteConnection(app.DBPath))
                {
                    int success = db.Insert(new Collection()
                    {
                        Title = model.Title,
                        DateCreated = DateTime.Now,
                        Void = false
                    });
                    if (success != 0)
                        return true;
                }
                return false;
            }

            catch
            {
                return false;
            }
        }
        public void addAppliance(string name, int watts, int number)
        {
            //string result = string.Empty;
            using (var db = new SQLite.SQLiteConnection(app.DBPath)) 
            {
                try
                {
                    int data = db.Insert(new Appliance()
                    {

                        ID = 0,
                        applianceName = name,
                        WATTS = watts,
                        numberOfAppliances = number
                    });
                    //result = "Success";
                }
                catch (Exception e)
                { 
                    //result = "This Appliance was not saved";
                }
            }

        }
示例#57
0
 public void addUser(string name, string surname, int age, string idNumber, string language, string contact, string email, string username, string password)
 {
     string result = string.Empty;
     using (var db = new SQLite.SQLiteConnection(app.dbPath))
     try {
         int success = db.Insert(new User() 
         {
              name = name,
              surname = surname,
              age = age,
              idNumber = idNumber,
              homeLanguage = language,
              contactNum = contact,
              emailAddress = email,
              username = username,
              password = password
         });
     }
     catch (Exception e)
     {
         
     }
     //return "Success";
 }
        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));

        }
示例#59
0
        private void Button_Add(object sender, RoutedEventArgs e)
        {
            this.DBPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "toDoListDB.sqlite");
            using (var db = new SQLite.SQLiteConnection(this.DBPath))
            {
                db.Insert(new ToDo()
                {
                    Name = activity.Text,
                    Goal = Int32.Parse(goal.Text),
                    Status = 0,
                    Description = description.Text
                });
            }
            if (this.Frame != null)
            {
                this.Frame.Navigate(typeof(MainPage));
            }

        }
示例#60
0
        private void ResetData()
        {
            using (var db = new SQLite.SQLiteConnection(this.DBPath))
            {
                // Empty the Customer and Project tables 
                //db.DeleteAll<Collection>();
                //db.DeleteAll<Album>();
                db.DropTable<Collection>();
                db.DropTable<Album>();
                db.CreateTable<Collection>();
                db.CreateTable<Album>();

                // Add seed customers and projects
                db.Insert(new Collection()
                {
                    Id = 1,
                    Title = "Relaxing Music",
                    DateCreated = DateTime.Now.AddDays(-3),
                    Image = "Assets/DarkGray.png",
                    Void = false
                });
                db.Insert(new Collection()
                {
                    Id = 2,
                    Title = "Hardcore Metal",
                    DateCreated = DateTime.Now.AddDays(-2),
                    Image = "Assets/MediumGray.png",
                    Void = false
                });
                db.Insert(new Collection()
                {
                    Id = 3,
                    Title = "Best 90s Music",
                    DateCreated = DateTime.Now.AddDays(-1),
                    Image = "Assets/LightGray.png",
                    Void = false
                });
                db.Insert(new Album()
                {
                    Id = 1,
                    Title = "Believe",
                    Artist = "Cher",
                    CollectionId = 1,
                    LastFmId = "2026126",
                    MusicBrainzId = "61bf0388-b8a9-48f4-81d1-7eb02706dfb0",
                    DateAdded = DateTime.Now.AddDays(-4),
                    Void = false
                });
                db.Insert(new Album()
                {
                    Id = 2,
                    Title = "Believe 2",
                    Artist = "Cher",
                    CollectionId = 1,
                    LastFmId = "2026126",
                    MusicBrainzId = "61bf0388-b8a9-48f4-81d1-7eb02706dfb0",
                    DateAdded = DateTime.Now.AddDays(-3),
                    Void = false
                });
                db.Insert(new Album()
                {
                    Id = 3,
                    Title = "Believe 3",
                    Artist = "Cher",
                    CollectionId = 2,
                    LastFmId = "2026126",
                    MusicBrainzId = "61bf0388-b8a9-48f4-81d1-7eb02706dfb0",
                    DateAdded = DateTime.Now.AddDays(-2),
                    Void = false
                });
                db.Insert(new Album()
                {
                    Id = 4,
                    Title = "Believe 4",
                    Artist = "Cher",
                    CollectionId = 3,
                    LastFmId = "2026126",
                    MusicBrainzId = "61bf0388-b8a9-48f4-81d1-7eb02706dfb0",
                    DateAdded = DateTime.Now.AddDays(-1),
                    Void = false
                });

                //2026126","mbid":"61bf0388-b8a9-48f4-81d1-7eb02706dfb0"
                
            }
        }