Пример #1
0
 public static bool IsPOCompleted(EMDataSet.POHeaderTblRow headerRow,
     ref TreeNode headerNode,IsContainerBundleCompleted isBundleCompleted,
     int percentageRequired)
 {
     EMDataSet emDataSet = (EMDataSet)headerRow.Table.DataSet;
     bool isMetric = DataInterface.IsMetric(headerRow);
     int completed = 0;
     int total = 0;
     EMDataSet.BalanceRptPORow newBalancePORow = emDataSet.BalanceRptPO.NewBalanceRptPORow();
     newBalancePORow.POID = headerRow.POID;
     newBalancePORow.PONumber = headerRow.PONumber;
     foreach (EMDataSet.POItemTblRow itemRow in headerRow.GetPOItemTblRows())
     {
         EMDataSet.BalanceRtpPOItemRow newBalancePOItemRow = emDataSet.BalanceRtpPOItem.NewBalanceRtpPOItemRow();
         newBalancePOItemRow.POID = headerRow.POID;
         newBalancePOItemRow.POItemNumber = itemRow.POItemNumber;
         newBalancePOItemRow["SizeOfITem"] = itemRow["SizeOfItem"];
         newBalancePOItemRow.Grade = HelperFunctions.GetItemName(itemRow);
         TreeNode poItemNode = new TreeNode();
         if (itemRow.IsQtyNull() || itemRow.Qty == 0)
             continue;
         ++total;
         decimal totalQty = itemRow.Qty;
         decimal totalQtyInClosedContainers = 0;
         string select = "POItemNumber = " + itemRow.POItemNumber.ToString();
         EMDataSet.ContBundleTblRow[] bundleRows = (EMDataSet.ContBundleTblRow[])
                         emDataSet.ContBundleTbl.Select(select);
         ArrayList listOfContIDs = new ArrayList();
         foreach (EMDataSet.ContBundleTblRow bundleRow in bundleRows)
         {
             listOfContIDs.Add(bundleRow.ContID);
         }
         AdapterHelper.Unique(ref listOfContIDs);
         foreach (int contID in listOfContIDs)
         {
             EMDataSet.ContainerTblRow contRow =
                 emDataSet.ContainerTbl.FindByContID(contID);
             decimal totalCompletedInContainer = 0;
             TreeNode containerNode = new TreeNode();
             foreach (EMDataSet.ContBundleTblRow bundleRow in bundleRows)
             {
                 if (bundleRow.ContID != contID)
                     continue;
                 decimal bundleQty = 0;
                 if (isMetric && !bundleRow.IsMetricShipQtyNull())
                     bundleQty = bundleRow.MetricShipQty;
                 else
                     if (!bundleRow.IsEnglishShipQtyNull())
                         bundleQty = bundleRow.EnglishShipQty;
                 decimal percentage = 100*bundleQty / totalQty;
                 string bundleDesc = "Bundle " + bundleRow.BundleSeqNumber +
                                     ": " + bundleQty.ToString("N0") +
                                     ": " + percentage.ToString("N2") + "%";
                 if (isBundleCompleted(bundleRow))
                 {
                     if (isMetric && !bundleRow.IsMetricShipQtyNull())
                     {
                         totalCompletedInContainer += bundleRow.MetricShipQty;
                     }
                     if (!isMetric && !bundleRow.IsEnglishShipQtyNull())
                     {
                         totalCompletedInContainer += bundleRow.EnglishShipQty;
                     }
                     bundleDesc += " (Completed)";
                 }
                 else
                     bundleDesc += " (Not completed)";
                 TreeNode bundleNode = new TreeNode(bundleDesc);
                 bundleNode.Tag = new POCompletedNodeTag(headerRow.POID,contID);
                 containerNode.Nodes.Add(bundleNode);
             }
             totalQtyInClosedContainers += totalCompletedInContainer;
             decimal percentageInContainer = 100*
                 totalCompletedInContainer / totalQty;
             containerNode.Text = "Container: " + contRow.ContNumber +
                                  " " + totalCompletedInContainer.ToString("N0")
                                 + " " + percentageInContainer.ToString("N2") + "%";
             containerNode.Tag = new POCompletedNodeTag(headerRow.POID, contID);
             poItemNode.Nodes.Add(containerNode);
         }
         decimal itemPercentage = totalQtyInClosedContainers / totalQty * 100;
         poItemNode.Text = "Row:" + itemRow.SeqNumber.ToString() + " " +
                             HelperFunctions.GetItemName(itemRow) +
                          " " + totalQtyInClosedContainers.ToString("N0") + " out of " +
                               itemRow.Qty.ToString("N0") +
                          " " + itemPercentage.ToString("N2") + "%";
         poItemNode.Tag = new POCompletedNodeTag(headerRow.POID, -1);
         if (itemPercentage >= percentageRequired)
         {
             completed++;
             newBalancePOItemRow.FinishedItem = 1;
         }
         newBalancePOItemRow.ClosedPercent = itemPercentage;
         newBalancePOItemRow.ClosedCount = totalQtyInClosedContainers;
         newBalancePOItemRow.TotalCount = totalQty;
         newBalancePOItemRow["UM"] = itemRow["UM"];
         emDataSet.BalanceRtpPOItem.AddBalanceRtpPOItemRow(newBalancePOItemRow);
         headerNode.Tag = new POCompletedNodeTag(headerRow.POID, -1);
         headerNode.Nodes.Add(poItemNode);
     }
     headerNode.Text = headerRow.PONumber;
     if (completed != total)
     {
         headerNode.Text += "(" + completed.ToString() + "/" + total.ToString();
     }
     newBalancePORow.ClosedCount = completed;
     newBalancePORow.TotalCount = total;
     if (completed == total)
         newBalancePORow.FinishedPO = 1;
     emDataSet.BalanceRptPO.AddBalanceRptPORow(newBalancePORow);
     return completed==total;
 }
Пример #2
0
 public static bool IsMetric(EMDataSet.POHeaderTblRow headerRow)
 {
     foreach (EMDataSet.POItemTblRow row in headerRow.GetPOItemTblRows())
     {
         if (!DataInterface.IsRowAlive(row))
             continue;
         if (!row.IsUMNull())
             return IsMetric(row);
     }
     return DefaultMetric;
 }