private async void InitializeDB() { ErrorText = "Установка связи с БД..."; await Task.Run(() => { SQLDb = new AgencySQLDb(); if (DBPath != string.Empty) DBConnected = SQLDb.TryOpen(DBPath); else DBConnected = SQLDb.TryConnect(); }); if (!DBConnected) { ErrorText = "База данных не найдена или не распознана, выберите расположение базы"; while (DBConnected == false) if (dialogService.OpenFileDialog()) { DBConnected = SQLDb.TryOpen(dialogService.FilePath); windowFactory.SetDBPath(dialogService.FilePath); } else { windowFactory.CloseApp(); break; } } if (DBConnected) { ErrorText = "Загрузка данных..."; UserData = SQLDb.GetLoginData(); UserData.RowChanged += UserData_RowChanged; Login = "******"; Password = "******"; ErrorText = null; } }
private async void UserData_RowChanged(object sender, DataRowChangeEventArgs e) { if (SQLDb.HaveEntry((int)e.Row["Id"])) { SQLDb.UpdateLoginTable(e.Row); await Task.Delay(500); UserData = SQLDb.GetLoginData(); UserData.RowChanged += UserData_RowChanged; } }
public SQLDb GetSQLDbObj() { var obj = new SQLDb(ConnStr); return(obj); }