Example #1
0
 private void bwLoadData_DoWork(object sender, DoWorkEventArgs e)
 {
     outsoleMaterialRejectList = OutsoleMaterialController.SelectReject();
     outsoleSupplierList       = OutsoleSuppliersController.Select();
     orderList = OrdersController.SelectByOutsoleMaterialReject();
     outsoleRawMaterialList = OutsoleRawMaterialController.Select();
 }
        private void bwLoadData_DoWork(object sender, DoWorkEventArgs e)
        {
            outsoleMaterialRejectList = OutsoleMaterialController.SelectReject();
            outsoleSupplierList       = OutsoleSuppliersController.Select();
            orderList = OrdersController.SelectByOutsoleMaterialReject();
            outsoleRawMaterialList = OutsoleRawMaterialController.Select();
            sizeRunList            = SizeRunController.SelectIsEnable();
            def = PrivateDefineController.GetDefine();

            DataTable dt  = new OutsoleMaterialRejectDataSet().Tables["OutsoleMaterialRejectTable"];
            DataTable dt1 = new OutsoleMaterialRejectDataSet().Tables["OutsoleMaterialRejectTable"];

            var regex = new Regex(@"[a-z]|[A-Z]");

            foreach (OutsoleMaterialModel outsoleMaterialReject in outsoleMaterialRejectList)
            {
                var     outsoleSupplier    = outsoleSupplierList.FirstOrDefault(f => f.OutsoleSupplierId == outsoleMaterialReject.OutsoleSupplierId);
                var     order              = orderList.FirstOrDefault(f => f.ProductNo == outsoleMaterialReject.ProductNo);
                var     outsoleRawMaterial = outsoleRawMaterialList.FirstOrDefault(f => f.ProductNo == outsoleMaterialReject.ProductNo && f.OutsoleSupplierId == outsoleMaterialReject.OutsoleSupplierId);
                DataRow dr  = dt.NewRow();
                DataRow dr1 = dt1.NewRow();

                dr["ProductNo"]  = outsoleMaterialReject.ProductNo;
                dr1["ProductNo"] = outsoleMaterialReject.ProductNo;
                var productNoList = new List <String>();
                if (order != null)
                {
                    dr["OutsoleCode"]  = order.OutsoleCode;
                    dr1["OutsoleCode"] = order.OutsoleCode;
                    dr["ETD"]          = order.ETD;
                    dr1["ETD"]         = order.ETD;
                    dr["ArticleNo"]    = order.ArticleNo;
                    dr1["ArticleNo"]   = order.ArticleNo;
                    productNoList      = orderList.Where(w => w.OutsoleCode == order.OutsoleCode).Select(s => s.ProductNo).ToList();
                }
                if (outsoleRawMaterial != null)
                {
                    dr["SupplierETD"]  = outsoleRawMaterial.ETD;
                    dr1["SupplierETD"] = outsoleRawMaterial.ETD;
                }
                if (outsoleSupplier != null)
                {
                    dr["OutsoleSupplier"]  = outsoleSupplier.Name;
                    dr1["OutsoleSupplier"] = outsoleSupplier.Name;
                }

                string sizeNoOutsole      = outsoleMaterialReject.SizeNo;
                var    sizeNo_OutsoleCode = sizeRunList.Where(w => productNoList.Contains(w.ProductNo) && w.SizeNo == sizeNoOutsole).FirstOrDefault();
                if (sizeNo_OutsoleCode != null)
                {
                    if (String.IsNullOrEmpty(sizeNo_OutsoleCode.OutsoleSize) == false)
                    {
                        sizeNoOutsole = sizeNo_OutsoleCode.OutsoleSize;
                    }
                }

                string sizeNoString = regex.IsMatch(sizeNoOutsole) == true?regex.Replace(sizeNoOutsole, "") : sizeNoOutsole;

                double sizeNoDouble = 0;
                Double.TryParse(sizeNoString, out sizeNoDouble);
                dr["SizeNoDouble"]  = sizeNoDouble;
                dr1["SizeNoDouble"] = sizeNoDouble;

                dr["SizeNo"]  = outsoleMaterialReject.SizeNo;
                dr1["SizeNo"] = outsoleMaterialReject.SizeNo;
                if (def.ShowOSSizeValue)
                {
                    dr["SizeOutsole"]  = sizeNoOutsole;
                    dr1["SizeOutsole"] = sizeNoOutsole;
                }


                if (outsoleMaterialReject.QuantityReject > 0)
                {
                    dr["QuantityReject"] = outsoleMaterialReject.QuantityReject;
                    dt.Rows.Add(dr);
                }

                if (outsoleMaterialReject.RejectAssembly > 0)
                {
                    dr1["QuantityReject"] = outsoleMaterialReject.RejectAssembly;
                    dt1.Rows.Add(dr1);
                }
            }
            dtRejectAssemblyStockfit = dt1;
            e.Result = dt;
        }