Look at the case study VFP: Sorting the results of the query

Source: Internet
Author: User
Tags join sort

This example is a "wage list" showing the nature of each record and the actual wage. This example uses the SELECT statement to calculate bonuses, grants, and so on in the form's Init event, and outputs the query results to a temporary table named LSJJ that contains the "real money" and "employee number", and then the People information table A table join query with a temporary table lsjj and sort the results of the query to the temporary table LSB, which includes the fields and wages that you want to display (this is the calculated payroll), and finally displays the data source that the LSB is set as a table control.

This example applies the knowledge of the ORDER BY clause and the INNER JOIN clause in the SELECT statement, and for the SELECT statement, refer to the Select SQL command or the SQL language tutorial. This example applies to the data environment, and uses the "People Information table" and "payroll" in the Data 1 database as the data source of the data environment, and the situation of the database is already looking at the case study VFP: sample database is given in the article, the running interface is shown at the end of this article.

Production steps:

First, create a new form, set its Caption property value to "Get started on the programming web-sort the results of the query," and set the AutoCenter property value to. T.,width property value set to 375,height property value set to 250 and save form as " Sort the results of the query. Scx ".

Add a Label control to the form, set its Caption property value to "wage ranking", and set the AutoSize property value to. T.,fontbold property value set to. t.,fontsize property value set to 18,forecolor property value set to " 0,0,255 ".

Third, add a table control below the label control and set its RecordSourceType property value to 1-alias, and the ReadOnly property value to. T.

Four, right click the blank space of the form select the Data Environment command to add the people information table and the payroll table to the data environment.

To adjust the position of each control on the form, the Adjusted form Designer is shown in the following illustration:

Vi. Add event code:

Init event code for the form:

Select bonuses-Medical insurance-endowment insurance-accident insurance + housing subsidy + living allowance;
 As the bonus, the employee number from the payroll into cursor LSJJ
Select personnel Information table. Name, Personnel information Table-Department, Personnel information table-gender,;
 Personnel Information table-Home address, Personnel information table-Basic salary +lsjj. Cash bonus;
 As Payroll from staff Information table inner join LSJJ;
 On personnel information table. Number =LSJJ. Employee number ORDER BY pay DESC into cursor lsb
thisform.grid1.recordsource= "LSB"

Run "Sort the results of the query. Scx", the interface of the following figure:

Resources:

The basic course of VFP: http://bianceng.cnhttp://www.bianceng.cn/vfpjc/index0.htm

VFP Primary Course: http://bianceng.cnhttp://www.bianceng.cn/cc/index.htm

VFP Intermediate Course: http://bianceng.cnhttp://www.bianceng.cn/mcc/mcc.htm

VFP Advanced Course: http://bianceng.cnhttp://www.bianceng.cn/hcc/hcc.htm

VFP Network Development: http://bianceng.cnhttp://www.bianceng.cn/VFPwz/vfpwlkf.htm

VFP Call API function: http://bianceng.cnhttp://www.bianceng.cn/VFPwz/vfpapi.htm

VFP Report Print: http://bianceng.cnhttp://www.bianceng.cn/VFPwz/vfpreport.htm

VFP Common technique: http://bianceng.cnhttp://www.bianceng.cn/VFPwz/vfpcyjs.htm

VFP Experience Summary: http://bianceng.cnhttp://www.bianceng.cn/VFPwz/vfpjyhz.htm

VFP Control use: http://bianceng.cnhttp://www.bianceng.cn/VFPwz/vfpkjsy.htm

VFP Data processing: http://bianceng.cnhttp://www.bianceng.cn/VFPwz/vfpsjcl.htm

This example code is debugged in the win2003+vfp6.0 environment.

See the full set of "rookie also learn VFP" tutorial

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.