locked
Input array error to DataTable RRS feed

  • Question

  • Hallo

    Hope all are well.

    I'm not sure how to copy the complete object values into columns, I understand that this is already in array.

    but updatedTable.Rows.Add("updated Rows" get the following error: Error Message: Input array is longer than the number of columns in this table. (Seems like to columns is not initialized, but the columns is not fixes and can vary.

    Just need to add a row in datatable if condition is true.

     private DataTable CalculateUnitsRequired(DataTable Orders)
            {
                var updatedRows = new tb_ProdTableSqlSymbols();
                int skuCompleteStatus = 5;
                string message = "";
                var updatedTable = new DataTable();            
                int recordCounter = 0;
                
                try
                {
                    foreach (DataRow dr in Orders.Rows)
                    {
                        updatedRows.primkey = Convert.ToInt32(Orders.Rows[recordCounter][0]);
                        updatedRows.orderNr = Orders.Rows[recordCounter][1].ToString();
                        updatedRows.waveNo = Convert.ToInt32(Orders.Rows[recordCounter][2]);
                        updatedRows.pigeonLocation = Orders.Rows[recordCounter][3].ToString();
                        updatedRows.cartonID = Orders.Rows[recordCounter][4].ToString();
                        updatedRows.huNr = Orders.Rows[recordCounter][5].ToString();
                        updatedRows.isGolden = Convert.ToBoolean(Orders.Rows[recordCounter][6]);
                        updatedRows.skuNr = Orders.Rows[recordCounter][7].ToString();
                        updatedRows.unitQty = Convert.ToInt32(Orders.Rows[recordCounter][8]);
                        updatedRows.unitPacked = Convert.ToInt32(Orders.Rows[recordCounter][9]);
                        updatedRows.unitRemaining = Convert.ToInt32((updatedRows.unitQty - updatedRows.unitPacked)); //Calculate if packs left
                        updatedRows.consignmentSize = Convert.ToInt32(Orders.Rows[recordCounter][11]);
                        updatedRows.createdDate = Convert.ToDateTime(Orders.Rows[recordCounter][12]);
                        updatedRows.status = Convert.ToInt32(Orders.Rows[recordCounter][13]);
    
                        if ((updatedRows.unitRemaining <= 0) && (updatedRows.status != skuCompleteStatus))  //Add record to datatable if pack is complete
                        {
                            updatedRows.status = skuCompleteStatus;                        
                            updatedTable.Rows.Add(updatedRows);  //Error happening here when try to add to table.
    
                            message = ("Order Nr " + updatedRows.orderNr + " with HuNr " + updatedRows.huNr + " has been packed complete");
                            LogFiles.EventLogHandler.WriteEvent("3 ; " + this + " ; " + message);
                            Console.WriteLine(message);
                        }
                        recordCounter++;
    
                        if (updatedTable.Rows.Count == 0)
                        {
                            message = ("Order Nr " + updatedRows.orderNr + " haven't got completed HuNr packed");
                            LogFiles.EventLogHandler.WriteEvent("3 ; " + this + " ; " + message);
                            Console.WriteLine(message);
                        }
                    }
                }
                catch (Exception e)
                {
                    LogFiles.ExceptionLogger.WriteException(e);
                }           
                return updatedTable;
            }
        }  


    labjac

    Monday, July 6, 2020 7:43 AM

Answers

  • Hallo

    Thanks, I was hoping there is a way to iterate though the values in a object, and just assign values based on the for loop, but looking at all the examples and answers above there is no "lazy" way.. :-)

    below is what we've done, it works just a bit longer then we wished for.

     try
                {
                    foreach (DataRow dr in rawHuNr.Rows)
                    {
                        currentHuObject = HuTableToObject(rawHuNr, rowCounter);
    
                        if ((currentHuObject.unitRemaining <= 0) && (currentHuObject.status != skuCompleteStatus))  //Add record to datatable if pack is complete
                        {
                            currentHuObject.status = skuCompleteStatus;
                            dt.Rows.Add();
                            dt.Rows[doneCounter][0] = currentHuObject.primkey;
                            dt.Rows[doneCounter][1] = currentHuObject.orderNr;
                            dt.Rows[doneCounter][2] = currentHuObject.waveNo;
                            dt.Rows[doneCounter][3] = currentHuObject.pigeonLocation;
                            dt.Rows[doneCounter][4] = currentHuObject.cartonID;
                            dt.Rows[doneCounter][5] = currentHuObject.huNr;
                            dt.Rows[doneCounter][6] = currentHuObject.isGolden;
                            dt.Rows[doneCounter][7] = currentHuObject.skuNr;
                            dt.Rows[doneCounter][8] = currentHuObject.unitQty;
                            dt.Rows[doneCounter][9] = currentHuObject.unitPacked;
                            dt.Rows[doneCounter][10] = currentHuObject.unitRemaining;
                            dt.Rows[doneCounter][11] = currentHuObject.consignmentSize;
                            dt.Rows[doneCounter][12] = currentHuObject.createdDate;
                            dt.Rows[doneCounter][13] = currentHuObject.status;
                            dt.Rows[doneCounter][14] = currentHuObject.modifiedDateTime;
    
                            message = ("Order Number " + currentHuObject.orderNr + " with HuNr " + currentHuObject.huNr +
                                        " status set to " + currentHuObject.status + " Completed");
                            LogFiles.EventLogHandler.WriteEvent("3 ; " + this + " ; " + message);
                            Console.WriteLine(message);
                            doneCounter++;
                        }
                        else
                        {



    labjac

    • Marked as answer by labjac Wednesday, July 8, 2020 10:39 AM
    Wednesday, July 8, 2020 10:39 AM

All replies

  • Hello,

    You have created upDatedTable without adding any DataColumns. No columns means you get the error you got.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, July 6, 2020 11:44 AM
  • Hallo Karen

    I'm aware, but the issue is the column could differ for the dataTable, even when getting data from Sql I never defined the columns directly, based on the data from what I understand it will create it.

    Below I don't define that amount of columns and the data is copied correctly into the table.

     public DataTable GetAllRecordsByOrderNr(string orderNr)
            {
                var dt = new DataTable();
    
                try
                {
                    conn.SqlQuery("SELECT * FROM [tb_ProdTable] where OrderNo = @OrderNr order by Primkey desc");
                    conn.Cmd.Parameters.AddWithValue("OrderNr", orderNr);
                    dt = conn.QueryEx();
                }
                catch (Exception e)
                {
                    LogFiles.ExceptionLogger.WriteException(e);
                }
                return dt;
            }

    Otherwise I need to find a way to put the object data in a array and run a for loop to populate the columns on the same row, but not sure how to address the object if there is no other way?


    labjac

    Monday, July 6, 2020 12:48 PM
  • hi

    The table structure should be define .First  So add the columns  to the datatable .Then add rows

    Thanks and regards

    Monday, July 6, 2020 1:03 PM
  • Hallo Karen

    I'm aware, but the issue is the column could differ for the dataTable, even when getting data from Sql I never defined the columns directly, based on the data from what I understand it will create it.

    Below I don't define that amount of columns and the data is copied correctly into the table.

     public DataTable GetAllRecordsByOrderNr(string orderNr)
            {
                var dt = new DataTable();
    
                try
                {
                    conn.SqlQuery("SELECT * FROM [tb_ProdTable] where OrderNo = @OrderNr order by Primkey desc");
                    conn.Cmd.Parameters.AddWithValue("OrderNr", orderNr);
                    dt = conn.QueryEx();
                }
                catch (Exception e)
                {
                    LogFiles.ExceptionLogger.WriteException(e);
                }
                return dt;
            }

    Otherwise I need to find a way to put the object data in a array and run a for loop to populate the columns on the same row, but not sure how to address the object if there is no other way?


    labjac

    Look at DataTable.Clone.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, July 6, 2020 1:05 PM
  • Hallo

    Ok so I've created the table structure but the issue is I need to add values a object into the datatable, I cannot find a way to loop through the values or to put it in array to loop through, there mus be something simple I'm missing..

     private DataTable CalculateUnitsRequired(DataTable Orders)
            {
                var updatedObject = new tb_ProdTableSqlSymbols();
                int skuCompleteStatus = 5;
                string message = "";
                var updatedTable = new DataTable();
                int recordCounter = 0;
    
                updatedTable.Columns.Add("Primkey", typeof(int));
                updatedTable.Columns.Add("OrderNr", typeof(string));
                updatedTable.Columns.Add("WaveNr", typeof(string));
                updatedTable.Columns.Add("PigeonLocation", typeof(string));
                updatedTable.Columns.Add("CartonID", typeof(string));
                updatedTable.Columns.Add("HuNr", typeof(string));
                updatedTable.Columns.Add("IsGolden", typeof(bool));
                updatedTable.Columns.Add("SkuNr", typeof(string));
                updatedTable.Columns.Add("UnitQty", typeof(int));
                updatedTable.Columns.Add("UnitPacked", typeof(int));
                updatedTable.Columns.Add("UnitRemaining", typeof(int));
                updatedTable.Columns.Add("ConsignmentSize", typeof(int));
                updatedTable.Columns.Add("CreatedDateTime", typeof(DateTime));
                updatedTable.Columns.Add("Status", typeof(int));       
                
                
                try
                {
                    foreach (DataRow dr in Orders.Rows)
                    {
                        updatedObject.primkey = Convert.ToInt32(Orders.Rows[recordCounter][0]);
                        updatedObject.orderNr = Orders.Rows[recordCounter][1].ToString();
                        updatedObject.waveNo = Convert.ToInt32(Orders.Rows[recordCounter][2]);
                        updatedObject.pigeonLocation = Orders.Rows[recordCounter][3].ToString();
                        updatedObject.cartonID = Orders.Rows[recordCounter][4].ToString();
                        updatedObject.huNr = Orders.Rows[recordCounter][5].ToString();
                        updatedObject.isGolden = Convert.ToBoolean(Orders.Rows[recordCounter][6]);
                        updatedObject.skuNr = Orders.Rows[recordCounter][7].ToString();
                        updatedObject.unitQty = Convert.ToInt32(Orders.Rows[recordCounter][8]);
                        updatedObject.unitPacked = Convert.ToInt32(Orders.Rows[recordCounter][9]);
                        updatedObject.unitRemaining = Convert.ToInt32((updatedObject.unitQty - updatedObject.unitPacked)); //Calculate if packs left
                        updatedObject.consignmentSize = Convert.ToInt32(Orders.Rows[recordCounter][11]);
                        updatedObject.createdDate = Convert.ToDateTime(Orders.Rows[recordCounter][12]);
                        updatedObject.status = Convert.ToInt32(Orders.Rows[recordCounter][13]);
    
                        if ((updatedObject.unitRemaining <= 0) && (updatedObject.status != skuCompleteStatus))  //Add record to datatable if pack is complete
                        {
                            updatedObject.status = skuCompleteStatus;
    
                            //updatedTable.Rows[1][1] = updatedObject.primkey;
                            //updatedTable.Rows[1][2] = updatedObject.orderNr;
                            //updatedTable.Rows[0][1] = updatedObject.waveNo;
    
                            //object updated = object.(updatedObject); //This is the "object"
    
                            updatedTable.Rows.Add(updatedObject);
    
                            message = ("Order Nr " + updatedObject.orderNr + " with HuNr " + updatedObject.huNr + " has been packed complete");
                            LogFiles.EventLogHandler.WriteEvent("3 ; " + this + " ; " + message);
                            Console.WriteLine(message);
                        }
                        recordCounter++;
    
                        if (updatedTable.Rows.Count == 0)
                        {
                            message = ("Order Nr " + updatedObject.orderNr + " and Hunr " + updatedObject.huNr + " not completed");
                            LogFiles.EventLogHandler.WriteEvent("3 ; " + this + " ; " + message);
                            Console.WriteLine(message);
                        }
                    }
                }
                catch (Exception e)
                {
                    LogFiles.ExceptionLogger.WriteException(e);
                }           
                return updatedTable;
            }
        }  
    namespace WCS_Shared.Databases.Symbols
    {
        public class tb_ProdTableSqlSymbols
        {
            public int primkey;
            public string orderNr;
            public int waveNo;
            public string pigeonLocation;
            public string cartonID;
            public string huNr;
            public bool isGolden;
            public string skuNr;
            public int unitQty;
            public int unitPacked;
            public int unitRemaining;
            public int consignmentSize;
            public DateTime createdDate;
            public int status;
    
            public tb_ProdTableSqlSymbols()
            {
                 int Primkey = 0;
                primkey = Primkey;
                string OrderNr = "";
                orderNr = OrderNr;
                int WaveNo = 0;
                waveNo = WaveNo;
                string PigeonLocation = "";
                pigeonLocation = PigeonLocation;
                string CartonID = "";
                cartonID = CartonID;
                string HuNr = "";
                huNr = HuNr;
                bool IsGolden = false;
                isGolden = IsGolden;
                 string SkuNr = "";
                skuNr = SkuNr;
                int UnitQty = 0;
                unitQty = UnitQty;
                int UnitPacked = 0;
                unitPacked = UnitPacked;
                int UnitRemaining = 0;
                unitRemaining = UnitRemaining;
                int ConsignmentSize = 0;
                consignmentSize = ConsignmentSize;
                int Status = 0;
                status = Status;
            }
        }



    labjac

    Monday, July 6, 2020 1:13 PM
  • Hallo Karen

    Agree Clone will work, but still not sure how to get the values from the Object in to the table.

    :-(


    labjac

    Monday, July 6, 2020 1:14 PM
  • Hallo Karen

    Agree Clone will work, but still not sure how to get the values from the Object in to the table.

    :-(


    labjac

    Do each row as follows DataTable.ImportRow.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, July 6, 2020 1:31 PM
  • Hallo Karen

    Thanks, I created a Clone from the original datatable, this part is sorted, but now how do I get the data into one Row at each of the columns back into the Datatable? (Structure is good).


    labjac

    Monday, July 6, 2020 1:31 PM
  • Hallo

    Thanks for the assistance this far, but need to find another way of doing the below.

    There must be a way to iterate through the object and assign values to each of the columns in the same row without assigning one by one...


    labjac

    Monday, July 6, 2020 2:45 PM
  • Hi labjac,

    I think what you really should do is to use a Typed DataSet (which is defined by XML in an .xsd file). I don't know what your tb_ProdTableSqlSymbols class looks like, but you'd want the XML in an .xsd to look similar to that. Once you've defined an .xsd and added it to your project, you'd get a Typed DataSet that you could use instead of having to redefine the UpdatedTable every time.

    My blog post (https://geek-goddess-bonnie.blogspot.com/2010/04/create-xsd.html) explains how to do this, although the creation of the .xsd file you'll probably have to do yourself by hand. My blog post does it by connecting to a database and running a query to fill a DataSet/DataTable that then gets saved as an .xsd. Your Orders table would benefit from using a Typed DataSet too.


    Then, your code would look like this (depending on how you've named your the DataSet and DataTable in both of your .xsd's). I think that I've managed to BOLD all the things I changed:

    private ProdDataSet.Prod CalculateUnitsRequired(OrdersDataSet.Orders Orders)
    {
        ProdDataSet dsProd = new ProdDataSet();
        ProdDataSet.ProdRow updatedRows; 
        int skuCompleteStatus = 5;
        string message = "";
        //var updatedTable = new DataTable();            
        int recordCounter = 0;
        
        try
        {
            foreach (var dr in Orders)
            {
                updatedRows = dsProd.Prod.NewProdRow();
                
                // assuming the same datatypes, and assuming you're going to use a 
                // Typed DataSet for your Orders too, you don't have to use Convert here
                updatedRows.primkey = dr.OrderPK; // or whatever the column is called 
                updatedRows.orderNr = dr.OrderNumber; // again, whatever the column is called
                
                // If you choose to not used Typed DataSet for your Orders, then continue doing it the old way
                updatedRows.waveNo = Convert.ToInt32(Orders.Rows[recordCounter][2]);
                updatedRows.pigeonLocation = Orders.Rows[recordCounter][3].ToString();
                updatedRows.cartonID = Orders.Rows[recordCounter][4].ToString();
                updatedRows.huNr = Orders.Rows[recordCounter][5].ToString();
                updatedRows.isGolden = Convert.ToBoolean(Orders.Rows[recordCounter][6]);
                updatedRows.skuNr = Orders.Rows[recordCounter][7].ToString();
                updatedRows.unitQty = Convert.ToInt32(Orders.Rows[recordCounter][8]);
                updatedRows.unitPacked = Convert.ToInt32(Orders.Rows[recordCounter][9]);
                updatedRows.unitRemaining = Convert.ToInt32((updatedRows.unitQty - updatedRows.unitPacked)); //Calculate if packs left
                updatedRows.consignmentSize = Convert.ToInt32(Orders.Rows[recordCounter][11]);
                updatedRows.createdDate = Convert.ToDateTime(Orders.Rows[recordCounter][12]);
                updatedRows.status = Convert.ToInt32(Orders.Rows[recordCounter][13]);
    
                if ((updatedRows.unitRemaining <= 0) && (updatedRows.status != skuCompleteStatus))  //Add record to datatable if pack is complete
                {
                    updatedRows.status = skuCompleteStatus;                        
                    dsProd.Prod.AddProdRow(updatedRows); 
    
                    message = ("Order Nr " + updatedRows.orderNr + " with HuNr " + updatedRows.huNr + " has been packed complete");
                    LogFiles.EventLogHandler.WriteEvent("3 ; " + this + " ; " + message);
                    Console.WriteLine(message);
                }
                recordCounter++;
    
                if (dsProd.Prod.Count == 0)
                {
                    message = ("Order Nr " + updatedRows.orderNr + " haven't got completed HuNr packed");
                    LogFiles.EventLogHandler.WriteEvent("3 ; " + this + " ; " + message);
                    Console.WriteLine(message);
                }
            }
        }
        catch (Exception e)
        {
            LogFiles.ExceptionLogger.WriteException(e);
        }           
        return dsProd.Prod;
    }



    ~~Bonnie DeWitt [C# MVP]

    http://geek-goddess-bonnie.blogspot.com

    Monday, July 6, 2020 4:31 PM
  • Hi labjac,
    Here is a simple code example about saving array to DataTable and you can refer to it.

    string[] myResult = {"Student" , "Daneil" , "5.5" , "7.5" , "6.5"};
    DataTable dt = new DataTable();
    dt.Columns.Add("Category");
    dt.Columns.Add("Name");
    dt.Columns.Add("Score 1");
    dt.Columns.Add("Score 2");
    dt.Columns.Add("Score 3");
    DataRow row = dt.NewRow();
    
    for (int i = 0; i < myResult.Length; i++)
    {
        row[i] = myResult[i];       
    }
    
    dt.Rows.Add(row);

    Here are some similar threads you can refer to.
    [from array to datatable]
    [How to save array to DataTable?]
    Hope these could be helpful.
    Best Regards,
    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, July 7, 2020 8:07 AM
  • private DataTable CalculateUnitsRequired(DataTable Orders)
            {
                var updatedObject = new tb_ProdTableSqlSymbols();
                int skuCompleteStatus = 5;
                string message = "";
                var updatedTable = new DataTable();
                int recordCounter = 0;
    
                updatedTable.Columns.Add("Primkey", typeof(int));
                updatedTable.Columns.Add("OrderNr", typeof(string));
                updatedTable.Columns.Add("WaveNr", typeof(string));
                updatedTable.Columns.Add("PigeonLocation", typeof(string));
                updatedTable.Columns.Add("CartonID", typeof(string));
                updatedTable.Columns.Add("HuNr", typeof(string));
                updatedTable.Columns.Add("IsGolden", typeof(bool));
                updatedTable.Columns.Add("SkuNr", typeof(string));
                updatedTable.Columns.Add("UnitQty", typeof(int));
                updatedTable.Columns.Add("UnitPacked", typeof(int));
                updatedTable.Columns.Add("UnitRemaining", typeof(int));
                updatedTable.Columns.Add("ConsignmentSize", typeof(int));
                updatedTable.Columns.Add("CreatedDateTime", typeof(DateTime));
                updatedTable.Columns.Add("Status", typeof(int));       
                
                
                try
                {
                    foreach (DataRow dr in Orders.Rows)
                    {
    			DataRow trow = updatedTable.NewRow();
    			trow[0] = dr["Primkey"];
    			trow[1] = dr["orderNr"];
    			.
    			.
    			 updatedTable.Rows.add(trow);                   
    			// your logic bellow why used updateObject
    
    		    updatedObject.primkey = Convert.ToInt32(Orders.Rows[recordCounter][0]);
                        updatedObject.orderNr = Orders.Rows[recordCounter][1].ToString();
                        updatedObject.waveNo = Convert.ToInt32(Orders.Rows[recordCounter][2]);
                        updatedObject.pigeonLocation = Orders.Rows[recordCounter][3].ToString();
                        updatedObject.cartonID = Orders.Rows[recordCounter][4].ToString();
                        updatedObject.huNr = Orders.Rows[recordCounter][5].ToString();
                        updatedObject.isGolden = Convert.ToBoolean(Orders.Rows[recordCounter][6]);
                        updatedObject.skuNr = Orders.Rows[recordCounter][7].ToString();
                        updatedObject.unitQty = Convert.ToInt32(Orders.Rows[recordCounter][8]);
                        updatedObject.unitPacked = Convert.ToInt32(Orders.Rows[recordCounter][9]);
                        updatedObject.unitRemaining = Convert.ToInt32((updatedObject.unitQty - updatedObject.unitPacked)); //Calculate if packs left
                        updatedObject.consignmentSize = Convert.ToInt32(Orders.Rows[recordCounter][11]);
                        updatedObject.createdDate = Convert.ToDateTime(Orders.Rows[recordCounter][12]);
                        updatedObject.status = Convert.ToInt32(Orders.Rows[recordCounter][13]);
    
                        if ((updatedObject.unitRemaining <= 0) && (updatedObject.status != skuCompleteStatus))  //Add record to datatable if pack is complete
                        {
                            updatedObject.status = skuCompleteStatus;
    
                            //updatedTable.Rows[1][1] = updatedObject.primkey;
                            //updatedTable.Rows[1][2] = updatedObject.orderNr;
                            //updatedTable.Rows[0][1] = updatedObject.waveNo;
    
                            //object updated = object.(updatedObject); //This is the "object"
    
                            updatedTable.Rows.Add(updatedObject);
    
                            message = ("Order Nr " + updatedObject.orderNr + " with HuNr " + updatedObject.huNr + " has been packed complete");
                            LogFiles.EventLogHandler.WriteEvent("3 ; " + this + " ; " + message);
                            Console.WriteLine(message);
                        }
                        recordCounter++;
    
                        if (updatedTable.Rows.Count == 0)
                        {
                            message = ("Order Nr " + updatedObject.orderNr + " and Hunr " + updatedObject.huNr + " not completed");
                            LogFiles.EventLogHandler.WriteEvent("3 ; " + this + " ; " + message);
                            Console.WriteLine(message);
                        }
                    }
                }
                catch (Exception e)
                {
                    LogFiles.ExceptionLogger.WriteException(e);
                }           
                return updatedTable;
            }
        }  

    Tuesday, July 7, 2020 4:55 PM
  • Hallo

    Thanks, I was hoping there is a way to iterate though the values in a object, and just assign values based on the for loop, but looking at all the examples and answers above there is no "lazy" way.. :-)

    below is what we've done, it works just a bit longer then we wished for.

     try
                {
                    foreach (DataRow dr in rawHuNr.Rows)
                    {
                        currentHuObject = HuTableToObject(rawHuNr, rowCounter);
    
                        if ((currentHuObject.unitRemaining <= 0) && (currentHuObject.status != skuCompleteStatus))  //Add record to datatable if pack is complete
                        {
                            currentHuObject.status = skuCompleteStatus;
                            dt.Rows.Add();
                            dt.Rows[doneCounter][0] = currentHuObject.primkey;
                            dt.Rows[doneCounter][1] = currentHuObject.orderNr;
                            dt.Rows[doneCounter][2] = currentHuObject.waveNo;
                            dt.Rows[doneCounter][3] = currentHuObject.pigeonLocation;
                            dt.Rows[doneCounter][4] = currentHuObject.cartonID;
                            dt.Rows[doneCounter][5] = currentHuObject.huNr;
                            dt.Rows[doneCounter][6] = currentHuObject.isGolden;
                            dt.Rows[doneCounter][7] = currentHuObject.skuNr;
                            dt.Rows[doneCounter][8] = currentHuObject.unitQty;
                            dt.Rows[doneCounter][9] = currentHuObject.unitPacked;
                            dt.Rows[doneCounter][10] = currentHuObject.unitRemaining;
                            dt.Rows[doneCounter][11] = currentHuObject.consignmentSize;
                            dt.Rows[doneCounter][12] = currentHuObject.createdDate;
                            dt.Rows[doneCounter][13] = currentHuObject.status;
                            dt.Rows[doneCounter][14] = currentHuObject.modifiedDateTime;
    
                            message = ("Order Number " + currentHuObject.orderNr + " with HuNr " + currentHuObject.huNr +
                                        " status set to " + currentHuObject.status + " Completed");
                            LogFiles.EventLogHandler.WriteEvent("3 ; " + this + " ; " + message);
                            Console.WriteLine(message);
                            doneCounter++;
                        }
                        else
                        {



    labjac

    • Marked as answer by labjac Wednesday, July 8, 2020 10:39 AM
    Wednesday, July 8, 2020 10:39 AM