void threadLoad_DoWork(object sender, DoWorkEventArgs e)
        {
            orderList          = OrdersController.SelectFull(etdStart, etdEnd);
            sewingMasterList   = SewingMasterController.SelectFull(etdStart, etdEnd);
            outsoleMasterList  = OutsoleMasterController.SelectFull(etdStart, etdEnd);
            assemblyMasterList = AssemblyMasterController.SelectFull(etdStart, etdEnd);
            orderExtraList     = OrderExtraController.SelectFull(etdStart, etdEnd);

            List <String> productNoList = sewingMasterList.Select(r => r.ProductNo).Distinct().ToList();

            foreach (string productNo in productNoList)
            {
                var order = orderList.FirstOrDefault(f => f.ProductNo == productNo);

                //var order1 = orderList.Where(w => w.ProductNo == productNo).FirstOrDefault();

                var sewingMaster   = sewingMasterList.FirstOrDefault(f => f.ProductNo == productNo);
                var outsoleMaster  = outsoleMasterList.FirstOrDefault(f => f.ProductNo == productNo);
                var assemblyMaster = assemblyMasterList.FirstOrDefault(f => f.ProductNo == productNo);
                var orderExtra     = orderExtraList.FirstOrDefault(f => f.ProductNo == productNo);

                CompletionStatusViewModel completionStatusView = new CompletionStatusViewModel
                {
                    ProductNo   = order.ProductNo,
                    Country     = order.Country,
                    ShoeName    = order.ShoeName,
                    ArticleNo   = order.ArticleNo,
                    OutsoleCode = order.OutsoleCode,
                    ETD         = order.ETD,
                    Quantity    = order.Quantity,
                };

                if (orderExtra != null)
                {
                    DateTime loadingDate = dtDefault;
                    if (DateTime.TryParse(orderExtra.LoadingDate, out loadingDate) == true)
                    {
                        completionStatusView.LoadingDate = string.Format(new CultureInfo("en-US"), "{0:dd-MMM}", loadingDate);
                    }
                    else
                    {
                        completionStatusView.LoadingDate = "";
                    }
                }

                if (sewingMaster != null)
                {
                    completionStatusView.SewingLine           = sewingMaster.SewingLine;
                    completionStatusView.CutAFinishDate       = sewingMaster.CutBBalance;
                    completionStatusView.CutAActualFinishDate = TimeHelper.ConvertDateToView(sewingMaster.CutAActualFinishDate);
                    completionStatusView.SewingFinishDate     = sewingMaster.SewingActualFinishDate;

                    if (string.IsNullOrEmpty(sewingMaster.SewingActualFinishDate.Trim()) == true)
                    {
                        completionStatusView.SewingFinishDate = sewingMaster.SewingBalance;
                    }
                }
                else
                {
                    completionStatusView.SewingLine           = "";
                    completionStatusView.CutAFinishDate       = "";
                    completionStatusView.CutAActualFinishDate = "";
                    completionStatusView.SewingFinishDate     = "";
                }

                if (outsoleMaster != null)
                {
                    completionStatusView.OutsoleLine       = outsoleMaster.OutsoleLine;
                    completionStatusView.OutsoleFinishDate = outsoleMaster.OutsoleActualFinishDate;
                    if (string.IsNullOrEmpty(outsoleMaster.OutsoleActualFinishDate.Trim()) == true)
                    {
                        completionStatusView.OutsoleFinishDate = outsoleMaster.OutsoleBalance;
                    }
                }
                else
                {
                    completionStatusView.OutsoleLine       = "";
                    completionStatusView.OutsoleFinishDate = "";
                }

                completionStatusView.IsFinished = false;
                if (assemblyMaster != null)
                {
                    completionStatusView.AssemblyLine       = assemblyMaster.AssemblyLine;
                    completionStatusView.AssemblyFinishDate =
                        assemblyMaster.AssemblyActualFinishDate.Contains("/")? TimeHelper.ConvertDateToView(assemblyMaster.AssemblyActualFinishDate)
                        : assemblyMaster.AssemblyActualFinishDate;

                    if (string.IsNullOrEmpty(assemblyMaster.AssemblyActualFinishDate.Trim()) == true)
                    {
                        completionStatusView.AssemblyFinishDate = assemblyMaster.AssemblyBalance;
                    }

                    if (string.IsNullOrEmpty(assemblyMaster.AssemblyActualFinishDate.Trim()) == false || assemblyMaster.AssemblyBalance.ToLower() == "OK".ToLower())
                    {
                        completionStatusView.IsFinished = true;
                    }
                }
                else
                {
                    completionStatusView.AssemblyLine       = "";
                    completionStatusView.AssemblyFinishDate = "";
                }
                completionStatusViewList.Add(completionStatusView);
            }
        }
        void threadLoad_DoWork(object sender, DoWorkEventArgs e)
        {
            //outsoleRawMaterialList = OutsoleRawMaterialController.Select();
            outsoleRawMaterialList = OutsoleRawMaterialController.SelectFull(etdStartSelect, etdEndSelect);
            outsoleMaterialList    = OutsoleMaterialController.SelectByOutsoleRawMaterialFull(etdStartSelect, etdEndSelect);
            sizeRunList            = SizeRunController.SelectByOutsoleRawMaterialFull(etdStartSelect, etdEndSelect);
            outsoleSupplierList    = OutsoleSuppliersController.Select();
            orderList        = OrdersController.SelectByOutsoleRawMaterialFull(etdStartSelect, etdEndSelect);
            sewingMasterList = SewingMasterController.SelectFull(etdStartSelect, etdEndSelect);

            List <String> productNoList = outsoleRawMaterialList.Select(r => r.ProductNo).Distinct().ToList();

            foreach (string productNo in productNoList)
            {
                OrdersModel order = orderList.FirstOrDefault(f => f.ProductNo == productNo);
                List <OutsoleRawMaterialModel> outsoleRawMaterialList_D1 = outsoleRawMaterialList.Where(o => o.ProductNo == productNo).ToList();
                List <SizeRunModel>            sizeRunList_D1            = sizeRunList.Where(s => s.ProductNo == productNo).ToList();
                List <OutsoleMaterialModel>    outsoleMaterialList_D1    = outsoleMaterialList.Where(o => o.ProductNo == productNo).ToList();
                var sewingMasterList_D1 = sewingMasterList.Where(w => w.ProductNo == productNo).ToList();
                foreach (OutsoleRawMaterialModel outsoleRawMaterial in outsoleRawMaterialList_D1)
                {
                    // 108a-2279
                    //bool isFull = OutsoleRawMaterialController.IsFull(sizeRunList_D1, new List<OutsoleRawMaterialModel>() { outsoleRawMaterial, }, outsoleMaterialList_D1);
                    if (
                        //isFull == false &&
                        outsoleRawMaterial.ETD.Date != dtDefault
                        //&& outsoleRawMaterial.ActualDate.Date == dtDefault
                        )
                    {
                        OutsoleDeliveryStatusViewModel outsoleDeliveryStatusView = new OutsoleDeliveryStatusViewModel();
                        outsoleDeliveryStatusView.ProductNo = productNo;
                        if (order != null)
                        {
                            outsoleDeliveryStatusView.Country     = order.Country;
                            outsoleDeliveryStatusView.ShoeName    = order.ShoeName;
                            outsoleDeliveryStatusView.ArticleNo   = order.ArticleNo;
                            outsoleDeliveryStatusView.OutsoleCode = order.OutsoleCode;
                            outsoleDeliveryStatusView.Quantity    = order.Quantity;
                            outsoleDeliveryStatusView.ETD         = order.ETD;
                        }

                        OutsoleSuppliersModel outsoleSupplier = outsoleSupplierList.FirstOrDefault(f => f.OutsoleSupplierId == outsoleRawMaterial.OutsoleSupplierId);
                        if (outsoleSupplier != null)
                        {
                            outsoleDeliveryStatusView.Supplier = outsoleSupplier.Name;
                        }

                        outsoleDeliveryStatusView.SupplierETD = outsoleRawMaterial.ETD;
                        //outsoleDeliveryStatusView.Actual = sizeRunList_D1.Sum(s => (s.Quantity - outsoleMaterialList_D1.Where(o => o.OutsoleSupplierId == outsoleRawMaterial.OutsoleSupplierId && o.SizeNo == s.SizeNo).Sum(o => (o.Quantity - o.QuantityReject)))).ToString();

                        //int actualQty = sizeRunList_D1.Sum(s => (outsoleMaterialList_D1.Where(o => o.OutsoleSupplierId == outsoleRawMaterial.OutsoleSupplierId && o.SizeNo == s.SizeNo).Sum(o => (o.Quantity - o.QuantityReject))));
                        //int actualQty = outsoleMaterialList_D1.Where(w => w.OutsoleSupplierId == outsoleRawMaterial.OutsoleSupplierId).Sum(s => s.Quantity - s.QuantityReject);
                        int actualQty = outsoleMaterialList_D1.Where(w => w.OutsoleSupplierId == outsoleRawMaterial.OutsoleSupplierId).Sum(s => s.Quantity);
                        if (actualQty > 0)
                        {
                            outsoleDeliveryStatusView.ActualQuantity = actualQty.ToString();
                        }

                        int rejectQty = outsoleMaterialList_D1.Where(w => w.OutsoleSupplierId == outsoleRawMaterial.OutsoleSupplierId).Sum(s => s.QuantityReject);
                        if (rejectQty > 0)
                        {
                            outsoleDeliveryStatusView.RejectQuantity = rejectQty.ToString();
                        }

                        outsoleDeliveryStatusView.IsFinished = true;
                        int balance = order.Quantity - actualQty + rejectQty;
                        if (balance > 0)
                        {
                            //outsoleDeliveryStatusView.Balance = balance.ToString();
                            outsoleDeliveryStatusView.IsFinished = false;
                        }

                        if (outsoleRawMaterial.ActualDate != dtDefault)
                        {
                            outsoleDeliveryStatusView.Actual = string.Format("{0:M/d}", outsoleRawMaterial.ActualDate);
                        }

                        outsoleDeliveryStatusView.SewingStartDate = dtDefault;
                        var sewingMasterModel = sewingMasterList_D1.FirstOrDefault();
                        if (sewingMasterModel != null)
                        {
                            outsoleDeliveryStatusView.SewingStartDate = sewingMasterModel.SewingStartDate;
                        }

                        outsoleDeliveryStatusViewList.Add(outsoleDeliveryStatusView);
                    }
                }
            }
        }