private bool TestConnection(string inDBType) { if (inDBType == "TXT") { return(true); } if (inDBType == "FOXPRO") { return(EmedOdbc.TestConnection(this.GetConnStr(inDBType))); } return(EmedDB.TestConnection(this.GetConnStr(inDBType))); }
private void btnDataView_Click(object sender, EventArgs e) { DataSet set1 = null; if (Config.Intance().CurrentCfgType == "1") { if (Config.Intance().CurrentDBType == "TXT") { set1 = uncTxt.getDataSet(Config.Intance().CurrentTxtTemplet); } else if (Config.Intance().CurrentDBType == "FOXPRO") { set1 = EmedOdbc.getDataSet(this.rtbSql.Text.Trim().Replace(":StoreOutDate", "2002-01-01"), Config.Intance().CurrentDBConStr); } else { set1 = EmedDB.getDataSet(this.rtbSql.Text.Trim().Replace(":StoreOutDate", "2002-01-01"), Config.Intance().CurrentDBConStr); } } else { string text1 = "select * from " + Config.Intance().EleDestination.SelectSingleNode("DestTable").Attributes["TableName"].Value; if (Config.Intance().CurrentDBType == "FOXPRO") { set1 = EmedOdbc.getDataSet(text1, Config.Intance().CurrentDBConStr); } else { set1 = EmedDB.getDataSet(text1, Config.Intance().CurrentDBConStr); } } FormDataView view1 = new FormDataView(set1); view1.ShowDialog(); view1.Dispose(); }
private void btnTest_Click(object sender, EventArgs e) { try { if (Config.Intance().CurrentCfgType == "1") { DataSet set1; if (Config.Intance().CurrentDBType == "TXT") { set1 = uncTxt.getDataSet(Config.Intance().CurrentTxtTemplet); } else if (Config.Intance().CurrentDBType == "FOXPRO") { set1 = EmedOdbc.getDataSet(this.rtbSql.Text.Trim().Replace(":StoreOutDate", "2002-01-01"), Config.Intance().CurrentDBConStr); } else { set1 = EmedDB.getDataSet(this.rtbSql.Text.Trim().Replace(":StoreOutDate", "2002-01-01"), Config.Intance().CurrentDBConStr); } if ((set1 != null) && EmedFunc.CheckTable(set1)) { if (this.IsFullSql(set1)) { XtraMessageBox.Show("Sql语句配置正确!", "提示"); this.btnSaveSql.Enabled = this.btnDataView.Enabled = true; } else { this.btnSaveSql.Enabled = this.btnDataView.Enabled = false; } } else { XtraMessageBox.Show("Sql语句配置错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.btnSaveSql.Enabled = this.btnDataView.Enabled = false; } } else { bool flag1; if (Config.Intance().CurrentDBType == "TXT") { uncTxt txt1 = new uncTxt(); flag1 = (txt1.BeginInsert(Config.Intance().CurrentTxtTemplet) && txt1.ExecInsert(this.CreateTestDataRow(), true)) && txt1.EndInsert(); } else if (Config.Intance().CurrentDBType == "FOXPRO") { flag1 = EmedOdbc.ExcuteSql(this.CreateTestInsertSql(this.rtbSql.Text.Trim().Replace(":StoreOutDate", "2002-01-01")), Config.Intance().CurrentDBConStr) && EmedOdbc.ExcuteSql(this.sqlDelete, Config.Intance().CurrentDBConStr); } else if (Config.Intance().CurrentDBType == "EXCEL") { flag1 = EmedDB.ExcuteSql(this.CreateTestInsertSql(this.rtbSql.Text.Trim().Replace(":StoreOutDate", "2002-01-01")), Config.Intance().CurrentDBConStr); } else if (Config.Intance().CurrentDBType == "ACCESS") { flag1 = EmedDB.ExcuteSql(this.CreateTestInsertSql(this.rtbSql.Text.Trim().Replace(":StoreOutDate", "2002-01-01")), Config.Intance().CurrentDBConStr) && EmedDB.ExcuteSql(this.sqlDelete, Config.Intance().CurrentDBConStr); } else { flag1 = EmedDB.ExcuteSql(this.CreateTestInsertSql(this.rtbSql.Text.Trim().Replace(":StoreOutDate", "2002-01-01")), Config.Intance().CurrentDBConStr) && EmedDB.ExcuteSql(this.sqlDelete, Config.Intance().CurrentDBConStr); } if (flag1) { XtraMessageBox.Show("Sql语句配置正确!", "提示"); this.btnSaveSql.Enabled = true; } else { XtraMessageBox.Show("Sql语句配置错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.btnSaveSql.Enabled = this.btnDataView.Enabled = false; } } } catch (Exception exception1) { XtraMessageBox.Show("Sql语句配置错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); ErrorLog.SaveLog("测试SQL", exception1); } }