private void MainFrame_Load(object sender, EventArgs e) { SQLitekurs.SQLite db = new SQLitekurs.SQLite(); if (!File.Exists(@"C:\BD\RealtorEstateAgancy.sqlite")) { SQLiteConnection.CreateFile(@"C:\BD\RealtorEstateAgancy.sqlite"); db.Connect(@"C:\BD\RealtorEstateAgancy.sqlite"); db.Create(); //SQLiteConnection connection = new SQLiteConnection(@"Data Source=C:\BD\RealtorEstateAgancy.sqlite;Version=3"); //SQLiteCommand command; //command= new SQLiteCommand("create table Realtor(id integer primary key autoincrement, fio text, login text, password text, telephoneNumber text);", connection); //connection.Open(); //command.ExecuteNonQuery(); //command = new SQLiteCommand("create table Customer(id integer primary key autoincrement, fio text, email text, telephoneNumber text);", connection); //command.ExecuteNonQuery(); //command = new SQLiteCommand("create table EstateObject(id INTEGER PRIMARY KEY AUTOINCREMENT, avitoId text, dealType text, price text, locality text," + // " address text, area text, roomNumber text, floor text, maxFloor text, material text, seller text, description text);", connection); //command.ExecuteNonQuery(); //command = new SQLiteCommand("create table Request(id integer primary key autoincrement, customerID references Customer(id)," + // " date text, dealType text, estateObjectType text, material text, lPrice text, uPrice text, locality text, lArea real, uArea real" + // " roomNumber integer, floor integer, maxFloor integer, suggestion text, status text);", connection); //command.ExecuteNonQuery(); //command = new SQLiteCommand("create table Agreement(id integer primary key autoincrement, date text, estateObjectId references estateObject(id)," + // " realtorId references Realtor(id), requestId references Request(id));", connection); //command.ExecuteNonQuery(); //connection.Close(); } }
private void DataBase_Load(object sender, EventArgs e) { string path = @"C:\BD\RealtorEstateAgancy.sqlite"; db.Connect(@"C:\BD\RealtorEstateAgancy.sqlite"); if (!File.Exists(path)) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.InitialDirectory = "C:\\"; fileDialog.Filter = "SQLite files (*.sqlite)|*.sqlite|All files (*.*)|*.*"; fileDialog.FilterIndex = 1; fileDialog.RestoreDirectory = true; fileDialog.CheckFileExists = true; fileDialog.Title = "Выберите файл с БД"; path = fileDialog.DereferenceLinks + fileDialog.FileName; if (fileDialog.ShowDialog() == DialogResult.OK) { db.Connect(path); } } UpdateDataGrid(); }