Namespace DataRead.Data {
Using system; using system.runtime.serialization;
///
// [SerializableAttribute] public class OrderRequestData: DataSet {public DataTable OrderRequestTable; public DataTable OrderTable; public DataTable OrderDetailTable; ///
///
public const String ProducetNo_OrderDetail = "productNo"; public const String Price_OrderDetail = "price"; public const String Quantity_OrderDetail = "quantity"; public const String Remark_OrderDetail = "remark"; public const String OrderNo_OrderDetail = "orderNo"; public const String LineNo_OrderDetail = "lineno"; public const string discount_orderdetail = "discount";
Public OrderRequestData (SerializationInfo Info, StreamingContext Context): Base (Info, Context) {}
Public ORDERREQUESTDATA () {BuildDataTables ();
private void BuildDataTables () {// build table OrderRequestData structure OrderRequestTable = new DataTable ( "OrderRequestData"); DataColumnCollection oRColumn = OrderRequestTable.Columns; oRColumn.Add (SessionID_OrderRequestData, typeof (System.String)); oRColumn.Add ( "OrderRequestData_Id" , typeof (System.Int32)); this.Tables.Add (OrderRequestTable); this.Tables [ "OrderRequestData"] Columns [ "OrderRequestData_Id"] ColumnMapping = MappingType.Hidden;... this.Tables [ "OrderRequestData"] Columns [ "OrderRequestData_Id"] AutoIncrement = true;. // build Order table structure OrderTable = new DataTable ( "Order"); DataColumnCollection orderColumn = OrderTable.Columns; orderColumn.Add ( "OrderRequestData_Id", typeof (System.Int32)); orderColumn .Add (Values_Order, typeof (System.String)); orderColumn.Add (CustomerNo_Order, typeof (System.String)); orderColumn.Add (Remark_Order, typeof (System.String)); orderColumn.Add (RequireDate_Order, typeof (System . String); OrderColumn.Add (ORDERNO_ORDER, TYPEOF (System.String); this.Tables.Add (OrderTable);. this.Tables [ "Order"] Columns [ "OrderRequestData_Id"] ColumnMapping = MappingType.Hidden;... this.Tables [ "Order"] Columns [ "OrderRequestData_Id"] AutoIncrement = true ; // Create a table structure OrderDetail OrderDetailTable = new DataTable ( "OrderDetail"); DataColumnCollection orderDetailColumn = OrderDetailTable.Columns; orderDetailColumn.Add (ProducetNo_OrderDetail, typeof (System.String)); orderDetailColumn.Add (Price_OrderDetail, typeof (System.String) ); OrderDetailColumn.Add (Quantity_OrderDetail, TypeOf (System.String));
orderDetailColumn.Add (Remark_OrderDetail, typeof (System.String)); orderDetailColumn.Add (OrderNo_OrderDetail, typeof (System.String)); orderDetailColumn.Add (LineNo_OrderDetail, typeof (System.String)); orderDetailColumn.Add (Discount_OrderDetail, typeof ( System.String)); this.tables.add (ORDERDetailTable); // Establish THIS.RELATION.ADD ("Order_OrderDetail", this.tables ["Order"]. Columns ["Orderno"], this.tables [ "OrderDetail"]. Column ["Orderno"]); this.relations ["Order_OrderDetail"]. NESTED = true;
this.Relations.Add (.. "OrderRequestData_Order", this.Tables [ "OrderRequestData"] Columns [ "OrderRequestData_Id"], this.Tables [ "Order"] Columns [ "OrderRequestData_Id"]); this.Relations [ "OrderRequestData_Order" ] .Nested = true;
}
The XML file structure is as follows
XML Version = "1.0" Standalone = "YES"?>
-
<
NewDataSet
>
-
<
ORDERREQUESTDATA
>
<
SessionID
>
SessionID
SessionID
>
-
<
ORDER
>
<
Values
>
Values
Values
>
<
Customerno
>
Customnerno
Customerno
>
<
Remark
>
Remark
Remark
>
<
Requiredate
>
Requiredate
Requiredate
>
<
ORDERNO
>
ORDERNO
ORDERNO
>
-
<
ORDERDETAIL
>
<
ProductNo
>
ProductNo
ProductNo
>
<
PRICE
>
PRICE
PRICE
>
<
Quantity
>
Quantity
Quantity
>
<
Remark
>
Remark
Remark
>
<
ORDERNO
>
ORDERNO
ORDERNO
>
<
Lineno
>
Lineno
Lineno
>
<
Discount
>
Discount
Discount
>
ORDERDETAIL>
-
<
ORDERDETAIL
>
<
ProductNo
>
ProductNo
ProductNo
>
<
PRICE
>
PRICE
PRICE
>
<
Quantity
>
Quantity
Quantity
>
<
Remark
>
Remark
Remark
>
<
ORDERNO
>
ORDERNO
ORDERNO
>
<
Lineno
>
Lineno
Lineno
>
<
Discount
>
Discount
Discount
>
ORDERDETAIL
>
ORDER
>
ORDERREQUESTDATA
>
NewDataSet
>
As long as you add a table in an instance of ORDERREQUESTDATA, you can fill the dataset, and the table relationship has been determined, so don't need to be considered again, but not, note that the father must correspond to the value of the sub-line.