报表参数添加

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

posted @ 2018-06-16 14:11  蒲公英的约定&h  阅读(142)  评论(0编辑  收藏  举报