private void btnQuery_Click(object sender, EventArgs e) { try { if (!CheckArgsIsOK()) { return; } if (_db == null) { _db = DBConnect.GetInstance();//创建数据库连接 } ConcatSQL cSql = new ConcatSQL(); cSql.ConcatSQLByUIControls(_ui);//根据界面条件生成相应的sql语句; if (dr == null) { dr = new DataReader(_ui, _db, dataGridViewDay, dataGridViewPeriod);//创建查询结果的识别语句,并把结果输出到gridview } _db.OpenConnection(); _db.Retrieval(cSql.Sql, dr.DataReaderImplementation);//执行查询 _db.CloseConnection(); } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }