Let PowerBuilder's interface of the Query system is more cool

zhaozj2021-02-16  70

In the management information system, the query system accounts for a considerable status (SQL Chinese is a structured query language), because it is open to users, the interface must be friendly, let others see it. According to the number of query results record, the query can be divided into two: 1. Unique record query. Such as: Enter the record number from the keyboard to query the person's file.

2. Fuzzy query, the result is a lot of records.

Here we use the production marriage system as an example, including a large fuzzy query, multi-button selection interface, and the recorded connection. Working Principle: Pass the selected conditions by defining the variables, such as: Sex can define variable SEX, age can define variables OLD. Note that the variable must be defined first, then use. One. Multi-button selection interface production. Multiple radio button in the packet box can only select one at the same time. Procedure: Newly created a window of B2, place the control in the window as shown below. Define variables (important), press Menu Declare Instance Variables, define instance variables in the dialog box, keyboard input: String sexinteger OLD Defines the Click event of the Query button after the Verification button: if rb_1.checked = true kil = "w "elseif rb_2.checked = true thensex =" m "end ifif rb_3.checked = true thenold = 30elseif rb_4.checked = true thenold = 40elseif rb_5.checked = true thenold = 50end if sle_1.text = sexsle_2.text = string (old If the window (notice is not running the application), then press the Query button, the result is as shown below, the variable has been correctly assigned. two. Data filtration. Next, you will be able to filter, so that the variable is passed to the WHERE statement in the SQL language, where to write SQL statements? In the WHERE tab below the data window, you can automatically generate the SQL filter statement.

Creating and entering the following table in SQL Anywhere, table name is AAA1, Head: Field Type Length Title head id char 10 No. Name Char 10 Name Old Integer Age SEX Char 10 Gender STATUS Char 30 Status Table AAA1 Content: ID Name Old SEX Status1 Xiao Wang 23 Women's Guide English 2 Xiao Li 34 Male Industry Revenue High 3 Xiaolin 45 Female Accounting 4 Little Yellow 27 Men's Computer Expert 5 Xiao Zheng 38 Female Teacher In Data Window New Creation Two Data Windows: Data Source For the AAA1 table, the requirements are as follows: Data Window Name Data Source Form Display Format SQL Filter Schemrate AD1 ID, NAME, OLD, SEX SQL SELECT Table "AAA1". "SEX" =: Sex and "aaa1". "OLD" <= : Oldad2 ID, Name, OLD, SEX, STATUS SQL SELECT free format "aaa1". "ID" =: id Note Write SQL filter statement is: in the data window, first in the first ID and Name, below the window Press the WHERE tab, press Colume, and select "AAA1" in the drop-down strip of Cloume. "SEX", fill in the Valua column: SEX, note that there is a column in front of the SEX, then pull strips in Cloume "AAA1" in the middle, "OLD", in the Operator column (=, filling in the field: Old, press the DESION menu above the window, select Retriveal Arguments, fill in the Name column, pay attention, here There is no colon in front of Sex, and the Type column is selected, and then fill in the next line in the Name column, the Type column selected Number. At the same time, in order to let the form data of the personal data, press the Sort tab at the bottom of the window, drag the id field to the right. Press the SYNTAX tab to see the automatically generated SQL statement. Select "AAA1". "ID", "aaa1". "Name", "aaa1". "OLD", "aaa1". "SEX" from "aaa1" where ("aaa1". "SEX" =: sex) and ("AAA1". "OLD" <=: OLD) Order by "aaa1". "OLD" ASC here the SQL statement means selecting gender = variable SEX, age <= variable OLD record. Only a few fields are displayed. Although in PB, these statements are automatically generated by dragging icons, but see, understanding their working principles or benefits. three. Data connection. You can use the mouse to make the recorded window as shown below, which mainly uses the function GetItemString (GetRow (), 1), which can get the first string of the left side of the current line of the mouse, that is, the data window is currently The value of the ID field, and assigns the instance variable TTTT, TTTT to the SQL of the data window 2, the WHERE ID =: ID, the ID = TTTT can be displayed in the data window II.

转载请注明原文地址:https://www.9cbs.com/read-17788.html

New Post(0)