public void CreateDatabase() { if (System.IO.File.Exists(FilePath + "\\" + Alias + ".db")) { MessageBox.Show(Properties.Resources.Txt_DBExist); Alias = ""; IsNameFocused = false; IsNameFocused = true; return; } bool result = GlobalData.CreateInstance().dbHelper.CreateDBFile(Alias, FilePath); if (result == false) { globalData.mainWindowViewModel.ShowStatusInfo(Properties.Resources.Txt_CreateDBFault); } else { globalData.mainWindowViewModel.ShowStatusInfo(Properties.Resources.Txt_CreateDBSuccess); } UpdateDBConfig(FilePath, Alias, Alias); globalData.mainWindowViewModel.RefreshDatabaseList(); CreateDialogResult = true; }
public AttatchDatabase() { InitializeComponent(); context = new AttatchDatabaseViewModel(); GlobalData.CreateInstance().attatchDatabaseViewModel = context; this.DataContext = context; }
public CreateDatabase() { InitializeComponent(); context = new CreateDatabaseViewModel(); this.DataContext = context; GlobalData.CreateInstance().createDatabaseViewModel = context; }
public MainWindow() { InitializeComponent(); InitializeCommands(); mainDataContext = new MainWindowViewModel(); this.DataContext = mainDataContext; GlobalData.CreateInstance().mainWindowViewModel = mainDataContext; }
public void UpdateDBConfig(string filePath, string name, string description) { try { globalData.xmlHelper.OpenXml(globalData.ConfigFilePath); globalData.xmlHelper.GetDocument().Root.Element("LocalDBList").Add(new XElement( "Item", new XElement("FilePath", filePath + "\\" + name + ".db"), new XElement("DisplayName", name), new XElement("Description", description) )); globalData.xmlHelper.Save(); } catch (Exception ex) { GlobalData.CreateInstance().log.Error(ex.Message); } }
public MainWindowViewModel() { IsCreateDialogShow = false; globalData = GlobalData.CreateInstance(); ShowCreateDatabaseDialog = new DelegateCommand(ShowCreateDialog); ShowAttatchDatabaseDialog = new DelegateCommand(ShowAttatchDialog); SelectDBItemCommand = new DelegateCommand <RoutedEventArgs>(SelectDBFunc); OpenDatabaseCommand = new DelegateCommand(OpenDatabase, () => { return(SelectedDBItem != null && SelectedDBItem.OpenState == false && SelectedDBItem.Children == null); }); ExecuteQueryCommand = new DelegateCommand(ExecuteQuery, () => { return(!string.IsNullOrEmpty(SQLStr)); }); FetchSQLStrCommand = new DelegateCommand <RoutedEventArgs>(FetchSQLStr); DeleteDBCommand = new DelegateCommand(DeleteDatabase, () => { return(SelectedDBItem != null && SelectedDBItem.Children == null); }); ExitProgramCommand = new DelegateCommand(ExitProgram); RefreshDatabaseList(); ShowStatusInfo(Properties.Resources.Txt_Status_Ready); }