Beispiel #1
0
        public void Load()
        {
            if (!File.Exists(sqLitePath))
            {
                string baseName = sqLitePath;

                try
                {
                    SQLiteConnection.CreateFile(baseName);
                }
                catch (Exception)
                {
                    if (!Directory.Exists("db"))
                    {
                        Directory.CreateDirectory("db");
                        SQLiteConnection.CreateFile(baseName);
                    }
                }

                using (SQLiteConnection connection = new SQLiteConnection())
                {
                    connection.ConnectionString = "Data Source = " + baseName;
                    connection.Open();

                    using (SQLiteCommand command = new SQLiteCommand(connection))
                    {
                        string departs =
                            @"CREATE TABLE [Departaments] (
                    [Id] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
                    [Department] TEXT NOT NULL
                    );";
                        string contacts = @"CREATE TABLE [Contacts] (

    [Id]    INTEGER NOT NULL,
	[D_no]  TEXT,
	[S_no]   TEXT,
	[Ad_soyad]    TEXT,
	[Tc] TEXT,
	 
 

    PRIMARY KEY([Id] AUTOINCREMENT)
);";
                        command.CommandText = departs + contacts;
                        command.CommandType = System.Data.CommandType.Text;
                        command.ExecuteNonQuery();
                    }
                    connection.Close();
                }
            }

            dataBase = new ApplicationContext();

            dataBase.Contacts.Load();

            dataBase.SaveChanges();

            Sync();

            UpdateContactsModel(contacts);
        }
Beispiel #2
0
        public void Update()
        {
            dataBase.SaveChanges();

            Sync();
        }