Implement data storage in the main table structure

Source: Internet
Author: User

In November 30, I published an article about solving an object set. No one has replied to me since I have not made it clear. Some time ago, I used C # To implement this function, but there are still some shortcomings. I will give them a target. Thank you for your criticism!

My requirement is that there is a structure in the main table, which contains information such as the document date and document number, and the table contains the row project related to this main table, contains the item number, quantity, and other information. I think this should be implemented by creating an inherited class, but I will not use it yet. I used generics to solve this problem temporarily.

I have written two interfaces: IDocuments and IDocuments_Lines. The corresponding Documents and Documents_Lines classes are also written. These two classes inherit the first two interfaces. IDocuments and Documents contain DocNumber, DocDate, and Lines attributes, and Add () and Remove () methods. The IDocuments_Lines and Documents_Lines attributes include the ItemCode and Quantity attributes, and the Add () and GetLists () methods.

The type of the Lines attribute in the Documents class is IDocuments_Lines. To access the collection of Documents_Lines, I cannot create a public method GetLists () in Documents_Lines (). This method returns a List <> set, and then the Add () method in the statements class traverses this set, and then adds the sub-table data together with the master table.

In the sbo sdk, methods and attributes similar to GetLists () are not exposed in Documents_Lines. In addition, Documents_Lines contains a Count attribute to record the total number of current lines, and can use the SetCurrentLine () method to specify the current row. In addition, there are also differences in calls: the call in the SDK is as follows:

1 Documents myd = myCompany. GetObject (Documents );
2
3Myd. DocNumber = "1 ";
4
5Myd. DocDate = CDate ");
6
7
8
9 // Add Row 1
10
11Myd. Lines. ItemCode = "";
12
13Myd. Lines. Quantity = 1;
14
15
16
17 // Add Row 2
18
19Myd. Lines. Add ();
20
21Myd. Lines. ItemCode = "B ";
22
23Myd. Lines. Quantity = 2;
24
25
26
27 // Add a master table
28
29Myd. Add ()
30
31
32
33 // complete.
34

 

For my classes, the call method is as follows:

1 Documents myd = new Documents ();
2
3Myd. DocNumber = "1 ";
4
5Myd. DocDate = CDate ");
6
7
8
9 // Add Row 1
10
11Myd. Lines. ItemCode = "";
12
13Myd. Lines. Quantity = 1;
14
15Myd. Lines. Add ();
16
17
18
19 // Add Row 2
20
21 // Add Row 2
22
23Myd. Lines. Add ();
24
25Myd. Lines. ItemCode = "B ";
26
27Myd. Lines. Quantity = 2;
28
29
30
31 // Add a master table
32
33Myd. Add ()
34

 

// Complete.

The difference between the two call methods is that, before adding a row to the SDK, execute Lines once. add () method (the first line does not need to be used), and after the last line, Lines. add () method, and the Lines. add () method to Add data to a row set. I don't know why there is such a difference? Thank you for your advice!

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.