4,820
社区成员
发帖
与我相关
我的任务
分享
TableLogOnInfo logOnInfo = new TableLogOnInfo();
ReportDocument oRpt = new ReportDocument();
string path1;
path1 = Application.StartupPath + ("\\fp.rpt");
/////////////////////////////////////////////
DataTable dt = new DataTable();
DataTable dt2 = new DataTable();
//把数据跳出来给fp
string sql = "select * from 发票表 where 发票代码=@D and 发票号码=@H";
OleDbCommand cmd = new OleDbCommand(sql);
cmd.Parameters.Add("@D",OleDbType.VarChar).Value=ID;
cmd.Parameters.Add("@H", OleDbType.VarChar).Value = SID;
dt = PageBase.Quick_SelectSQL(cmd);
//MessageBox.Show(dt.Rows.Count.ToString());
if (dt.Rows.Count < 1)
{
MessageBox.Show("数据库中没有记录,请先保存后在打印。");
this.Close();
return;
}
string id = dt.Rows[0]["ID"].ToString();
sql = "select * from 发票清单表 where SID=@id";
OleDbCommand cmd2 = new OleDbCommand(sql);
cmd2.Parameters.Add("@id", OleDbType.VarChar).Value = id;
dt2 = PageBase.Quick_SelectSQL(cmd2);
MessageBox.Show(dt.Rows.Count.ToString() + "/" + dt2.Rows.Count.ToString());
/////////////////////////////////////////////////////////
//MessageBox.Show(path1); return;
oRpt.Load(path1);
oRpt.SetDataSource(dt);
//oRpt.Subreports[0].SetDataSource(dt2);
//从web.config中获取logOnInfo参数信息
//获取ServerName
//logOnInfo.ConnectionInfo.ServerName = ".";
//logOnInfo.ConnectionInfo.DatabaseName = "bill";
//logOnInfo.ConnectionInfo.UserID = "admin";
//logOnInfo.ConnectionInfo.Password = "1";
//oRpt.Database.Tables[0].ApplyLogOnInfo(logOnInfo);
crystalReportViewer1.ReportSource = oRpt;
