C # Data Center reconstruction-report production
Preface
Different from other report software that VB needs to reference, VS has its own report design function. The first attempt is to feel its power.
Report Creation
Let's not talk much about the process of directly generating reports.
1. First, we need to create a report container. Put it on the form where the report is displayed.
2. Add a report.
3. After the report is added, we can see the relevant data of the report.
4. Add the data source and dataset in sequence and test the connection.
5. After the operation is successful. Add the parameters to be used.
6. Then we can add what we need in the report toolbox, such as tables and text boxes. The table here can directly reference the content in the dataset. Click the small icon in the table.
7. reference the data source dataset.
Well, some basic configurations are completed here. Next is the code.
Code
Private void btnInquire_Click (object sender, EventArgs e) {string BeginDate = dtpBegin. text. trim (); string EndDate = dtpEnd. text. trim (); Facade. facade faca = new Facade. facade (); DataTable table = faca. inqCheckInfo (BeginDate, EndDate); ReportDataSource rptDataSource = new ReportDataSource (); ReportParameter [] Params = {new ReportParameter ("ID", Entity. model. user), new ReportParameter ("CheckDate", DateTime. now. toShortDateString ()}; rptDataSource. name = "DataSetCheckReport"; // specify the dataset Name rptDataSource. value = table; // data source name reportViewer. localReport. reportEmbeddedResource = "UI. checkReport. rdlc "; // report file name reportViewer. localReport. dataSources. clear (); // Clear the report reportViewer. localReport. dataSources. add (rptDataSource); // Add the data source reportViewer. localReport. setParameters (Params); // pass the reportViewer parameter. refreshReport (); // refresh report control}
Similar to the Code in layer D, the parameter is first input and then executed. The execution steps are as follows. Summary
If you encounter any difficulties during the report production process, you have to say that the problem occurs when the parameters are passed in. Most of the problems are caused by naming, right-clicking parameters, setting properties, and being careful, make sure that the variable name is correctly displayed in the report.
After completing the report, you may find that the report is not only capable of displaying data, but also has many functions, user friendly. I feel that I not only have too much room for improvement in technology, but also have too much room for improvement in interface friendliness. Therefore, it is not important to do software. What is important is how many people like it.