{"id":748,"date":"2008-01-04T19:57:21","date_gmt":"2008-01-05T02:57:21","guid":{"rendered":"http:\/\/members.crystalreportsbook.com\/crystal-reports-xi\/18-5-c-code-listings\/"},"modified":"2010-11-17T18:47:52","modified_gmt":"2010-11-18T01:47:52","slug":"18-5-c-code-listings","status":"publish","type":"post","link":"http:\/\/www.crystalreportsonlinetraining.com\/training\/18-5-c-code-listings\/","title":{"rendered":"18.05 C# Code Listings"},"content":{"rendered":"<h1>C# Code Listings<\/h1>\n<p>The C# code listings are equivalent to the VB.NET code listings.<\/p>\n<p>         <code_Caption>Listing 18-1. Consuming a project&#8217;s web service<\/code_Caption><br \/>\n         <code>private void Form1_Load(object sender, System.EventArgs e)<\/code><br \/>\n         <code>{<\/code><br \/>\n         <code>crystalReportViewer1.ReportSource = new localhost.EmployeeListService();<\/code><br \/>\n         <code>}<\/code><br \/>\n         <code_Caption>Listing 18-2. Preview a report using the web service URL.<\/code_Caption><br \/>\n         <code>private void Form1_Load(object sender, System.EventArgs e)<\/code><br \/>\n         <code>{<\/code><br \/>\n         <code>crystalReportViewer1.ReportSource =<\/code><br \/>\n         <code>\"http:\/\/localhost\/VBWebService\/EmployeeListService.asmx\";<\/code><br \/>\n         <code>}<\/code><br \/>\n         <code_Caption>Listing 18-3. Print a web service report without previewing it.<\/code_Caption><br \/>\n         <code>private void Form1_Load(object sender, System.EventArgs e)<\/code><br \/>\n         <code>{<\/code><br \/>\n         <code>crystalReportViewer1.ReportSource =<\/code><br \/>\n         <code>\"http:\/\/localhost\/VBWebService\/EmployeeListService.asmx\";<\/code><br \/>\n         <code>crystalReportViewer1.PrintReport();<\/code><br \/>\n         <code>crystalReportViewer1.ReportSource = null;<\/code><br \/>\n         <code>}<\/code><br \/>\n         <code_Caption>Listing 18-4. Setting the parameter of a report web service.<\/code_Caption><br \/>\n         <code>private void Form1_Load(object sender, System.EventArgs e)<\/code><br \/>\n         <code>{<\/code><br \/>\n         <code>CrystalDecisions.Shared.IParameterField ParameterField;<\/code><br \/>\n         <code>CrystalDecisions.Shared.ParameterDiscreteValue DiscreteValue =<\/code><br \/>\n         <code>new CrystalDecisions.Shared.ParameterDiscreteValue();<\/code><br \/>\n         <code>crystalReportViewer1.ReportSource =<\/code><br \/>\n         <code>\"http:\/\/localhost\/C_WebService\/EmployeeListService.asmx\";<\/code><br \/>\n         <code>ParameterField = crystalReportViewer1.ParameterFieldInfo[\"LastName\"];<\/code><br \/>\n         <code>DiscreteValue.Value = \"B*\";<\/code><br \/>\n         <code>ParameterField.CurrentValues.Add(DiscreteValue);<\/code><br \/>\n         <code>}<\/code><br \/>\n         <code_Caption>Listing 18-5. Assign a DataSet object to the report&#8217;s data source<\/code_Caption><br \/>\n         <code>public virtual ReportDocument  CreateReport()<\/code><br \/>\n         <code>{<\/code><br \/>\n         <code>EmployeeList    report =<\/code><br \/>\n         <code>new EmployeeList();<\/code><br \/>\n         <code>\/\/Put all your report modification code here<\/code><br \/>\n         <code>DataSet MyDataSet = new DataSet();<\/code><br \/>\n         <code>\/\/Call one of the sample methods from Chapter 17 for populating<\/code><br \/>\n         <code>\/\/the DataSet object<\/code><br \/>\n         <code>FillDataSet(MyDataSet);<\/code><br \/>\n         <code>report.SetDataSource(MyDataSet);<\/code><br \/>\n         <code>report.InitReport += new EventHandler( this.webService.OnInitReport );<\/code><br \/>\n         <code>return ( report );<\/code><br \/>\n         <code>}<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>C# Code Listings The C# code listings are equivalent to the VB.NET code listings. Listing 18-1. Consuming a project&#8217;s web service private void Form1_Load(object sender, System.EventArgs e) { crystalReportViewer1.ReportSource = new localhost.EmployeeListService(); } Listing 18-2. Preview a report using the web service URL. private void Form1_Load(object sender, System.EventArgs e) { crystalReportViewer1.ReportSource = &#8220;http:\/\/localhost\/VBWebService\/EmployeeListService.asmx&#8221;; } Listing [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38,2],"tags":[],"class_list":["post-748","post","type-post","status-publish","format-standard","hentry","category-chapter-18-report-web-services","category-crystal-reportsnet-2003","entry"],"_links":{"self":[{"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/posts\/748","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/comments?post=748"}],"version-history":[{"count":1,"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/posts\/748\/revisions"}],"predecessor-version":[{"id":1663,"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/posts\/748\/revisions\/1663"}],"wp:attachment":[{"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/media?parent=748"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/categories?post=748"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.crystalreportsonlinetraining.com\/training\/wp-json\/wp\/v2\/tags?post=748"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}