报表参数添加
Posted jasonch123
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了报表参数添加相关的知识,希望对你有一定的参考价值。
string sqlWhere = string.Empty;
string sqlWhere2 = string.Empty;
if (!string.IsNullOrEmpty(textBox2.Text))
{
sqlWhere += " and pick_doc like ‘%" + textBox2.Text + "%‘";
}
if (!string.IsNullOrEmpty(textBox4.Text))
{
sqlWhere2 += " and material_name like ‘%" + textBox4.Text + "%‘";
}
sqlWhere += "and date_delivery>=‘" + Convert.ToDateTime(dateTimePicker1.Text).ToString("yyyy-MM-dd")
+ "‘ and date_delivery<=‘" + Convert.ToDateTime(dateTimePicker2.Text).ToString("yyyy-MM-dd") + "‘";
#region QQS020M
string sql = @"select id,pick_doc,date_delivery,status,memo,org from QQS020M where 1=1" + sqlWhere;
this.dt1 = Program.DB.GetDataTable(sql);
try
{
this.dataSet检货.Tables[1].Rows.Clear();
for (int i = 0; i < dt1.Rows.Count; i++)
{
DataRow DR = dataSet检货.Tables[1].NewRow();
DataRow dr = dt1.Rows[i];
DR["表ID"] = (i + 1);
DR["检货计划单"] = dr["pick_doc"];
DR["检货日期"] = dr["date_delivery"];
DR["状态"] = dr["status"];
DR["备注"] = dr["memo"];
DR["组织"] = dr["org"];
dataSet检货.Tables[1].Rows.Add(DR);
}
ReportParameter[] ps1 = new ReportParameter[3];// ("条件", ReturnData[0]);
ps1[0] = new ReportParameter("总行数", dt1.Rows.Count.ToString());
ps1[1] = new ReportParameter("制表人", Program.User);
ps1[2] = new ReportParameter("制表日期",DateTime.Now.ToString("yyyy-MM-dd"));
this.reportViewer1.LocalReport.SetParameters(ps1);
this.reportViewer1.RefreshReport();
}
catch (Exception)
{
throw;
}
#endregion
以上是关于报表参数添加的主要内容,如果未能解决你的问题,请参考以下文章