Actually the data is taken from two tables and in stored procedure it is inner joined with condition. My problem is that how can I filter dates and print ony data between these ranges??
controller part
public ActionResult ExportCustomers()
{
ReportDocument rd = new ReportDocument();
rd.Load(Path.Combine(Server.MapPath("~/CrystalReports/Report.rpt")));
rd.SetDataSource(db.ItemBookings.Select(p => new
{
name = p.CustID,
status = p.Status,
bookingTime = p.Bookingtime,
Post = p.TotalAmount,
}).ToList());
Response.Buffer = false;
Response.ClearContent();
Response.ClearHeaders();
Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "application/pdf", "CollectionHistory.pdf");
}
in view page stored procedure
CREATE procedure [dbo].[spItemBookingDateFilter]
@FomDate AS VARCHAR(20),
@ToDate AS VARCHAR(20)
AS
Begin
SELECT IB.ID, IB.CustID, IB.DeviceID, IB.Bookingtime, IB.RouteID, IB.IsCollected, IB.IsAllocated, IB.Status, IB.TotalAmount, IB.TotalWeight, AD.Id AS Expr1, AD.Name, AD.MobNo, AD.Location, AD.Address, AD.Post,
AD.PostalCode
FROM dbo.ItemBooking AS IB INNER JOIN
dbo.CustomerAddressDetail AS AD ON IB.AddressID = AD.Id
AND convert(VARCHAR(50),@FomDate,105) <= IB.BookingTime AND convert(VARCHAR(50),@ToDate,105) >= IB.BookingTime
end
GO
by giving a table it is just downloading as pdf file but how can I give stored procedure with parameter to filter date range and to print these data ??
somebody please guid me how to get to the correct result ??
athira kPosted Jun 3, 2017, 5:47 AM
Saineshwar BageriPosted Jun 3, 2017, 4:11 AM