As the carrier of communication with users, the main form has been preliminarily designed. When we press a function button, we can get a form with corresponding functions. We call these forms as sub-forms for the time being.
10 sub-forms are designed to implement the corresponding functions. The 10 sub-forms are placed in the PerForm folder. The names of the 10 forms are F_AddressList, F_ClearData, F_Find, F_HaveBack, F_ManFile, F_Stat, F_User, F_UserAdd, F_UserPope, F_WordPad. Address query, data clearance and personnel query are implemented respectively. data base Restore, recognize browsing, personnel statistics, user information, add users, user rights settings and notepad functions.
In this section, firstly, we design F_AddressList to query according to query conditions and query types, and find the desired data. The relevant knowledge of SQL query will be used. If you can supplement the relevant knowledge, it will be very helpful for understanding.
The design interface is as follows:
Grid'View control is used to display the inquired data in the form, a ComBox control is used to provide the user with the choice of the inquiry type, a TextBox control is used to receive the inquiry conditions, and four Button buttons are designed to realize the functions of adding, modifying, deleting and exiting.
When the interface is designed, various functions are implemented:
1. Define two instantiated objects, MyClass and MyModule
Declare a DataSet "data container" for querying results through the SqlDataReader class
// Query to get all the items in tb_AddressBook table to add information.
// Find_Field--> stores query fields corresponding to TextBox controls
The showAll () method is called in the load event:
3. When the query button is clicked, the query operation is needed to complete the function by implementing Button's Click event.
4. The implementation code of query condition selection in ComBox control is as follows:
5. When all buttons are clicked, the corresponding code for the Click event is:
6. When we need to add data to this table, we need to click the "Add Button", which is the code for the triggered Click event.
7. When clicking the modification button, the existing data can be modified, which is also realized by clicking the button to trigger the Click event of the button:
8. When the delete button is clicked, the existing data is deleted. The Click event implementation code is as follows:
When you click to exit, you need to add this.Clsoe(); that's all.
9. However, what really shows us the results of the query is the GridView control, which implements its cell enter event here:
At this point, the form design is basically completed, and the F_ClearData form will be designed in the next section.