Development Process of Combined Query of Data room Charging System

Source: Internet
Author: User

Let's talk about my combined query.

In combination query, the earliest thought was to use structure, because there is a type in the impression that it can be accessed using the int type, but it was found that it was not a structure, by searching online, the enum type is found.

There are four Combined Query forms in the data center charging system. The four forms have the same appearance, so the inheritance between forms is not mentioned.

However, after inheritance, it is found that the click event of the child form button is not executed, and the parent class click event is executed. If handle btnquery. Click is added to the subclass method, an error is returned. Later, I found myself confused. Then, change the function of the parent class click event to overridable, and the problem is solved after the subclass is overwritten.

Through inheritance, we saved the effort to copy and paste the code that judged the input, saving a lot of trouble in parameter filling. Next I will explain how I implement it. No matter how I fill in the conditions, only three parameters are transmitted, and no select judgment is made. Because my relation is an and relation by default, therefore, only the relation uses an if statement to determine whether the relationship is or not. When there is only one condition, the three parameters are assigned the same value, that is, to query and relationships for three identical conditions. The advantage of doing so is to avoid the use of judgment statements to splice strings and directly input parameters in the stored procedure.

Secondly, for the fields used in the corresponding table for each combination query, I have created an enumeration type, the order of the fields contained in the enumeration type, and the text corresponding to the selectindex location of the corresponding combo box. Create a class by using the field name (Enumeration type), operator, content to be queried, and composite relationships. In this way, there are four classes, all of which overwrite the initial values of the new function. Example:


The assignment of initial values is also why I discard structure and use class. In my opinion, structure can be assigned an initial value, but when I assign an initial value, an error is always prompted. Through the query, structure has a constructor without parameters, but it cannot be rewritten (this is described in msdn, but most of the information I have found can be rewritten, it should be in.. net. I did not go into this topic too deeply. The first one is the information searched on the Internet, and the second one is described in msdn. The two are the opposite ...)

 

Because only the field names of the classes corresponding to these four combinations of queries are different, and the Fill function is used to assign values to each Member, I used the template method (as mentioned in the previous article)

The development history of my Combined Query is almost like this. Next I will talk about the passing of parameters in this process.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.