没有用户界面 - 是否可行? [英] Without A User Interface - Is It Feasible?

查看:54
本文介绍了没有用户界面 - 是否可行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

推荐答案

只要您不必从您的用户那里获得任何参数,这肯定是可能的。您将创建绕过报表查看器的代码。这是一个小样本,但Crystal和Microsoft的知识库中有很多文章。在我的示例中,我确实有用户提供的参数,但在您的情况下,您将调整它以便不提供参数,只需运行存储过程并将报表文档数据源设置为该存储过程。祝你好运!!

It is definately possible as long as you don't have to get any paramaters from your user.  You would create code that would bypass the Report Viewer.  This is a small sample but there are a lot of articles in the knowledge base of Crystal as well as Microsoft.  In my example I do have parameters that the user supplies, but in your case you would tweak it so you don't supply parameters, just run the stored procedure and set the report document datasource to that stored procedure.  Good luck!!


using CrystalDecisions.Shared;

private void btnExport_Click( < font color ="#0000ff"size = 2> object sender,System.EventArgs e)

private void btnExport_Click(object sender, System.EventArgs e)

{

string exportFileName =" exportedReport.pdf";

string exportFileName="exportedReport.pdf";

string exportPath = " \\Crystal" +"\\" + exportFileName;

string exportPath="\\Crystal" + "\\" + exportFileName;

string fileName =(" rptBankTotals.rpt");

string fileName=("rptBankTotals.rpt");

string filePath = String.Concat(@" \\flsouth2 \DAP_Initial_Deploy\Reports" +" \\" + fileName);

(在我的情况下我有参数)

(In my case I had parameters)

System.Data.SqlClient.SqlParameter [] par = new System.Data.SqlClient.SqlParameter [2];

System.Data.SqlClient.SqlParameter[] par = new System.Data.SqlClient.SqlParameter[2];

< font color ="#0000ff"size = 2> int size = 0;

int size = 0;

par [size] = new System.Data.SqlClient.SqlParameter(" EndingDate",SqlDbType.DateTime);

par[size] = new System.Data.SqlClient.SqlParameter("EndingDate", SqlDbType.DateTime);

par [ size] .Value = this .udtDate.Value;

par[size].Value = this.udtDate.Value;

size ++;

par [size] = new System.Data.SqlClient.SqlParameter(" FinancialAccountId",SqlDbType.Int);

par[size] = new System.Data.SqlClient.SqlParameter("FinancialAccountId", SqlDbType.Int);

par [size] .Value = Convert.ToInt32(ucbSelectBank.Value);

par[size].Value =Convert.ToInt32(ucbSelectBank.Value);

size ++;

DataSet ds = objReports.RunReport(" usp_rptBankTotals",par);

DataSet ds = objReports.RunReport("usp_rptBankTotals", par);

ReportDocument crReportDocument = new ReportDocument() ;

ReportDocument crReportDocument=new ReportDocument();

crReportDocument.Load(filePath);

crReportDocument.Load (filePath);

crReportDocument.SetDataSource(ds);

crReportDocument.SetDataSource(ds);

crReportDocument.ExportToDisk(ExportFormatType.PortableDocFormat,exportPath);

crReportDocument.ExportToDisk(ExportFormatType.PortableDocFormat,exportPath);

}

(这是我的数据层)

public DataSet RunReport( string proc,System.Data.SqlClient.SqlParameter [] p)

public DataSet RunReport(string proc,System.Data.SqlClient.SqlParameter[] p)

{

ArrayList parms = new ArrayList(p);

ArrayList parms = new ArrayList(p);

object [] pValues = new 对象 [parms.Count];

object[] pValues = new object[parms.Count];

for int i = 0; i< = parms.Count - 1; i ++)

for (int i = 0; i <= parms.Count - 1; i++)

{

尝试

try

{

pValues =((System.Data.SqlClient.SqlParameter)(parms ))。值;

pValues = ((System.Data.SqlClient.SqlParameter)(parms)).Value;

}

catch

catch

{

}

}

数据库db = DatabaseFactory.CreateDatabase();

Database db = DatabaseFactory.CreateDatabase();

试试

try

{

DBCommandWrapper cmd = db.GetStoredProcCommandWrapper(proc,pValues);

DBCommandWrapper cmd = db.GetStoredProcCommandWrapper(proc, pValues);

DataSet returnDS = db.ExecuteDataSet(cmd);

DataSet returnDS = db.ExecuteDataSet(cmd);

return returnDS;

return returnDS;

}

catch

catch

{

return null ;

return null;

}


这篇关于没有用户界面 - 是否可行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆