예제 #1
0
        private void Testing2()
        {
            List <InputItem> inputItemList = new List <InputItem>();

            inputItemList.Add(new InputItem("s-802锦绣纹", "b", "300*3600", "2+4", "顶", "东南卧室", "0.9", "东西铺贴"));
            inputItemList.Add(new InputItem("s-802锦绣纹", "b", "400*3600", "5.9+4.7", "顶", "南西卧室", "3.6", "南北铺贴"));
            inputItemList.Add(new InputItem("s-803锦绣纹", "b", "300*3600", "5.9+4.7", "顶", "南西卧室", "3.6", "南北铺贴"));
            inputItemList.Add(new InputItem("s-802锦绣纹", "b", "300*3600", "5.9+4.7", "顶", "南西卧室", "3.6", "南北铺贴"));
            inputItemList.Add(new InputItem("s-802锦绣纹", "b", "300*800", "5.9+4.7", "顶", "南西卧室", "0.2", "南北铺贴"));
            inputItemList.Add(new InputItem("s-603金橡木", "x", "100*3000", "5.9+4.7+5.9+4.7", "踢脚线", "南西卧室"));
            inputItemList.Add(new InputItem("s-603金橡木", "x", "100*3000", "5.8", "踢脚线", "北卧室"));
            inputItemList.Add(new InputItem("s-802锦绣纹", "b", "400*800", "5.9+4.7", "顶", "南西卧室", "0.2", "南北铺贴"));


            List <SummedItem> summedItemList = CalculationService.MergeInputItem(inputItemList);

            foreach (SummedItem item in summedItemList)
            {
                item.BuyPrice  = "15";
                item.SellPrice = "20";
                double buyPrice  = StringParserService.ParsePrice(item.BuyPrice);
                double sellPrice = StringParserService.ParsePrice(item.SellPrice);

                //TODO: figure out why 15 * 46.66 gives you 656.5999999991 only here but not in csharpplayground
                item.TotalBuyPrice  = CalculationService.CalculateTotalPricesByAreaOrLength(buyPrice, item.TotalAreaOrLength);
                item.TotalSellPrice = CalculationService.CalculateTotalPricesByAreaOrLength(sellPrice, item.TotalAreaOrLength);
            }

            BuckleItem buckleItem = new BuckleItem();

            buckleItem.Quantity  = CalculationService.CalculateBuckleItemQuantity(summedItemList);
            buckleItem.BuyPrice  = "1";
            buckleItem.SellPrice = "1.5";
            double buckleBuyPrice  = StringParserService.ParsePrice(buckleItem.BuyPrice);
            double buckleSellPrice = StringParserService.ParsePrice(buckleItem.SellPrice);

            buckleItem.TotalBuyPrice  = CalculationService.CalculateTotalPricesByQuantity(buckleBuyPrice, buckleItem.Quantity);
            buckleItem.TotalSellPrice = CalculationService.CalculateTotalPricesByQuantity(buckleSellPrice, buckleItem.Quantity);

            IOService.GenerateInputCheckingSheet(@"C:\Users\JZhang\Desktop\输入校对表.xlsx", inputItemList);
            IOService.GenerateConstructionDetailSheet(@"C:\Users\JZhang\Desktop\施工详单.xlsx", inputItemList);
            IOService.GenerateMaterialTotalSheet(@"C:\Users\JZhang\Desktop\材料清单1.xlsx", summedItemList, buckleItem, true);
            IOService.GenerateMaterialTotalSheet(@"C:\Users\JZhang\Desktop\材料清单2.xlsx", summedItemList, buckleItem, false);

            List <InputItem> readInput = IOService.ReadInputCheckingSheetToInputItemList(@"C:\Users\JZhang\Desktop\输入校对表.xlsx");
        }
예제 #2
0
        private void GoToProgramEndPageButton_Click(object sender, RoutedEventArgs e)
        {
            // Verify price valid and not null
            if (!VerifyPriceFields())
            {
                return;
            }

            try
            {
                CalculationService.PopulateSummedItemsPriceFromPriceCollectors(priceCollectorList, ref summedItemList);
            }
            catch (Exception ex)
            {
                string           sMessageBoxText = "输入价格未能涵盖所有条目,请联系软件商";
                string           sCaption        = "报表生成失败";
                MessageBoxButton btnMessageBox   = MessageBoxButton.OK;
                MessageBoxImage  icnMessageBox   = MessageBoxImage.Error;
                MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);
            }

            // Calculate total prices for general item
            foreach (SummedItem item in summedItemList)
            {
                double buyPrice  = StringParserService.ParsePrice(item.BuyPrice);
                double sellPrice = StringParserService.ParsePrice(item.SellPrice);

                item.TotalBuyPrice  = CalculationService.CalculateTotalPricesByAreaOrLength(buyPrice, item.TotalAreaOrLength);
                item.TotalSellPrice = CalculationService.CalculateTotalPricesByAreaOrLength(sellPrice, item.TotalAreaOrLength);
            }

            // Calculate total prices for buckle if we need buckle
            if (needBuckle)
            {
                double buckleBuyPrice  = StringParserService.ParsePrice(buckleItem.BuyPrice);
                double buckleSellPrice = StringParserService.ParsePrice(buckleItem.SellPrice);
                buckleItem.TotalBuyPrice  = CalculationService.CalculateTotalPricesByQuantity(buckleBuyPrice, buckleItem.Quantity);
                buckleItem.TotalSellPrice = CalculationService.CalculateTotalPricesByQuantity(buckleSellPrice, buckleItem.Quantity);
            }

            // Generate Construction Detail Sheet, Material Total Sheet (listing buy price), and Material Total Sheet (listing sell price)
            try
            {
                IOService.GenerateConstructionDetailSheet(saveDirectoryPrefix + "-施工详单" + AppConfigReadingService.GetSpreadSheetExtention(), inputItemList);
                IOService.GenerateMaterialTotalSheet(saveDirectoryPrefix + "-材料清单(商家用)" + AppConfigReadingService.GetSpreadSheetExtention(), summedItemList, buckleItem, true);
                IOService.GenerateMaterialTotalSheet(saveDirectoryPrefix + "-材料清单(客户用)" + AppConfigReadingService.GetSpreadSheetExtention(), summedItemList, buckleItem, false);

                ProgramEndPage programEndPage = new ProgramEndPage();
                this.NavigationService.Navigate(programEndPage);
            }
            catch (IOException ioex)
            {
                string           sMessageBoxText = "报表生成失败,请确认您已关闭所有报表";
                string           sCaption        = "报表生成失败";
                MessageBoxButton btnMessageBox   = MessageBoxButton.OK;
                MessageBoxImage  icnMessageBox   = MessageBoxImage.Error;
                MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);
            }
            catch (Exception ex)
            {
                string           sMessageBoxText = "因未知原因报表生成失败,请联系软件商";
                string           sCaption        = "报表生成失败";
                MessageBoxButton btnMessageBox   = MessageBoxButton.OK;
                MessageBoxImage  icnMessageBox   = MessageBoxImage.Error;
                MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);
            }
        }