Pro SQL Server 2012 Reporting Services

(sharon) #1

CHAPTER 10  MANAGING REPORTS


GetParameters reportParameters = new GetParameters(url);
reportParameters.ShowDialog();
Microsoft.Reporting.WinForms.ReportParameter[] rps = reportParameters.Parameters;

// Convert the Winforms.ReportParameter returned
// from the GetParameters to ParameterValues required for
// the CreateSubscription method
int i = 0;
foreach (Microsoft.Reporting.WinForms.ReportParameter rpin rps)
{
if (rp.Values.Count != 0) i++;
}

ParameterValue[] pvs = new ParameterValue[i];
int j = 0;
foreach (Microsoft.Reporting.WinForms.ReportParameter rp in rps)
{
if (rp.Values.Count != 0)
{
pvs[j] = new ParameterValue();
pvs[j].Name = rp.Name;
pvs[j].Value = rp.Values[0]; j++;
}
}

// Now set up the subscription
try
{
rs.CreateSubscription(report, extSettings, desc, eventType, matchData, pvs);
}
catch (SoapException ex)
{
MessageBox.Show(ex.Detail.InnerXml.ToString());
}
}
}

To complete the PickSchedule form, you need to wire up the setSchedule button’s click event so it
will call the ScheduleReport method to actually schedule the report with the schedule selected by the
user. With the PickSchedule.cs in design mode, double-click the OK button. Add the code shown in
Listing 10-8.

Listing 10-8. Hooking the Schedule Button’s Click Event to the ScheduleReport Method

private void setSchedule_Click(object sender, EventArgs e)
{
ScheduleReport();
}

Now let’s add a button to the ViewerRVC.cs form that you’ll code to call the new PickSchedule.cs
form. First, you need to add a new button to the ViewerRVC.cs form as shown in Figure 10-30. Name it
Free download pdf