Get range and add it to queryrun

Source: Internet
Author: User
The system's query may not be able to meet this requirement: use different tables for association based on different situations to form a datasource
For example, to make a report on miscellaneous charges, you need to view the miscellaneous charges of the sales order and the corresponding order number. miscellaneous charges may be associated with the main table custinvoicejour of the customer's invoice, or the custinvocetrans.
In this case, two different queries must be constructed respectively.
1. If miscellaneous charges are associated with the master table, you only need to associate markuptrans with custinvoicejournal,
2. If miscellaneous charges are associated with the slave table, you need to associate the markuptrans, custinvoicetrans, and custinvoicejournal tables.
Because it is a self-constructed query, the range value selected by the SELECT statement in the dialog is not added to the query and must be written. Code The following code shows the association process. datasource is constructed according to situation 2. Queryrun builddetailqueryrun ()
{
Queryrun qrdetail;
Queryrun qroriginal;
Query Q;
Querybuilddatasource qbdsmarkuptransoriginal;
Querybuilddatasource qbdsinvoicejournaloriginal;
Querybuilddatasource qbdsinvoicetransoriginal;

Querybuilddatasource qbdsmarkuptrans;
Querybuilddatasource qbdsinvoicejournal;
Querybuilddatasource qbdsinvoicetrans;
Int I;
;
Q =   New Query ();
Qbdsmarkuptrans = Q. adddatasource (tablenum (markuptrans ));
Qbdsinvoicetrans = Qbdsmarkuptrans. adddatasource (tablenum (custinvoicetrans ));
Qbdsinvoicetrans. Relations ( True );

Qbdsinvoicejournal = Qbdsinvoicetrans. adddatasource (tablenum (custinvoicejour ));
Qbdsinvoicejournal. Relations ( True );

Qroriginal =   New Queryrun ( This );

Qbdsmarkuptransoriginal = Qroriginal. Query (). datasourcetable (tablenum (markuptrans ));
For (I =   1 ; I <= Qbdsmarkuptransoriginal. rangecount (); I ++ )
Qbdsmarkuptrans. addrange (fieldname2id (tablenum (markuptrans), qbdsmarkuptransoriginal. Range (I). Name (). Value (qbdsmarkuptransoriginal. Range (I). Value ());

Qbdsinvoicejournaloriginal = Qroriginal. Query (). datasourcetable (tablenum (custinvoicejour ));
For (I = 1 ; I <= Qbdsinvoicejournaloriginal. rangecount (); I ++ )
Qbdsinvoicejournal. addrange (fieldname2id (tablenum (custinvoicejour), qbdsinvoicejournaloriginal. Range (I). Name (). Value (gradient. Range (I). Value ());

Qbdsinvoicetransoriginal = Qroriginal. Query (). datasourcetable (tablenum (custinvoicetrans ));
For (I =   1 ; I <= Qbdsinvoicetransoriginal. rangecount (); I ++ )
Qbdsinvoicetrans. addrange (fieldname2id (tablenum (custinvoicetrans), qbdsinvoicetransoriginal. Range (I). Name (). Value (range. Range (I). Value ());


Qrdetail =   New Queryrun (Q );
Return Qrdetail;
}

The code is very simple and will not be explained.

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.