cool hit counter Server room charging system (VB.NET) - super detailed report creation process_Intefrankly

Server room charging system (VB.NET) - super detailed report creation process

Copyright: This is an original post by the blogger and may not be reproduced without the blogger's permission.

The report used in the previous server room charging system was Grid++Report, and the report control that comes with VisualStudio was used in this VB. I was certainly unfamiliar with this piece of functionality at first, but after exploring it for a while I was able to get it to work.

The following is the process of creating reports in VisualStudio (I used VisualStudio 2013, if different from the version you are using, please consider the actual situation if there are discrepancies in the process) documented in as much detail as possible for beginners to learn reference.

To get the whole picture right, take a look at the finished product, the finished statement is as follows.

Actually being able to achieve such a result requires two things: adding the report control ReportViewer and adding an edit RDLC file. Personally, I feel that the RDLC file is there to bind the data needed in the database, and ReportViewer references the RDLC file to display the data that the RDLC file binds from the database.

1. Add the report control ReportViewer.

Adding a report control is easy: Toolbox-Reports-ReportViewer control.

2. Adding and editing editorial RDLC files.

To add RDLC files, there are two ways: 1. Left-click the ReportViewer you just added, you will find a small black triangle will appear in the upper right corner of the control, click that small triangle → Design New Report:.

If the RDLC file is being created for the first time, the screen that comes out looks like this.

As shown in the upper left corner of the picture, the system default name of this new data set is "DataSet1", in order to name standard, we first cancel the "Data Source Configuration Wizard" form, rename the name of the data set, mine is named DataSetCheckoutReport:.

After naming it, click on "New" to enter the "Data Source Configuration Wizard" window.

In " Where will the application get its data from? Under "Issues", select "Database", next.

In " What type of database model to use? "Under the question, select " Data set", next.

In " Which database connection should an application use to connect to a database? " and then click on " New Connection ".

As shown above, select or enter the appropriate items respectively, test the connection, and if the test is successful, OK, automatically returning to the " Data Source Configuration Wizard" form, next.


Sfc, Version=, Culture=neutral,PublicKeyToken=89845dcd8080cc91" or one of its dependencies. The system cannot find the specified file] This error, then you can download and installSharedManagementObject.msi

Select the objects in the database that you need to use, set the DataSet name, finish, and automatically return to the " Report Wizard" form, next.

Drag the required fields into the row or column groups in order. Since the fields must be dragged into the "∑Values", here we drag in a random field (you can change it later if you don't need it) and keep clicking "Next" until "Finish", and the RDLC file will look like this.

Here we don't need to use sum for each column, so right click on each row and last column of the table to delete the rows and columns that are not needed, leaving only the rows and columns that are needed (or just delete this table, right click to insert a new table, and then edit it to suit your needs), I designed the table as follows

The first row is the column heading, the second row is the data associated with the data in the database, the mouse to the second row of each cell, a small icon will appear in the upper right corner of the cell, click can be associated with the data in the data set for the cell and the entire column where the cell is located.

Here are some details to start designing the report, such as title, parameters, time, etc..

Add text box : Add the title "Checkout Sheet for Server Room Charging System" It is actually a text box that can be added to the [Toolbox]. The same applies to other texts such as "Start time:", "End time:", etc..

Adding built-in fields:as shown above, Bottom right.《Exp》 It's the function that comes with the report, It can be found on【 Reported data】 to the built-in fields of the, For example, I have this in the bottom right cornerExp It is to show the time of execution of the report, Time format can be set by yourself, right click《Exp》— expression (math.), (located) at“ Set expressions for the following items” Just enter the expression under, If I want it to display the time in the format of“2014-08-08 08:08:08”, then you can enter“=Format(Now,"yyyy-MM-dd hh:mm:ss")”;

Adding parameters For example, I want to display the operator who created the report in the bottom left corner of the report, and the operator's user name can only be obtained from the program, and the start date @startTime and the end date @endTime above need to be passed in from the code. This type of parameter can be added by right-clicking on "Parameters" in [Report Data].

(Note: If you don't find [Toolbox] or [Report Data] then you need to go to [View] to add it. )

Here comes the final stage, adding the code, the core code is (limited to space, only the refresh button event code is posted here).

' The first thing to add to this code layer is the following reference
Imports System
Imports Microsoft.Reporting.WinForms
Private Sub btnRefresh_Click(sender As Object, e As EventArgs) Handles btnRefresh.Click
        ' Checkout records by time period
        Dim startTime As String = Format(dtpBegin.Value, "yyyy-MM-dd")
        Dim endTime As String = Format(dtpEnd.Value, "yyyy-MM-dd")
        Dim dt As New DataTable
        ' targets【checkReportFacade】 of【QueryCheckOut】 The method function is based on two dates, Query the checkout records for this time period
        dt = checkReportFacade.QueryCheckOut(startTime, endTime)

        ' Declare a report data source object
        Dim rptDateSource = New ReportDataSource
        ' Setting the report data set name
        rptDateSource.Name = "DataSetCheckoutReport"
        ' Example of setting up a report data source
        rptDateSource.Value = dt
        ' Set the name of the resource embedded in the report
        reportViewer.LocalReport.ReportEmbeddedResource = "UI.CheckReport.rdlc"
        ' Emptying the report data source
        ' Adding a report data source

        ' Setting up a collection of parameters in a report( note: The parameters here and in the report should be the same case and data type)
        Dim strUserID As String = Entity.UtilUserEntity.UtilUser.UserID
        Dim params As ReportParameter()
        params = {New ReportParameter("startTime", startTime),
                  New ReportParameter("endTime", endTime),
                  New ReportParameter("userId", strUserID)}
        ' Passing a collection of parameters in a report
        ' Refresh Statement
    End Sub

Please note. : The dataset name DataSetCheckoutReport in the code must be the same as the dataset name DataSetCheckoutReport that was set when the RDLC file was first created, otherwise the error "No datasource instance has been provided for the datasource ***" will occur.

Finally, re-click the ReportViewer space added in the first step, click the small triangle in the upper right corner, and select the report you just created after "Select Report" and you're done. At this point, a simple report has been created

If there are errors or incompleteness in the steps, feel free to add clarification.

1、microservice architecture
2、InetAddress Analysis
3、Blog commenting Netflix follow up comment alert feature
4、Do you really understand modal arithmetic
5、Basic operations of a linked table with a head node

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送