Now that is working well. What I want is to keep FromDate
and Todate
in the place which I marked in the report above. How do I do that? How do I pass the dates to crystal report? Any help to resolve this issue?
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");
}