public static void saveConfig(SQLConnConfig config) { IObjectContainer db = Db4oFactory.OpenFile(SQLConnConfig.configFilePath); try { IList <SQLConnConfig> list = db.Query <SQLConnConfig>(delegate(SQLConnConfig cf) { return(cf.dbType == config.dbType); } ); if (list.Count <= 0) { db.Store(config); } else { SQLConnConfig.copy(config, list[0]); db.Store(list[0]); } } finally { db.Close(); } }
void frmMain_Load(object sender, EventArgs e) { SQLConnConfig sqlc = SQLConnConfig.getDefaultDBConfig(DBType.sqlserver); if (sqlc != null) { staticClass.currentDBConnectString = sqlc.connectString; } }
void frmSysConfig_Load(object sender, EventArgs e) { appConfig ac = appConfig.getDefaultConfig(); this.txtPort.Text = ac.port.ToString(); this.txtInterval.Text = ac.interval.ToString(); int selectedIndex = 0; selectedIndex = this.cmbRfidDataFormat.Items.IndexOf(ac.dataFormat.ToString()); SQLConnConfig sqlc = SQLConnConfig.getDefaultDBConfig(DBType.sqlserver); if (sqlc != null) { this.txtConnString.Text = sqlc.connectString; } }
private void btnConnect_Click(object sender, EventArgs e) { if (this.checkConnectValidation() == false) { return; } if (SQLConnConfig.testConnection(DBType.sqlite, this.txtConnString.Text)) //if (SQLConnConfig.testConnection(DBType.sqlserver, this.txtConnString.Text)) { MessageBox.Show("连接测试成功!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("连接测试失败!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static SQLConnConfig getDefaultDBConfig(DBType type) { SQLConnConfig config = null; IObjectContainer db = Db4oFactory.OpenFile(SQLConnConfig.configFilePath); try { IList <SQLConnConfig> list = db.Query <SQLConnConfig>(delegate(SQLConnConfig cf) { return(cf.dbType == type); } ); if (list.Count > 0) { config = list[0]; } } finally { db.Close(); } return(config); }
private void button1_Click(object sender, EventArgs e) { if (this.checkConnectValidation() == false) { //return; } else { SQLConnConfig sqlc = new SQLConnConfig(DBType.sqlserver, this.txtConnString.Text); SQLConnConfig.saveConfig(sqlc); staticClass.currentDBConnectString = this.txtConnString.Text; } appConfig ac = new appConfig(); if (this.checkIntervalValidation() == false) { //return; } else { ac.interval = int.Parse(this.txtInterval.Text); } if (this.checkPortValidation() == false) { //return; } else { ac.port = int.Parse(this.txtPort.Text); } appConfig.saveConfig(ac); this.Close(); }
public static void copy(SQLConnConfig source, SQLConnConfig dest) { dest.configName = source.configName; dest.dbType = source.dbType; dest.connectString = source.connectString; }