8 Ekim 2015 Perşembe

Axapta - Send and receive dataset

I took this code part from Fatih Demirci's developments.

Send dataset:
 

    System.Data.DataTable               dataTable;
    System.Data.DataColumnCollection    dataTableColumns;
    System.Data.DataRowCollection       DataRowCollection;
    System.Data.DataRow                 tmpRow;
    System.Data.DataSet dataset = new System.Data.DataSet();
    System.Data.DataTableCollection     dataTableCollection;


    dataTable = new System.Data.DataTable();
    dataTableColumns = dataTable.get_Columns();

//Describe lines
    dataTableColumns.Add("ACCOUNTNO", System.Type::GetType("System.String"));
    dataTableColumns.Add("ITEMNO", System.Type::GetType("System.String"));
    dataTableColumns.Add("TOACCOUNTNUM", System.Type::GetType("System.String"));
    dataTableColumns.Add("RETURNREASONIDD", System.Type::GetType("System.String"));
    dataTableColumns.Add("QUANTITY", System.Type::GetType("System.Double"));
    dataTableColumns.Add("DESCRIPTION", System.Type::GetType("System.String"));
//bir satır al
    DataRowCollection = dataTable.get_Rows();
        tmpRow = dataTable.NewRow();
//fill lines
    tmpRow.set_Item("ACCOUNTNO","MU_014600");
    tmpRow.set_Item("ITEMNO","200.05.01.0306");
    tmpRow.set_Item("TOACCOUNTNUM","MU_014600");
    tmpRow.set_Item("RETURNREASONIDD","");
    tmpRow.set_Item("QUANTITY",11);
    tmpRow.set_Item("DESCRIPTION","");

    DataRowCollection.Add(tmpRow);

     dataTable.AcceptChanges();
//At this time if opposite side needs data table, it's ready

//In the other case if wants dataset, tie to dataset
     dataTableCollection     = dataSet.get_Tables();
     dataTableCollection.Add(datatable);
//now dataset ready too


Receive dataset:

    System.Data.DataTable               dataTable;
    System.Data.DataTableCollection     dataTableCollection;
    System.Data.DataColumnCollection    dataColumnCollection;
    System.Data.DataRowCollection       dataRowCollection;
    System.Data.DataRow                 dataRow;
    System.Data.DataColumn              dataColumn;
    System.Data.DataTable               returnData;
;


        dataTableCollection     = dataSet.get_Tables();
        totalTable              = dataTableCollection.get_Count();
        for(i = 0; i < totalTable; i ++)
        {
            dataTable               = dataTableCollection.get_Item(i);
            dataColumnCollection    = dataTable.get_Columns();
            DataRowCollection       = dataTable.get_Rows();
            totalRow                = dataRowCollection.get_Count();
            totalCol                = dataColumnCollection.get_Count();
            for( j = 0; j < totalRow; j ++)
            {
                dataRow         = dataRowCollection.get_Item(j);
                custAccount     = dataRow.get_Item("ACCOUNTNO");
                itemId          = dataRow.get_Item("ITEMNO");
                toCustAccount   = dataRow.get_Item("TOACCOUNTNUM");
                strtext         = dataRow.get_Item("RETURNREASONIDD");
                krc_DefectiveId = str2int64(strtext);
                strtext         = dataRow.get_Item("QUANTITY");
                _b2bdesc        = dataRow.get_Item("DESCRIPTION");
...

2 yorum: