private void pmPrintData() { string strErrorMsg = ""; string strSQLText = ""; string strJoinTable = ""; string strJoinFld = ""; WS.Data.Agents.cDBMSAgent objSQLHelper = new WS.Data.Agents.cDBMSAgent(App.ConnectionString, App.DatabaseReside); string strFld = " APPLOGIN.CLOGIN, APPROLE.CCODE as QCPOST, APPROLE.CNAME as QNPOST "; strFld += " ,EMSECT.CCODE as QCSECT , EMSECT.CNAME as QNSECT "; string strSQLExec = "select " + strFld + " from APPAUTHDET "; strSQLExec += " left join APPLOGIN on APPLOGIN.CROWID = APPAUTHDET.CAPPLOGIN "; strSQLExec += " left join APPEMPL on APPEMPL.CRCODE = APPLOGIN.CRCODE "; strSQLExec += " left join APPEMROLE on APPEMROLE.CEMPL = APPEMPL.CROWID "; strSQLExec += " left join APPROLE on APPROLE.CROWID = APPEMROLE.CAPPROLE "; strSQLExec += " left join EMSECT on EMSECT.CROWID = APPAUTHDET.CSECT "; strSQLExec += " where APPAUTHDET.CCORP = ? and APPAUTHDET.CTYPE = ? "; strSQLExec += " order by APPLOGIN.CLOGIN, EMSECT.CCODE "; Report.LocalDataSet.DTSLIST01 dtsPreviewReport = new Report.LocalDataSet.DTSLIST01(); objSQLHelper.SetPara(new object[] { App.ActiveCorp.RowID, "S" }); objSQLHelper.SQLExec(ref this.dtsDataEnv, "QList", "BGTRANHD", strSQLExec, ref strErrorMsg); foreach (DataRow dtrList in this.dtsDataEnv.Tables["QList"].Rows) { DataRow dtrPreview = dtsPreviewReport.XRLSTAUTHDET.NewRow(); dtrPreview["Login"] = dtrList["cLogin"].ToString(); dtrPreview["QcPost"] = dtrList["QcPost"].ToString(); dtrPreview["QnPost"] = dtrList["QnPost"].ToString(); dtrPreview["QcSect"] = dtrList["QcSect"].ToString(); dtrPreview["QnSect"] = dtrList["QnSect"].ToString(); dtrPreview["cAccess"] = "Y"; dtsPreviewReport.XRLSTAUTHDET.Rows.Add(dtrPreview); } if (dtsPreviewReport.XRLSTAUTHDET.Rows.Count != 0) { this.pmPreviewReport(dtsPreviewReport); } else { MessageBox.Show(this, "ไม่มีข้อมูล", "Application confirm message", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void pmPrintData() { string strErrorMsg = ""; string strSQLText = ""; string strJoinTable = ""; string strJoinFld = ""; WS.Data.Agents.cDBMSAgent objSQLHelper = new WS.Data.Agents.cDBMSAgent(App.ConnectionString, App.DatabaseReside); if (this.mstrTableName == MapTable.Table.EMCorp || this.mstrTableName == "APPLOGIN") { objSQLHelper.SetPara(new object[] { this.txtBegQcProj1.Text.TrimEnd(), this.txtEndQcProj1.Text.TrimEnd() }); if (this.mstrTableName == "APPLOGIN") { strSQLText = "select * from " + this.mstrTableName + " where CLOGIN between ? and ? "; } else { strSQLText = "select * from " + this.mstrTableName + " where CCODE between ? and ? "; } } else { switch (this.mstrTableName) { case "EMSECT": strJoinTable = "EMDEPT"; strJoinFld = "CDEPT"; break; case "EMJOB": strJoinTable = "EMPROJ"; strJoinFld = "CPROJ"; break; case "BGCHARTHD": strJoinTable = "BGTYPE"; strJoinFld = "CBGTYPE"; break; } objSQLHelper.SetPara(new object[] { App.ActiveCorp.RowID, this.txtBegQcProj1.Text.TrimEnd(), this.txtEndQcProj1.Text.TrimEnd() }); string strFld = "MASTER.*"; if (strJoinTable != string.Empty) { strFld += ", J1.CCODE as QCPR01, J1.CNAME as QNPR01"; } strSQLText = " select " + strFld + " from " + this.mstrTableName + " MASTER "; if (strJoinTable != string.Empty) { strSQLText += " left join " + strJoinTable + " J1 on J1.CROWID = MASTER." + strJoinFld; } strSQLText += " where MASTER." + this.mstrPrefixFld + " = ? and MASTER." + this.mstrSort + " between ? and ? order by MASTER." + this.mstrSort; } Report.LocalDataSet.DTSLIST01 dtsPreviewReport = new Report.LocalDataSet.DTSLIST01(); objSQLHelper.SQLExec(ref this.dtsDataEnv, "QList", this.mstrTableName, strSQLText, ref strErrorMsg); foreach (DataRow dtrProj in this.dtsDataEnv.Tables["QList"].Rows) { DataRow dtrPreview = dtsPreviewReport.XRLIST01.NewRow(); switch (this.mstrTableName) { case "APPLOGIN": dtrPreview["cCode"] = dtrProj["cRCode"].ToString().TrimEnd(); dtrPreview["cName"] = dtrProj["cLogin"].ToString().TrimEnd(); break; case "APPEMPL": dtrPreview["cCode"] = dtrProj["cCode"].ToString().TrimEnd(); dtrPreview["cName"] = dtrProj["cName"].ToString().TrimEnd(); dtrPreview["cPRCode1"] = dtrProj["cRCode"].ToString().TrimEnd(); break; default: dtrPreview["cCode"] = dtrProj["cCode"].ToString().TrimEnd(); dtrPreview["cName"] = dtrProj["cName"].ToString().TrimEnd(); break; } switch (this.mstrTableName) { case "EMJOB": case "EMPROJ": case "BGCHARTHD": dtrPreview["cType"] = dtrProj["cType"].ToString().TrimEnd(); break; } if (strJoinTable != string.Empty) { dtrPreview["cPRCode1"] = dtrProj["QCPR01"].ToString().TrimEnd(); dtrPreview["cPRName1"] = dtrProj["QNPR01"].ToString().TrimEnd(); } dtsPreviewReport.XRLIST01.Rows.Add(dtrPreview); } if (dtsPreviewReport.XRLIST01.Rows.Count != 0) { this.pmPreviewReport(dtsPreviewReport); } else { MessageBox.Show(this, "ไม่มีข้อมูล", "Application confirm message", MessageBoxButtons.OK, MessageBoxIcon.Information); } }