我在我的应用程序中生成了一个摘要报告。我正在使用mvc4。我使用Crystal报告生成了该报告。现在我有一个观点。在该视图中,我有两个名为FromDate
,ToDate
的字段。如果我选择FromDate
和ToDate
并点击确定按钮,则会根据这两个日期条件生成报告并显示报告。
我的报告
现在运作良好。我想要的是将FromDate
和Todate
保留在我在下面的报告中标记的位置。我怎么做?如何将日期传递给水晶报告?有任何帮助来解决这个问题吗?
我的控制器代码
public ActionResult GetOrderComplaintsValues(VisitorsViewModel vvm)
{
var ObjFromDate = Convert.ToDateTime(vvm.FromDate);
var ObjTodate = Convert.ToDateTime(vvm.ToDate);
var objpovisitID = vvm.POVisitID;
var objText = "Order";
if(objpovisitID == new Guid("DB7FE0EA-8444-4F6B-9961-4F54E7C4F0FD"))
{
var PurchaseOrderCount = (from v in db.View_VisitorsForm where v.POVisitID == objpovisitID && v.VisitingDate >= ObjFromDate && v.VisitingDate <= ObjTodate select v).ToList();
}
SqlConnection con = new SqlConnection(@"Data Source=192.168.0.73\SQLEXPRESS,14330;Initial Catalog=WafeERP_NEW;User ID=sa;Password=wafewin;");
DataTable dt = new DataTable();
try
{
con.Open();
if (objpovisitID == new Guid("DB7FE0EA-8444-4F6B-9961-4F54E7C4F0FD"))
{
SqlCommand cmd = new SqlCommand("Select * from View_VisitorsForm where POVisitID= '" + objpovisitID + "' and VisitingDate >='" + ObjFromDate + "'and VisitingDate <= '" + ObjTodate + "'", con);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
adp.Fill(dt);
}
else if (objpovisitID == new Guid("283462E7-665D-44D1-A469-B8AF2D913B8B"))
{
SqlCommand cmd = new SqlCommand("Select * from View_VisitorsForm where POVisitID= '" + objpovisitID + "' and VisitingDate >='" + ObjFromDate + "'and VisitingDate <= '" + ObjTodate + "'", con);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
adp.Fill(dt);
}
else if (objpovisitID == new Guid("00000000-0000-0000-0000-000000000000"))
{
SqlCommand cmd = new SqlCommand("Select * from View_VisitorsForm where VisitingDate >='" + ObjFromDate + "'and VisitingDate <= '" + ObjTodate + "'", con);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
adp.Fill(dt);
}
}
catch (Exception ex)
{
throw;
}
ReportClass rc = new ReportClass();
rc.FileName = Server.MapPath("/Reports/rpt_OrderComplaintsSummaryReport.rpt");
rc.Load();
rc.SetDataSource(dt);
Stream stream = rc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
return File(stream, "application/pdf");
}