private void initialForm() { appConfig appconfig = appConfig.getDefaultConfig(); if (appconfig != null) { this.type = appconfig.dbType; } //DBType type = ConfigManager.GetCurrentDBType(); SQLConnConfig config = SQLConnConfig.getDefaultDBConfig(type); //type = config.dbType; if (type == DBType.sqlserver) { this.comboBox1.SelectedIndex = 0; } else if (type == DBType.sqlite) { this.comboBox1.SelectedIndex = 1; } //string connStr = ConfigManager.GetDBConnectString(type); if (config != null) { this.connectString = config.connectString; } this.txtConnString.Text = connectString; }
public static bool checkDBSetting() { if (staticClass.currentDbType == DBType.None) { appConfig appconfig = appConfig.getDefaultConfig(); if (appconfig != null) { staticClass.currentDbType = appconfig.dbType; SQLConnConfig config = SQLConnConfig.getDefaultDBConfig(staticClass.currentDbType); if (config != null) { staticClass.currentDBConnectString = config.connectString; } else { return(false); } } else { return(false); } } return(true); }
public static string rtConnection() { if (connectString == string.Empty) { appConfig appconfig = appConfig.getDefaultConfig(); if (appconfig != null) { SQLConnConfig config = null; config = SQLConnConfig.getDefaultDBConfig(appconfig.dbType); if (config != null) { connectString = config.connectString; } } } return(connectString); }
private void button2_Click(object sender, EventArgs e) { if (this.checkValidation() == false) { return; } appConfig appConfig = new appConfig(this.type); appConfig.saveConfig(appConfig); SQLConnConfig config = new SQLConnConfig(this.type, this.connectString); SQLConnConfig.saveConfig(config); staticClass.currentDbType = this.type; staticClass.currentDBConnectString = this.connectString; this.Close(); //initialForm(); //switch (this.comboBox1.SelectedIndex) //{ // case 0: // if (ConfigManager.SaveDBConnectString(DBType.sqlserver, this.txtConnString.Text)) // { // MessageBox.Show("保存成功!"); // } // else // { // MessageBox.Show("保存失败!"); // } // break; // case 1: // if (ConfigManager.SaveDBConnectString(DBType.sqlite, this.txtConnString.Text)) // { // MessageBox.Show("保存成功!"); // } // else // { // MessageBox.Show("保存失败!"); // } // break; //} }
public static appConfig getDefaultConfig() { appConfig config = null; //IObjectContainer db = Db4oFactory.OpenFile(appConfig.configFilePath); IObjectContainer db = staticClass.db; try { IList <appConfig> list = db.Query <appConfig>(typeof(appConfig)); if (list.Count > 0) { config = list[0]; } } finally { // db.Close(); } return(config); }
public static void saveConfig(appConfig config) { //IObjectContainer db = Db4oFactory.OpenFile(appConfig.configFilePath); IObjectContainer db = staticClass.db; try { IList <appConfig> list = db.Query <appConfig>(typeof(appConfig)); if (list.Count <= 0) { db.Store(config); } else { appConfig.copy(config, list[0]); db.Store(list[0]); } } finally { //db.Close(); } }
public static void copy(appConfig source, appConfig dest) { dest.dbType = source.dbType; }