0
votes

i am in between very complex situation. I am filling a report with one record only from store procedure which only requires one parameter and select record on basis of it e.g. @complaintCode. Now requirements has changed, it should load multiple records i.e. i have two dates textboxes which picks only complaint codes which falls between those dates e.g. 20 complaint codes, now my rdlc should display all records for all complaint codes that has been loaded into dataset.

To make my issue simple: 1. Enter 2 dates and click search, it loads many complaint codes between date range and put in dataset. 2. Now i WANT to fill dataset from store procedure which takes only one parameter i.e. complaint code and loading all records in rdlc report, how ?

Code:

protected void btnGenReport_Click(object sender, EventArgs e)
    {

        try
        {


            DateTime fromDate = DateTime.ParseExact(txtFromDate.Text, "dd/MMM/yyyy", null);
            DateTime toDate = DateTime.ParseExact(txtToDate.Text, "dd/MMM/yyyy", null);
            DataTable dt_temp = MyComplaints.SearchAllComplaintByDate(fromDate, toDate);

            ReportViewer1.ProcessingMode = ProcessingMode.Local;
            ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Reports/Report_Complaints24Hours_Sdpo.rdlc");
            string ComplaintCode = Convert.ToString(txtComplaintCode.Text);
            DataTable dt = ManageRecievedMessage.Report_Complaints24Hours_Sdpo(ComplaintCode);

            if (dt.Rows.Count <= 0)
            {
                HiddenFieldSetMessage.Value = "WrongDatesComb";
                HiddenFieldShowMessage.Value = "True";
                ReportViewer1.Visible = false;
            }
            else
            {
                ReportDataSource rpds = new ReportDataSource("DataSet1", dt);
                ReportViewer1.LocalReport.DataSources.Clear();
                ReportViewer1.LocalReport.DataSources.Add(rpds);
                ReportViewer1.Visible = true;
            }

        }
1

1 Answers

0
votes

Simple approach will be Make a store procedure which take four parameters like

 Create procedure searchComplaint @complaintId=null varchar(50),@startDate=null date,@endDate=null date,@queryType=null 
 AS Begin 
if(@queryType=='fetchFromID')
 Begin
 select * from record_Tbl where complaintId=@complaintId 
End    
if(@queryType=='fetchDateWise') 
Begin  
select * from record_Tbl where date between @startdate and @endDAte  
    End 

 END

Reason to choose the queryType parameter

Where you want to fetch data from the Only Complaint Id basis call the store procedure with @querytype value="fetchFromID" else @querytype value="fetchDateWise"

Then store procedure automatically run that query according to querytype as per if condition..and you will always get result.. So Only concept is this to run one query at a time from a store procedure.. Just pass other parameters as normal id,startdate,enddate which user has spplied Decider is only @queryType Parameter

So how to pass different @queryType parameter

USe to radio radio button for 1.Search by ID only 2. Search by date

IF(option1) then queryType="fetchFromID" else queryType="fetchDateWise"


I hope it will help you. If you find any problem or confusion feel free to ask again :)