Пример #1
0
 private void bwInsert_DoWork(object sender, DoWorkEventArgs e)
 {
     foreach (SewingOutputModel model in sewingOutputToInsertList)
     {
         SewingOutputController.Insert(model);
     }
 }
 private void bwLoadData_DoWork(object sender, DoWorkEventArgs e)
 {
     assemblyReleaseAllList = AssemblyReleaseController.Select(reportId, null);
     orderAllList           = OrdersController.SelectByAssemblyRelease(reportId);
     sewingOutputAllList    = SewingOutputController.SelectByAssemblyRelease(reportId);
     outsoleOutputAllList   = OutsoleOutputController.SelectByAssemblyRelease(reportId);
     sizeRunAllList         = SizeRunController.SelectByAssemblyRelease(reportId);
 }
        private void bwAddMore_DoWork(object sender, DoWorkEventArgs e)
        {
            string productNo = "";

            txtProductNo.Dispatcher.Invoke((Action)(() =>
            {
                productNo = txtProductNo.Text;
            }));
            orderSearch               = OrdersController.SelectTop1(productNo);
            sizeRunSearchList         = SizeRunController.Select(productNo);
            assemblyReleaseSearchList = AssemblyReleaseController.Select(productNo);
            sewingOutputSearchList    = SewingOutputController.Select(productNo);
            outsoleOutputSearchList   = OutsoleOutputController.Select(productNo);
        }
        private void bwLoadData_DoWork(object sender, DoWorkEventArgs e)
        {
            assemblyMasterList          = AssemblyMasterController.Select();
            sewingOutputList            = SewingOutputController.SelectByAssemblyMaster();
            outsoleOutputList           = OutsoleOutputController.SelectByAssemblyMaster();
            assemblyReleaseList         = AssemblyReleaseController.SelectByAssemblyMaster();
            orderList                   = OrdersController.Select();
            sockliningInputList         = SockliningInputController.SelectByAssemblyMaster();
            sizeRunList                 = SizeRunController.SelectIsEnable();
            rawMaterialViewModelNewList = RawMaterialController.Select_1();

            List <UpperWHInventoryViewModel> upperWHInventoryList   = new List <UpperWHInventoryViewModel>();
            List <UpperWHInventoryViewModel> upperWHInventoryList_1 = new List <UpperWHInventoryViewModel>();
            var POList = orderList.Select(s => s.ProductNo).Distinct().ToList();

            foreach (var productNo in POList)
            {
                var assemblyMaster_PO  = assemblyMasterList.FirstOrDefault(w => w.ProductNo == productNo);
                var assemblyRelease_PO = assemblyReleaseList.Where(w => w.ProductNo == productNo).ToList();
                var sewingOutput_PO    = sewingOutputList.Where(w => w.ProductNo == productNo).ToList();
                var outsoleOutput_PO   = outsoleOutputList.Where(w => w.ProductNo == productNo).ToList();
                var sockliningInput_PO = sockliningInputList.Where(w => w.ProductNo == productNo).ToList();
                var sizeNoList         = sizeRunList.Where(w => w.ProductNo == productNo).Select(s => s.SizeNo).ToList();

                int qtyUpper_PO = 0, qtyOutsole_PO = 0, qtySocklining_PO = 0, qtyMatch_PO = 0, qtyMatchWithSocklining_PO = 0;
                foreach (var sizeNo in sizeNoList)
                {
                    int qtyAssemblyRelease_Size = assemblyRelease_PO.Where(w => w.SizeNo == sizeNo).Sum(s => s.Quantity);
                    int qtySewingOutput_Size    = sewingOutput_PO.Where(w => w.SizeNo == sizeNo).Sum(s => s.Quantity);
                    int qtyOutsoleOutput_Size   = outsoleOutput_PO.Where(w => w.SizeNo == sizeNo).Sum(s => s.Quantity);
                    int qtySocklining_Size      = sockliningInput_PO.Where(w => w.SizeNo == sizeNo).Sum(s => s.Quantity);

                    int qtyUpper = qtySewingOutput_Size - qtyAssemblyRelease_Size;
                    if (qtyUpper < 0)
                    {
                        qtyUpper = 0;
                    }
                    qtyUpper_PO += qtyUpper;

                    int qtyOutsole = qtyOutsoleOutput_Size - qtyAssemblyRelease_Size;
                    if (qtyOutsole < 0)
                    {
                        qtyOutsole = 0;
                    }
                    qtyOutsole_PO += qtyOutsole;

                    int qtySocklining = qtySocklining_Size - qtyAssemblyRelease_Size;
                    if (qtySocklining < 0)
                    {
                        qtySocklining = 0;
                    }
                    qtySocklining_PO += qtySocklining;

                    int qtyMatch = Math.Min(qtySewingOutput_Size, qtyOutsoleOutput_Size) - qtyAssemblyRelease_Size;
                    if (qtyMatch < 0)
                    {
                        qtyMatch = 0;
                    }
                    qtyMatch_PO += qtyMatch;

                    List <Int32> materialList = new List <Int32>();
                    materialList.Add(qtySewingOutput_Size > 0 ? qtySewingOutput_Size : 0);
                    materialList.Add(qtyOutsoleOutput_Size > 0 ? qtyOutsoleOutput_Size : 0);
                    materialList.Add(qtySocklining_Size > 0 ? qtySocklining_Size : 0);

                    int qtyMatchWithSocklining = materialList.Min() - qtyAssemblyRelease_Size;
                    if (qtyMatchWithSocklining < 0)
                    {
                        qtyMatchWithSocklining = 0;
                    }
                    qtyMatchWithSocklining_PO += qtyMatchWithSocklining;
                }

                string assemblyLine_PO   = assemblyMaster_PO != null ? assemblyMaster_PO.AssemblyLine : "";
                var    upperInventory_PO = new UpperWHInventoryViewModel()
                {
                    AssemblyLine           = assemblyLine_PO,
                    SewingOutput           = qtyUpper_PO,
                    OutsoleOutput          = qtyOutsole_PO,
                    SockliningInput        = qtySocklining_PO,
                    Matching               = qtyMatch_PO,
                    MatchingWithSocklining = qtyMatchWithSocklining_PO,
                };
                upperWHInventoryList.Add(upperInventory_PO);
            }

            var assemblyLineList = upperWHInventoryList.Select(s => s.AssemblyLine).Distinct().ToList();

            if (assemblyLineList.Count() > 0)
            {
                assemblyLineList = assemblyLineList.OrderBy(o => o).ToList();
            }
            var regex = new Regex(@"\D");
            var assemblyLineCustomList = assemblyLineList.Select(s => new { Line = s, LineNumber = regex.IsMatch(s) ? regex.Replace(s, "") : s }).ToList();

            if (assemblyLineCustomList.Count() > 0)
            {
                assemblyLineCustomList = assemblyLineCustomList.OrderBy(o => String.IsNullOrEmpty(o.LineNumber) ? 100 : Int32.Parse(o.LineNumber)).ThenBy(th => th.Line).ToList();
            }

            foreach (var assemblyLineCustom in assemblyLineCustomList)
            {
                var assemblyLine = assemblyLineCustom.Line;
                var upperWHInventoryByAssemblyLine = upperWHInventoryList.Where(w => w.AssemblyLine == assemblyLine).ToList();
                var productNoList_Assembly         = assemblyMasterList.Where(w => w.AssemblyLine == assemblyLine).Select(s => s.ProductNo).Distinct().ToList();
                var upperInventory = new UpperWHInventoryViewModel()
                {
                    AssemblyLine    = assemblyLine,
                    ProductNoList   = productNoList_Assembly,
                    SewingOutput    = upperWHInventoryByAssemblyLine.Sum(s => s.SewingOutput),
                    OutsoleOutput   = upperWHInventoryByAssemblyLine.Sum(s => s.OutsoleOutput),
                    SockliningInput = upperWHInventoryByAssemblyLine.Sum(s => s.SockliningInput),
                    Matching        = upperWHInventoryByAssemblyLine.Sum(s => s.Matching),
                };
                upperWHInventoryViewList.Add(upperInventory);

                var upperInventory_1 = new UpperWHInventoryViewModel()
                {
                    AssemblyLine    = assemblyLine,
                    ProductNoList   = productNoList_Assembly,
                    SewingOutput    = upperWHInventoryByAssemblyLine.Sum(s => s.SewingOutput),
                    OutsoleOutput   = upperWHInventoryByAssemblyLine.Sum(s => s.OutsoleOutput),
                    SockliningInput = upperWHInventoryByAssemblyLine.Sum(s => s.SockliningInput),
                    Matching        = upperWHInventoryByAssemblyLine.Sum(s => s.MatchingWithSocklining),
                };
                upperWHInventoryViewList_WithSocklining.Add(upperInventory_1);
            }
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DataTable dt = new UpperWHInventoryDetailDataSet().Tables["UpperWHInventoryDetailTable"];

            assemblyMasterList  = AssemblyMasterController.Select();
            sewingOutputList    = SewingOutputController.SelectByAssemblyMaster();
            outsoleOutputList   = OutsoleOutputController.SelectByAssemblyMaster();
            assemblyReleaseList = AssemblyReleaseController.SelectByAssemblyMaster();
            orderList           = OrdersController.SelectByAssemblyMaster();

            List <UpperWHInventoryViewModel> upperWHInventoryViewList = new List <UpperWHInventoryViewModel>();

            assemblyLineList = assemblyMasterList.Where(a => String.IsNullOrEmpty(a.AssemblyLine) == false).Select(a => a.AssemblyLine).Distinct().OrderBy(l => l).ToList();

            // Total value
            //int upperTotal = 0;
            //int outsoleTotal = 0;
            //int matchingTotal = 0;
            // Sum value
            int upperSum, outsoleSum, matchingSum;

            foreach (string assemblyLine in assemblyLineList)
            {
                List <String> productNoList = assemblyMasterList.Where(a => a.AssemblyLine == assemblyLine).Select(o => o.ProductNo).OrderBy(l => l).Distinct().ToList();
                List <UpperWHInventoryDetailViewModel> upperWHInventoryDetailViewList = new List <UpperWHInventoryDetailViewModel>();
                foreach (string productNo in productNoList)
                {
                    UpperWHInventoryDetailViewModel upperWHInventoryDetailView = new UpperWHInventoryDetailViewModel();
                    OrdersModel order = orderList.Where(o => o.ProductNo == productNo).FirstOrDefault();
                    if (order != null)
                    {
                        upperWHInventoryDetailView.ProductNo = productNo;
                        upperWHInventoryDetailView.ShoeName  = order.ShoeName;
                        upperWHInventoryDetailView.ArticleNo = order.ArticleNo;
                    }
                    int qtyUpperTotal   = 0;
                    int qtyOutsoleTotal = 0;
                    int qtyMatchTotal   = 0;
                    int qtyQuantity     = order.Quantity;
                    int qtyReleaseTotal = 0;
                    List <AssemblyReleaseModel> assemblyReleaseList_D1 = assemblyReleaseList.Where(a => a.ProductNo == productNo).ToList();
                    List <SewingOutputModel>    sewingOutputList_D1    = sewingOutputList.Where(s => s.ProductNo == productNo).ToList();
                    List <OutsoleOutputModel>   outsoleOutputList_D1   = outsoleOutputList.Where(o => o.ProductNo == productNo).ToList();

                    List <String> sizeNoList = sewingOutputList_D1.Select(s => s.SizeNo).Distinct().ToList();
                    if (sizeNoList.Count == 0)
                    {
                        sizeNoList = outsoleOutputList_D1.Select(o => o.SizeNo).Distinct().ToList();
                    }
                    foreach (string sizeNo in sizeNoList)
                    {
                        int qtyRelease = assemblyReleaseList_D1.Where(a => a.SizeNo == sizeNo).Sum(a => a.Quantity);
                        int qtyUpper   = sewingOutputList_D1.Where(s => s.SizeNo == sizeNo).Sum(s => s.Quantity)
                                         - qtyRelease;
                        int qtyOutsole = outsoleOutputList_D1.Where(o => o.SizeNo == sizeNo).Sum(o => o.Quantity)
                                         - qtyRelease;
                        int qtyMatch =
                            MatchingHelper.Calculate(sewingOutputList_D1.Where(s => s.SizeNo == sizeNo).Sum(s => s.Quantity),
                                                     outsoleOutputList_D1.Where(o => o.SizeNo == sizeNo).Sum(o => o.Quantity), sizeNo)
                            - qtyRelease;
                        if (qtyUpper < 0)
                        {
                            qtyUpper = 0;
                        }
                        qtyUpperTotal += qtyUpper;
                        if (qtyOutsole < 0)
                        {
                            qtyOutsole = 0;
                        }
                        qtyOutsoleTotal += qtyOutsole;
                        if (qtyMatch < 0)
                        {
                            qtyMatch = 0;
                        }
                        qtyMatchTotal += qtyMatch;
                        if (qtyRelease < 0)
                        {
                            qtyRelease = 0;
                        }
                        qtyReleaseTotal += qtyRelease;
                    }
                    upperWHInventoryDetailView.Quantity        = qtyQuantity;
                    upperWHInventoryDetailView.ReleaseQuantity = qtyReleaseTotal;
                    upperWHInventoryDetailView.SewingOutput    = qtyUpperTotal;
                    upperWHInventoryDetailView.OutsoleOutput   = qtyOutsoleTotal;
                    upperWHInventoryDetailView.Matching        = qtyMatchTotal;

                    //UpperWHInventoryViewModel upperWHInventoryView = new UpperWHInventoryViewModel
                    //{
                    //    AssemblyLine = assemblyLine,
                    //    ProductNoList = productNoList,
                    //    SewingOutput = qtyUpperTotal,
                    //    OutsoleOutput = qtyOutsoleTotal,
                    //    Matching = qtyMatchTotal,
                    //};
                    //upperWHInventoryViewList.Add(upperWHInventoryView);


                    if (upperWHInventoryDetailView.SewingOutput != 0 || upperWHInventoryDetailView.OutsoleOutput != 0)
                    {
                        upperWHInventoryDetailViewList.Add(upperWHInventoryDetailView);
                    }
                }

                Int32.TryParse(upperWHInventoryDetailViewList.Sum(o => o.SewingOutput).ToString(), out upperSum);
                Int32.TryParse(upperWHInventoryDetailViewList.Sum(o => o.OutsoleOutput).ToString(), out outsoleSum);
                Int32.TryParse(upperWHInventoryDetailViewList.Sum(o => o.Matching).ToString(), out matchingSum);

                //List<int> upperSumList = upperWHInventoryDetailViewList.Where(o => o.SewingOutput != 0).Select(p => p.SewingOutput).ToList();
                //List<int> ousoleSumList = upperWHInventoryDetailViewList.Where(o => o.OutsoleOutput != 0).Select(p => p.OutsoleOutput).ToList();
                //List<int> matchingSumList = upperWHInventoryDetailViewList.Where(o => o.Matching != 0).Select(p => p.Matching).ToList();

                foreach (UpperWHInventoryDetailViewModel print in upperWHInventoryDetailViewList)
                {
                    DataRow dr = dt.NewRow();
                    dr["ProductNo"]    = print.ProductNo;
                    dr["ShoeName"]     = print.ShoeName;
                    dr["ArticleNo"]    = print.ArticleNo;
                    dr["AssemblyLine"] = assemblyLine;
                    //dr["AssemblyLineSum"] = assemblyLine;
                    dr["Quantity"] = print.Quantity;
                    dr["Release"]  = print.ReleaseQuantity;
                    dr["Upper"]    = print.SewingOutput;
                    dr["OutSole"]  = print.OutsoleOutput;
                    dr["Matching"] = print.Matching;

                    //dr["UpperSum"] = upperWHInventoryDetailViewList.Sum(o => o.SewingOutput).ToString();
                    //dr["OutSoleSum"] = upperWHInventoryDetailViewList.Sum(o => o.OutsoleOutput).ToString();
                    //dr["MatchingSum"] = upperWHInventoryDetailViewList.Sum(o => o.Matching).ToString();
                    dr["UpperSum"]    = upperSum;
                    dr["OutSoleSum"]  = outsoleSum;
                    dr["MatchingSum"] = matchingSum;

                    dt.Rows.Add(dr);
                }
            }


            ReportDataSource rds = new ReportDataSource();

            rds.Name = "UpperWHInventoryDetail_DataSetV9";
            //rds.Name = "UpperWHInventoryDetailFinal";
            rds.Value = dt;
            //reportViewer.LocalReport.ReportPath = @"C:\Users\IT02\Documents\Visual Studio 2010\Projects\Saoviet Master Schedule Solution\MasterSchedule\Reports\DelayReport.rdlc";
            reportViewer.LocalReport.ReportPath = @"Reports\UpperWHInventoryDetailReport.rdlc";
            //reportViewer.LocalReport.ReportPath = @"Reports\UpperWHInventoryDetailReportV11.rdlc";
            reportViewer.LocalReport.DataSources.Add(rds);
            reportViewer.RefreshReport();
            this.Cursor = null;
        }
Пример #6
0
 private void bwLoadData_DoWork(object sender, DoWorkEventArgs e)
 {
     sewingOutputList = SewingOutputController.Select(productNo);
     sizeRunList      = SizeRunController.Select(productNo);
     offDayList       = OffDayController.SelectDate();
 }
Пример #7
0
        private void bwLoadData_DoWork(object sender, DoWorkEventArgs e)
        {
            assemblyMasterList  = AssemblyMasterController.Select();
            sewingOutputList    = SewingOutputController.SelectByAssemblyMaster();
            outsoleOutputList   = OutsoleOutputController.SelectByAssemblyMaster();
            assemblyReleaseList = AssemblyReleaseController.SelectByAssemblyMaster();
            orderList           = OrdersController.SelectByAssemblyMaster();

            List <UpperWHInventoryViewModel> upperWHInventoryViewList = new List <UpperWHInventoryViewModel>();

            assemblyLineList = assemblyMasterList.Where(a => String.IsNullOrEmpty(a.AssemblyLine) == false).Select(a => a.AssemblyLine).Distinct().OrderBy(l => l).ToList();
            foreach (string assemblyLine in assemblyLineList)
            {
                List <String> productNoList = assemblyMasterList.Where(a => a.AssemblyLine == assemblyLine).Select(o => o.ProductNo).Distinct().ToList();

                List <AssemblyReleaseModel> assemblyReleaseList_D1 = assemblyReleaseList.Where(a => productNoList.Contains(a.ProductNo) == true).ToList();
                List <SewingOutputModel>    sewingOutputList_D1    = sewingOutputList.Where(s => productNoList.Contains(s.ProductNo) == true).ToList();
                List <OutsoleOutputModel>   outsoleOutputList_D1   = outsoleOutputList.Where(o => productNoList.Contains(o.ProductNo) == true).ToList();

                int qtyUpperTotal   = 0;
                int qtyOutsoleTotal = 0;
                int qtyMatchTotal   = 0;
                foreach (string productNo in productNoList)
                {
                    List <AssemblyReleaseModel> assemblyReleaseList_D2 = assemblyReleaseList_D1.Where(a => a.ProductNo == productNo).ToList();
                    List <SewingOutputModel>    sewingOutputList_D2    = sewingOutputList_D1.Where(s => s.ProductNo == productNo).ToList();
                    List <OutsoleOutputModel>   outsoleOutputList_D2   = outsoleOutputList_D1.Where(o => o.ProductNo == productNo).ToList();

                    List <String> sizeNoList = sewingOutputList_D2.Select(s => s.SizeNo).Distinct().ToList();
                    if (sizeNoList.Count == 0)
                    {
                        sizeNoList = outsoleOutputList_D2.Select(o => o.SizeNo).Distinct().ToList();
                    }
                    foreach (string sizeNo in sizeNoList)
                    {
                        int qtyRelease = assemblyReleaseList_D2.Where(a => a.SizeNo == sizeNo).Sum(a => a.Quantity);
                        int qtyUpper   = sewingOutputList_D2.Where(s => s.SizeNo == sizeNo).Sum(s => s.Quantity)
                                         - qtyRelease;
                        int qtyOutsole = outsoleOutputList_D2.Where(o => o.SizeNo == sizeNo).Sum(o => o.Quantity)
                                         - qtyRelease;
                        int qtyMatch =
                            MatchingHelper.Calculate(sewingOutputList_D2.Where(s => s.SizeNo == sizeNo).Sum(s => s.Quantity),
                                                     outsoleOutputList_D2.Where(o => o.SizeNo == sizeNo).Sum(o => o.Quantity), sizeNo)
                            - qtyRelease;
                        if (qtyUpper < 0)
                        {
                            qtyUpper = 0;
                        }
                        qtyUpperTotal += qtyUpper;
                        if (qtyOutsole < 0)
                        {
                            qtyOutsole = 0;
                        }
                        qtyOutsoleTotal += qtyOutsole;
                        if (qtyMatch < 0)
                        {
                            qtyMatch = 0;
                        }
                        qtyMatchTotal += qtyMatch;
                    }
                }
                UpperWHInventoryViewModel upperWHInventoryView = new UpperWHInventoryViewModel
                {
                    AssemblyLine  = assemblyLine,
                    ProductNoList = productNoList,
                    SewingOutput  = qtyUpperTotal,
                    OutsoleOutput = qtyOutsoleTotal,
                    Matching      = qtyMatchTotal,
                };

                upperWHInventoryViewList.Add(upperWHInventoryView);
            }

            e.Result = upperWHInventoryViewList;
        }