WinForm Development framework of the General Advanced query Module--SNF Rapid development platform 3.3-spring.net.framework

Source: Internet
Author: User

The recent project is really busy, but also has been busy with the project and framework technology, and has been working to improve my WinForm development framework. Make it easier, more friendly and more efficient for you and your customers.

In many of the program modules are very common, but also to the customer extended query a very good supplement, because I have always wanted my WinForm development framework to keep improving, so I made this module, I hope for the future of all my own projects and framework itself, can be efficient use.

1, the use of general-purpose advanced query module and introduction

Since it is called the General query module, then he can not be coupled with the specific table field, but to implement a specific query, you must pass the property in some way to achieve more intuitive and friendly field query function. Advanced query module, in a lot of well-developed programs will be provided to meet the user to specific fields, add specific conditions, because in general, because the layout of the limited interface query content is relatively limited, just some very common, important fields as query input, if the table field is more, Then there are some special fields that are at a loss.

As this procedure, the field information is less obvious. Fields that are commonly used as queries generally do not have too many fields, because that will make the page appear bloated and unsightly.

My advanced query Query module is also based on this principle, therefore, add an advanced Query button entry in the main interface, as shown in, click to display a list of all fields, the following interface.

See the above is not familiar and new to it, novelty is because the previous advanced query is a table The first column is the title, the second row is the value of the input and then convert. And I do this is to imitate UF U9 product to do the query scheme. That is to meet the needs of advanced queries and expand the query scheme to save.

When we introduce the input criteria, we notice that the query input can basically be divided into several categories: one is the regular text type, the text box control is used, and the other is that the column of the table translation takes the drop-down list control to show, and the third is the date type, which requires the user to specify the start date and the end date. A custom date range control is also used (for convenience, you can enter only a subset of them as criteria for advanced queries.) ), the four is the number type, is also the use of the text box format, why do not use the scope but can choose the symbol of the query, which is the other people to do advanced query differences. Its five, check box we also did the processing.

After the query will retain the user's input, the second time after opening the interface, will load the previous input conditions, so more humane. At the same time can save the query scheme, for the next login System select query Scheme can bring out the conditions of the query, again query use. Alternatively, you can share the query scheme with others, or you can see it for yourself.

2, the implementation of General advanced query module ideas

A lot of people do it according to the table structure or view structure to do, so there is a limit is not in the query table and view, but the Multi-table association query, the Advanced query field will be incomplete, the other reason table fields are not necessarily all as the query criteria.

I took the field to get the query from the displayed content to be processed in order to use it more simply and conveniently.

This is very simple to call, and a line of code is done.

  stringthis. Showadvancedquery (this. Grvgridview);

1. Use the passed GridView to parse the controls used in each column.

Private void Showquerycontrol ()         {            foreach in gridview.columns)            {                string fieldName = gridcolumn.fieldname;                 if (! fieldname.equals (businesslogic.selectedcolumn))                {                    string name = gridcolumn.caption;                     = Gridcolumn.columntype,                    ..... }}       }    

2. Symbols to be queried when querying fields and controls are resolved above

#regionSymbol drop-down listintTxtnotationwidth = -; PrivateImagecomboboxedit Getnotationimagecomboboxedit (stringfieldName) {Imagecomboboxedit ComboBox= Baseinterfacelogic.createimagecomboboxedit ("cmbnotation"+ FieldName,NULL,NULL, Txtnotationwidth,"Notation");//comboBox.Properties.Items.Clear (); COMBOBOX.PROPERTIES.ITEMS.ADD (NewImagecomboboxitem ("include"," like")); COMBOBOX.PROPERTIES.ITEMS.ADD (NewImagecomboboxitem ("does not contain","Notlike")); COMBOBOX.PROPERTIES.ITEMS.ADD (NewImagecomboboxitem ("left contains","Startwith")); COMBOBOX.PROPERTIES.ITEMS.ADD (NewImagecomboboxitem ("Right contains","Endwith")); COMBOBOX.PROPERTIES.ITEMS.ADD (NewImagecomboboxitem ("equals","Equal")); COMBOBOX.PROPERTIES.ITEMS.ADD (NewImagecomboboxitem ("Not equal to","notequal")); COMBOBOX.PROPERTIES.ITEMS.ADD (NewImagecomboboxitem ("Greater than","Greater")); COMBOBOX.PROPERTIES.ITEMS.ADD (NewImagecomboboxitem ("less than"," Less")); COMBOBOX.PROPERTIES.ITEMS.ADD (NewImagecomboboxitem ("greater than or equal","greaterequal")); COMBOBOX.PROPERTIES.ITEMS.ADD (NewImagecomboboxitem ("less than or equal","lessequal")); COMBOBOX.PROPERTIES.ITEMS.ADD (NewImagecomboboxitem ("Time Range","DateRange")); //ComboBox.Properties.Items.Add (new Imagecomboboxitem ("null", "null")); //ComboBox.Properties.Items.Add (New Imagecomboboxitem ("Non-Empty", "notnull")); //ComboBox.Properties.Items.Add (New Imagecomboboxitem ("between", "between"));Combobox.selectedindex =0; returnComboBox; }        #endregion

3. After the display is complete, you need to reverse-parse the page control after clicking on the query.

The following is the key code for the anti-parsing condition.

foreach(Control controlinchscrollablecontrolquery.controls) {if(Control isFlowLayoutPanel) {Panel=(FlowLayoutPanel) control; foreach(Control ChildControlinchpanel. Controls) {//05. Normal drop-down box                        if(ChildControl isImagecomboboxedit) {}                    }                }          }

4. coexist with common query function

In order to make the traditional query button, and advanced query can coexist, we need to store an advanced query query object, but when the traditional query, we set the advanced query object is empty to block the advanced query conditions.

As can be seen in the above code, the query scheme will only return the assembled SQL condition to the public string querywhere = string after clicking on the query. Empty; properties. After that you want to use it is the program said forget it. So that our program can meet the needs of customers as far as possible, to obtain better feedback and support.

The complete code is used in the project as follows:

 #regionAdvanced Query Event handling/// <summary>        ///Advanced Query Event handling/// </summary>        /// <param name= "Sender" ></param>        /// <param name= "E" ></param>        Private voidBtnsearcha_click (Objectsender, EventArgs e) {            stringWheresql = This. Showadvancedquery ( This. Grvgridview); if(!wheresql.equals (Showadvancedquerycancel)) {                 This.            Search (Wheresql); }                    }        #endregion

From the above view, in fact, I do this high-level query in the industry is relatively simple and practical. It also adds a query scheme for storage. It is also a standard practice in the line. Others can follow suit.

Of course, this query scheme is not satisfied with the current function, but also to expand the collation and display the column control.

-------------------------------------------------------------------------------------------

Wang Chuntin 2015-10-21
Author Blog:http://www.cnblogs.com/spring_wang Source: http://www.cnblogs.com/spring_wang/p/4874584.html

If you feel good, please reprint.

A series of articles on the SNF Rapid development Platform framework:

WinForm Development framework of the General Advanced query Module--SNF Rapid development platform 3.3-spring.net.framework

WinForm Development Framework Chart Report online designer 2-chart-snf.easyquery Project--SNF rapid development Platform 3.3-spring.net.framework

WinForm Development Framework Chart Report online designer-report-snf.easyquery Project--SNF Rapid development Platform 3.3-spring.net.framework (

WinForm Development framework of the common accessories management Module--SNF Rapid development platform 3.3-spring.net.framework

Snfautoupdater Universal Auto-upgrade Component V2.0-winform

SNF Rapid Development Platform 3.2--. net extensible Document number generator-snf.coderule

SNF Rapid Development Platform 3.1--Audit flow (3) Low-key luxury, simple and uncommon, example demo-snf.workflow

SNF Rapid Development Platform 3.1--Audit flow (2) process design-snf.workflow function instruction

SNF Rapid Development Platform 3.1--Audit flow (1) SNF. Introduction to Workflow Audit flow

SNF Rapid Development Platform 3.0--Perfect code generator snf.codegenerator-Quick Developer's weapon

--spring.net.frameworkv3.0 General introduction of Web development framework based on Mvc4+easyui

SNF Rapid Development Platform 3.0--MVC Printing Solution

SNF Rapid Development Platform 3.0--File batch upload-Unified Attachment Manager-Online Preview file (with Internet and no two)

SNF Rapid Development Platform 3.0--asp.net MVC4 powerful export and bulk import without uploading files to excel

SNF Rapid Development Platform 3.0 MVC Universal Control Library show-asp.net+mvc4.0+webapi+easyui+knockout

SNF Rapid Development Platform 3.0 of the BS page show and nine advantages-part of the page display effect-asp.net+mvc4.0+webapi+easyui +knockout

SNF Rapid Development Platform 3.0-interface Personalization + 10 skins + 7 Menu-asp.net+mvc4.0+webapi+easyui+knockout

SNF Rapid Development Platform 3.0-cs page-asp.net+spring.net.framework

SNF Rapid Development Platform 3.0-the role of broadcasting in the system-quickly and concisely send the message to the receiver

WinForm Development framework of the General Advanced query Module--SNF Rapid development platform 3.3-spring.net.framework

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.