Thursday, March 22, 2012

custom web app for reportviewer

Hi,

I am trying to develop a custom web page to display and generate our company reports.

It shoud have a login page, and then a general window with 2 or 3 frames (top frame with general info, left frame with a

dynamic list of all existing reports (eventually categorized by a certain word in the report title), and a center frame

that has initialy the company logo and after selecting a specific report displays the parameters and afterwards the

generated report).

Does anybody has some pointers or links on the web where some of this is a little bit documented.

I have dev skills in vb.net and know how to work with ssrs.

My web dev skills are intermediate.

All info, tips, hints are very welcome ...

Greetings

Vinnie

If ou want logic i can provide you that..

code you need to write..

I think you can create login page and list of report..

For the 3rd frame.

keep 3 control there

1 image

2 panel with all the controls thath you need for parameter

3 reportviewer control (property visible = false and size (min that you want)

for 1 - you can initially keep image visible.

on click on list of report make it invicible and make the panel for parameter visible.

2) initially invisible as i said above while keeping it visible check for the parameters for the report that are needed and make thaem visible. everything else invisible.

( In my 10 reports I have kept name of the parameters same for same type like if i need to pull patientname and first visit date ..... so my report parameter is patienName, StartDate in 2 nd report date is i need Patientname with last visitdte

then parameter would be PatientName,last date.

in 3rd report i need patient visited between FirstDate and lastDate.. I would keep same parameter Name..

So for each parameter I hav one control.

So it would be easy to make them visible as per report name.

After that you need to set report to report viewer

than pass parameter values to report

than database login to report( if needed)

than make report viewer visible.

RptViewer.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local;

string ReportPath = "";

ReportPath = ReportLoad.Reportpath + ReportRow["ReportName"].ToString();// ;

if (File.Exists(ReportPath))

{

RptViewer.LocalReport.ReportPath = ReportPath;

//RptViewer.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);

//RptViewer.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent;

//RptViewer.ZoomPercent = 100;

RptViewer.LocalReport.DataSources.Clear();

SetReportParameter(weekdate);

RptViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("SlimPOS", GetWeekenderData(weekdate)));

RptViewer.RefreshReport();

}

private void SetReportParameter(DateTime weekenddate)

{

Microsoft.Reporting.WinForms.ReportParameterInfoCollection ParInfo;

Microsoft.Reporting.WinForms.ReportParameter[] RepParameter;

ParInfo = RptViewer.LocalReport.GetParameters();

RepParameter = new Microsoft.Reporting.WinForms.ReportParameter[ParInfo.Count];

for (int j = 0; j < ParInfo.Count; j++)

{

switch (ParInfo[j].Name.ToLower())

{

case "centername":

RepParameter[j] = new Microsoft.Reporting.WinForms.ReportParameter("CenterName", domain.Name.ToString(), false);

break;

case "pweekstartdate":

RepParameter[j] = new Microsoft.Reporting.WinForms.ReportParameter("StartDate", Settings.GetStartOfWeek(weekenddate).ToShortDateString());

break;

case "pweekenddate":

RepParameter[j] = new Microsoft.Reporting.WinForms.ReportParameter("EndDate", Settings.GetEndOfWeek(weekenddate).ToShortDateString());

break;

}

}

RptViewer.LocalReport.SetParameters(RepParameter);

}

private void SetDBLogonForReport(string ReportTitle)

{

Microsoft.Reporting.WinForms.DataSourceCredentials[] crd = new Microsoft.Reporting.WebForms.DataSourceCredentials[1];

crd[0] = new Microsoft.Reporting.WinForms.DataSourceCredentials();

crd[0].Name = ReportTitle;

crd[0].UserId = User;

crd[0].Password = Pwd;

RptViewer.LocalReport.SetDataSourceCredentials(crd);

}

Hope it helps.. all the best..

|||

If ou want logic i can provide you that..

code you need to write..

I think you can create login page and list of report..

For the 3rd frame.

keep 3 control there

1 image

2 panel with all the controls thath you need for parameter

3 reportviewer control (property visible = false and size (min that you want)

for 1 - you can initially keep image visible.

on click on list of report make it invicible and make the panel for parameter visible.

2) initially invisible as i said above while keeping it visible check for the parameters for the report that are needed and make thaem visible. everything else invisible.

( In my 10 reports I have kept name of the parameters same for same type like if i need to pull patientname and first visit date ..... so my report parameter is patienName, StartDate in 2 nd report date is i need Patientname with last visitdte

then parameter would be PatientName,last date.

in 3rd report i need patient visited between FirstDate and lastDate.. I would keep same parameter Name..

So for each parameter I hav one control.

So it would be easy to make them visible as per report name.

After that you need to set report to report viewer

than pass parameter values to report

than database login to report( if needed)

than make report viewer visible.

RptViewer.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local;

string ReportPath = "";

ReportPath = ReportLoad.Reportpath + ReportRow["ReportName"].ToString();// ConfigurationManager.AppSettings.GetValues("RSReportpath")[0].ToString() + ReportName; // @."c:\code\slimcommon\reporting service reports\rs report\" + ReportTitle + ".rdl";// Application.StartupPath;

if (File.Exists(ReportPath))

{

RptViewer.LocalReport.ReportPath = ReportPath;

//RptViewer.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);

//RptViewer.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent;

//RptViewer.ZoomPercent = 100;

RptViewer.LocalReport.DataSources.Clear();

SetReportParameter(weekdate);

RptViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("SlimPOS", GetWeekenderData(weekdate)));

RptViewer.RefreshReport();

}

private void SetReportParameter(DateTime weekenddate)

{

Microsoft.Reporting.WinForms.ReportParameterInfoCollection ParInfo;

Microsoft.Reporting.WinForms.ReportParameter[] RepParameter;

ParInfo = RptViewer.LocalReport.GetParameters();

RepParameter = new Microsoft.Reporting.WinForms.ReportParameter[ParInfo.Count];

for (int j = 0; j < ParInfo.Count; j++)

{

switch (ParInfo[j].Name.ToLower())

{

case "centername":

RepParameter[j] = new Microsoft.Reporting.WinForms.ReportParameter("CenterName", domain.Name.ToString(), false);

break;

case "pweekstartdate":

RepParameter[j] = new Microsoft.Reporting.WinForms.ReportParameter("StartDate", Settings.GetStartOfWeek(weekenddate).ToShortDateString());

break;

case "pweekenddate":

RepParameter[j] = new Microsoft.Reporting.WinForms.ReportParameter("EndDate", Settings.GetEndOfWeek(weekenddate).ToShortDateString());

break;

}

}

RptViewer.LocalReport.SetParameters(RepParameter);

}

private void SetDBLogonForReport(string ReportTitle)

{

Microsoft.Reporting.WinForms.DataSourceCredentials[] crd = new Microsoft.Reporting.WebForms.DataSourceCredentials[1];

crd[0] = new Microsoft.Reporting.WinForms.DataSourceCredentials();

crd[0].Name = ReportTitle;

crd[0].UserId = User;

crd[0].Password = Pwd;

RptViewer.LocalReport.SetDataSourceCredentials(crd);

}

Hope it helps.. all the best..

sql

No comments:

Post a Comment