コード例 #1
0
 public void Drop()
 {
     using (var connection = new SQLiteConnection(_dbPath))
     {
         connection.DropTable<Account>();
     }
 }
コード例 #2
0
ファイル: SQLiteMethods.cs プロジェクト: sviom/MoneyNote
 //기본 카테고리 생성
 public void BasicSetting()
 {
     try
     {
         //DB와 연결
         SQLiteConnection conn = new SQLiteConnection(dbPath, true);
         //기본 카테고리들 생성
         string[] basicIncomeCategory = { "Salary", "Interest", "Installment Saving", "Allowance" };
         string[] basicExpenseCategory = { "Electronics", "Food", "Internet", "Transport", "Housing" };
         //돌아가면서 Income category insert
         foreach (string tempCategory in basicIncomeCategory)
         {
             IncomeCategoryForm basicCategory = new IncomeCategoryForm
             {
                 categoryName = tempCategory
             };
             conn.Insert(basicCategory);
         }
         //돌아가면서 expense category insert
         foreach (string tempCategory in basicExpenseCategory)
         {
             ExpenseCategoryForm expenseCategory = new ExpenseCategoryForm
             {
                 categoryName = tempCategory
             };
             conn.Insert(expenseCategory);
         }
     }
     catch (Exception ex)
     {
         ex.Message.ToString();
     }
 }
コード例 #3
0
ファイル: MainPage.xaml.cs プロジェクト: peterdn/Geomoir
 private async Task<Location> GetLastLocation()
 {
     using (var db = new SQLiteConnection(Database.DatabasePath))
     {
         return db.Table<Location>().OrderByDescending(x => x.Timestamp).FirstOrDefault();
     }
 }
コード例 #4
0
ファイル: BUser.cs プロジェクト: tienbui123/Mobile-VS2
		public static async Task<Exception> CheckAuth(string id, string pass,SQLiteConnection connection)
		{
			pass = base64Encode (pass);
			var httpClient = new HttpClient ();
			Exception  error;
			httpClient.Timeout = TimeSpan.FromSeconds (20);
			string contents;
			Task<string> contentsTask = httpClient.GetStringAsync ("http://www.schoolapi.somee.com/dangnhap/"+id+"/"+pass);

			try
			{
				contents =  await contentsTask;

			}
			catch(Exception e) {
				error =new Exception("Xảy Ra Lỗi Trong Quá Trình Kết Nối Server");
				return error;
			}
			if (contents.Contains ("false")) {
				error=new Exception("Mã Sinh Viên Hoặc Mật Khẩu Không Đúng");
				return error;

			}
			User usr = new User ();
			usr.Password = pass;
			usr.Id = id;
			Task<string> contentNameTask = httpClient.GetStringAsync ("http://www.schoolapi.somee.com/user/" + id);
			contents=await contentNameTask;
			XDocument doc = XDocument.Parse (contents);
			usr.Hoten= doc.Root.Elements().ElementAt(0).Elements().ElementAt(1).Value.ToString();
			int i = AddUser (connection, usr);
			return null;
		}
コード例 #5
0
 public void Initialize()
 {
     using (var db = new SQLiteConnection(DbPath))
     {
         db.CreateTable<TracklistItem>();
     }
 }
コード例 #6
0
 public void InsertPost(Post post)
 {
     using(Connection = new SQLiteConnection(this.DbPath))
     {
         this.Connection.Insert(post);
     }
 }
コード例 #7
0
			public static List<DiemThi> getAll(SQLiteConnection connection)
			{
				list = new List<DiemThi>();
				DataProvider dtb = new DataProvider (connection);
				list = dtb.GetAllDT ();
				return list;
			}
コード例 #8
0
        public bool AddCategoryOffline(CategoryOfflineViewModel newCategoryOffline, string _synced)
        {
            bool result = false;
            try
            {
                using (var db = new SQLite.SQLiteConnection(_dbPath))
                {
                    CategoryOffline objCategoryOffline = new CategoryOffline();

                    objCategoryOffline.categoryId = Convert.ToString(newCategoryOffline.categoryId);
                    objCategoryOffline.organizationId = Convert.ToString(newCategoryOffline.organizationId);
                    objCategoryOffline.categoryCode = Convert.ToString(newCategoryOffline.categoryCode);
                    objCategoryOffline.categoryDescription = newCategoryOffline.categoryDescription;
                    objCategoryOffline.parentCategoryId = newCategoryOffline.parentCategoryId;
                    objCategoryOffline.imageName = newCategoryOffline.imageName;
                    objCategoryOffline.active = newCategoryOffline.active;

                    objCategoryOffline.synced = _synced;  // i.e. Need to synced when online and Update the synced status = "True"

                    db.RunInTransaction(() =>
                    {
                        db.Insert(objCategoryOffline);
                    });
                }

                result = true;
            }//try
            catch (Exception ex)
            {

            }//catch
            return result;
        }
コード例 #9
0
ファイル: TodoDatabase.cs プロジェクト: djoker07/c_sharp
 /// <summary>
 /// Initializes a new instance of the <see cref="Tasky.DL.TaskDatabase"/> TaskDatabase. 
 /// if the database doesn't exist, it will create the database and all the tables.
 /// </summary>
 /// <param name='path'>
 /// Path.
 /// </param>
 public TodoDatabase()
 {
     database = DependencyService.Get<ISQLite>().GetConnection();
     // create the tables
     database.CreateTable<TODOItem>();
     database.CreateTable<EventItem>();
 }
コード例 #10
0
ファイル: OrmExample.cs プロジェクト: ARMoir/mobile-samples
		/// <returns>
		/// Output of test query
		/// </returns>
		public static string DoSomeDataAccess ()
		{
			var output = "";
			output += "\nCreating database, if it doesn't already exist";
			string dbPath = Path.Combine (
				Environment.GetFolderPath (Environment.SpecialFolder.Personal), "ormdemo.db3");

			var db = new SQLiteConnection (dbPath);
			db.CreateTable<Stock> ();

			if (db.Table<Stock> ().Count() == 0) {
				// only insert the data if it doesn't already exist
				var newStock = new Stock ();
				newStock.Symbol = "AAPL";
				db.Insert (newStock); 

				newStock = new Stock ();
				newStock.Symbol = "GOOG";
				db.Insert (newStock); 

				newStock = new Stock ();
				newStock.Symbol = "MSFT";
				db.Insert (newStock);
			}

			output += "\nReading data using Orm";
			var table = db.Table<Stock> ();
			foreach (var s in table) {
				output += "\n" + s.Id + " " + s.Symbol;
			}

			return output;
		}
コード例 #11
0
        public static void ProcessPath(string databasePath, string filePath)
        {
            //TODO ensure directory exists for the database
            using (var db = new SQLiteConnection(databasePath)) {

                DatabaseLookups.CreateTables(db);

                var hdCollection = DriveUtilities.ProcessDriveList(db);

                var start = DateTime.Now;

                List<string> arrHeaders = DriveUtilities.GetFileAttributeList(db);

                var directory = new DirectoryInfo(filePath);

                var driveLetter = directory.FullName.Substring(0, 1);
                //TODO line it up with the size or the serial number since we will have removable drives.
                var drive = hdCollection.FirstOrDefault(letter => letter.DriveLetter.Equals(driveLetter, StringComparison.OrdinalIgnoreCase));

                if (directory.Exists) {
                    ProcessFolder(db, drive, arrHeaders, directory);
                }

                //just in case something blew up and it is not committed.
                if (db.IsInTransaction) {
                    db.Commit();
                }

                db.Close();
            }
        }
コード例 #12
0
 public void Update(Account currentAccount)
 {
     using (var connection = new SQLiteConnection(_dbPath))
     {
         connection.Update(currentAccount);
     }
 }
コード例 #13
0
 public void Initialize()
 {
     using (var connection = new SQLiteConnection(_dbPath))
     {
         connection.CreateTable<Account>();
     }
 }
コード例 #14
0
 public List<Account> GetAccounts()
 {
     using (var connection = new SQLiteConnection(_dbPath))
     {
         return connection.Table<Account>().ToList();
     }
 }
コード例 #15
0
ファイル: SQLContext.cs プロジェクト: hputtick/ImageProcessor
        /// <summary>
        /// Creates the database if it doesn't already exist.
        /// </summary>
        internal static void CreateDatabase()
        {
            try
            {
                if (!File.Exists(IndexLocation))
                {
                    string absolutePath = HostingEnvironment.MapPath(VirtualCachePath);

                    if (absolutePath != null)
                    {
                        DirectoryInfo directoryInfo = new DirectoryInfo(absolutePath);

                        if (!directoryInfo.Exists)
                        {
                            // Create the directory.
                            Directory.CreateDirectory(absolutePath);
                        }
                    }

                    using (SQLiteConnection connection = new SQLiteConnection(IndexLocation))
                    {
                        connection.CreateTable<CachedImage>();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #16
0
ファイル: BRemind.cs プロジェクト: tienbui123/Mobile-VS2
		public static void SaveLTRemind(SQLiteConnection connection,LTRemindItem item)
		{
			DataProvider dtb = new DataProvider (connection);
			if (dtb.GetLTRemind (item.MaMH, item.NamHoc, item.HocKy) == null) {
				dtb.AddRemindLT (item);
			}
		}
コード例 #17
0
ファイル: scheda.cs プロジェクト: frungillo/vegetha
 public static void Create()
 {
     Console.WriteLine ("Creo Database...");
     string dbPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "cust.db");
     var db = new SQLiteConnection (dbPath);
     db.CreateTable<schede> ();
 }
コード例 #18
0
ファイル: BRemind.cs プロジェクト: tienbui123/Mobile-VS2
		public static void SaveLHRemind(SQLiteConnection connection,LHRemindItem item)
		{
			DataProvider dtb = new DataProvider (connection);
			if (dtb.GetLHRemind (item.IDLH,item.Date) == null) {
				dtb.AddRemindLH (item);
			}
		}
コード例 #19
0
ファイル: MainModel.cs プロジェクト: vmendi/ListenAndRepeat
        public MainModel()
        {
            // This forces the instantiation
            mDictionarySearcher = ServiceContainer.Resolve<SearchModel> ();
            mSuggestionModel = ServiceContainer.Resolve<SuggestionModel> ();
            mPlaySoundModel = ServiceContainer.Resolve<PlaySoundModel> ();

            mDictionarySearcher.SearchCompleted += OnSearchCompleted;

            var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            mDatabasePath = Path.Combine(documentsPath, "..", "Library", "db_sqlite-net.db");

            bool isFirstLoad = false;

            using (var conn = new SQLite.SQLiteConnection(mDatabasePath))
            {
                // https://github.com/praeclarum/sqlite-net/wiki
                // In general, it will execute an automatic migration
                conn.CreateTable<WordModel>();
                conn.CreateTable<WaveModel>();

                InitialRefresh(conn);
                LoadNextWord(conn);
                RefreshWordsList(conn);

                isFirstLoad = conn.Table<WordModel>().Count() == 0;
            }

            if (isFirstLoad)
            {
                AddWord("Thanks");
                AddWord("For");
                AddWord("Downloading");
            }
        }
コード例 #20
0
        public void Connect()
        {
            sqlConnection = new SQLiteConnection(DB_PATH);

            if (!ApplicationData.Current.LocalSettings.Values.ContainsKey(DB_VERSION_KEY))
            {
                ApplicationData.Current.LocalSettings.Values.Add(DB_VERSION_KEY, 0);
            }

            int currentDatabaseVersion = DebugHelper.CastAndAssert<int>(ApplicationData.Current.LocalSettings.Values[DB_VERSION_KEY]);

            if (currentDatabaseVersion < 1)
            {
                sqlConnection.CreateTable<ArtistTable>();
                sqlConnection.CreateTable<AlbumTable>();
                sqlConnection.CreateTable<SongTable>();
                sqlConnection.CreateTable<PlayQueueEntryTable>();
                sqlConnection.CreateTable<PlaylistTable>();
                sqlConnection.CreateTable<PlaylistEntryTable>();
                sqlConnection.CreateTable<HistoryTable>();
                sqlConnection.CreateTable<MixTable>();
                sqlConnection.CreateTable<MixEntryTable>();
            }

            if (currentDatabaseVersion < DB_VERSION)
            {
                ApplicationData.Current.LocalSettings.Values[DB_VERSION_KEY] = DB_VERSION;
            }
        }
コード例 #21
0
ファイル: BUser.cs プロジェクト: tienbui123/Mobile-VS2
		public static bool IsLogined(SQLiteConnection connection)
		{
			DataProvider dtb = new DataProvider (connection);
			if (dtb.GetMainUser () != null)
				return true;
			return false;
		}
コード例 #22
0
		public Downloader ()
		{
			var personal = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
			var dbpath = Path.Combine (personal, "download.db");
			var db = new SQLiteConnection (
				dbpath, 
				SQLiteOpenFlags.ReadWrite 
				| SQLiteOpenFlags.Create 
				| SQLiteOpenFlags.FullMutex , 
				true) {
				#if DEBUG
				Trace = true
				#endif
			};

			int maxdownloads = 3;
			_bus = new InProcessBus ();
			_repository = new DownloadRepository (db);
			_manager = new DownloadManager (_bus, _repository, maxdownloads);
			_service = new NSUrlSessionManager (_bus, maxdownloads);
			_progress = new ProgressManager (_bus, _repository);
			_timer = new Timer (TimerCallback, null, 1000, 1000);
			_timer = new Timer (TimerCallback, null, 1000, 1000);

			_bus.Subscribe<DownloadError> (DownloadError_Received);
			_bus.Subscribe<TaskError> (TaskError_Received);
			_bus.Subscribe<QueueEmpty> (QueueEmpty_Received);
			_bus.Subscribe<GlobalProgress> (GlobalProgress_Received);
			_bus.Subscribe<NotifyFinish> (NotifyFinish_Received);

		}
コード例 #23
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (NavigationContext.QueryString.TryGetValue("BookISBN", out ISBN))
            {
                dbPath = Path.Combine(Path.Combine(ApplicationData.Current.LocalFolder.Path, "jadeface.sqlite"));
                dbConn = new SQLiteConnection(dbPath);
                SQLiteCommand command = dbConn.CreateCommand("select * from booklistitem where isbn = '" + ISBN + "'");
                List<BookListItem> books = command.ExecuteQuery<BookListItem>();
                if (books.Count == 1)
                {
                    book = books.First();
                    //BookDetailGrid.DataContext = book;
                }

            }
            else
            {
                MessageBox.Show("详细信息页面加载出错!");
                NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
            }

            bookService = BookService.getInstance();
            showNoteList();
        }
コード例 #24
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            db = new SQLiteConnection("naturapp.db");

            if (NavigationContext.QueryString.ContainsKey("idCliente"))
                idCliente = NavigationContext.QueryString["idCliente"].ToString();

            int id = Convert.ToInt32(idCliente.ToString());

            var count = (from x in db.Table<tablaPedidos>() where x.idCliente == id select x.idCliente).Count();
            if (count > 0)
            {
                pedidos = db.Query<tablaPedidos>("SELECT * from tablaPedidos where idCliente like " + idCliente);

                arrPedidos = new ObservableCollection<PedidoConsulta>();
                foreach (var pedido in pedidos)
                {
                    arrPedidos.Add(new PedidoConsulta(pedido.producto,pedido.fechaPedido.ToShortDateString(),pedido.totalPedido.ToString()));
                }

                listPedidos.ItemsSource = arrPedidos;
            }
            else
            {
                MessageBox.Show("No hay pedidos generados para este cliente");
            }

            base.OnNavigatedTo(e);
        }
コード例 #25
0
 public void Drop()
 {
     using (var db = new SQLiteConnection(DbPath))
     {
         db.DropTable<TracklistItem>();
     }
 }
コード例 #26
0
 public void CreateLogEntry(LogEntry myEntrie)
 {
     using (var dbConn = new SQLiteConnection(App.DB_PATH))
     {
         dbConn.Insert(myEntrie);
     }
 }
コード例 #27
0
		//constructor
		private BookKeeperManager ()
		{
			string dbPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal);
			db = new SQLiteConnection ( dbPath + @"\database.db");

			try{
				db.Table<Entry>().Count();
			} catch(SQLiteException e){
				db.CreateTable<Entry> ();
			}

			try{
				db.Table<TaxRate>().Count();
			} catch(SQLiteException e){
				db.CreateTable<TaxRate> ();
				db.Insert (new TaxRate(){ Tax = 6.0});
				db.Insert (new TaxRate(){ Tax = 12.0});
				db.Insert (new TaxRate(){ Tax = 25.0});
			}

			try{
				db.Table<Account>().Count();
			} catch(SQLiteException e){
				db.CreateTable<Account> ();
				db.Insert (new Account(){ Name = "Försäljning inom Sverige", Number = 3000});
				db.Insert (new Account(){ Name = "Fakturerade frakter", Number = 3520});
				db.Insert (new Account(){ Name = "Försäljning av övrigt material", Number = 3619});
				db.Insert (new Account(){ Name = "Lokalhyra", Number = 5010});
				db.Insert (new Account(){ Name = "Programvaror", Number = 5420});
				db.Insert (new Account(){ Name = "Energikostnader", Number = 5300});
				db.Insert (new Account(){ Name = "Kassa", Number = 1910});
				db.Insert (new Account(){ Name = "PlusGiro", Number = 1920});
				db.Insert (new Account(){ Name = "Bankcertifikat", Number = 1950});
			}
		}
コード例 #28
0
 public void UpdateLogEntry(LogEntry selectedLogEntry)
 {
     using (var dbConn = new SQLiteConnection(App.DB_PATH))
     {
         dbConn.Update(selectedLogEntry);
     }
 }
コード例 #29
0
ファイル: LineStore.cs プロジェクト: yingfangdu/BNR
        public static void addCompletedCircle(Circle circle)
        {
            completeCircles.Add(circle);

            string dbPath = GetDBPath();
            SQLiteConnection db;
            db = new SQLiteConnection(dbPath);
            db.Insert(circle);

            var result = db.Query<Line>("SELECT * FROM Lines");
            foreach (Line l in result) {
                Console.WriteLine("Line DB: bx {0}, by {1}, ex {2}, ey {3}", l.begin.X, l.begin.Y, l.end.X, l.end.Y);
            }
            var result2 = db.Query<Circle>("SELECT * FROM Circles");
            foreach (Circle c in result2) {
                Console.WriteLine("Circle DB: cx {0}, cy {1}, p2x {2}, p2yy {3}", c.center.X, c.center.Y, c.point2.X, c.point2.Y);
            }

            db.Close();
            db = null;

            foreach (Line l in completeLines) {
                Console.WriteLine("Line CL: bx {0}, by {1}, ex {2}, ey {3}", l.begin.X, l.begin.Y, l.end.X, l.end.Y);
            }
            foreach (Circle c in completeCircles) {
                Console.WriteLine("Circle CC: cx {0}, cy {1}, p2x {2}, p2yy {3}", c.center.X, c.center.Y, c.point2.X, c.point2.Y);
            }
        }
コード例 #30
0
 public void Clear()
 {
     using (var connection = new SQLiteConnection(_dbPath))
     {
         connection.Query<Account>("DELETE * FROM ACCOUNT");
     }
 }