Пример #1
0
        private void NewProjectButton_Click(object sender, RoutedEventArgs e)
        {
            ClearErrorMessage();

            // projectName:         Remington Apartment
            string projectName = newProjectNameTextBox.Text;
            // saveDirectoryPrefix: C:\Users\JZhang\Desktop\表格\Remington Apartment
            // full file path:      C:\Users\JZhang\Desktop\表格\Remington Apartment-xxxx表.xlsx
            string saveDirectoryPrefix = AppConfigReadingService.GetConfigSetting("formSaveDirectory") + "\\" + projectName;

            if (projectName == string.Empty || projectName == null)
            {
                newProjectErrMsgTextBlock.Visibility = Visibility.Visible;
                newProjectErrMsgTextBlock.Text       = "工程名不能为空";
            }
            else if (IOService.FileAlreadyExists(saveDirectoryPrefix + "-输入校对表" + AppConfigReadingService.GetSpreadSheetExtention()))
            {
                newProjectErrMsgTextBlock.Visibility = Visibility.Visible;
                newProjectErrMsgTextBlock.Text       = "工程名已存在";
            }
            else
            {
                List <InputItem> inputItems = new List <InputItem>();

                ItemInputPage itemInputPage = new ItemInputPage(inputItems, saveDirectoryPrefix);
                this.NavigationService.Navigate(itemInputPage);
            }
        }
Пример #2
0
        public MainWindow()
        {
            InitializeComponent();

            // Verify licensing valid
            string licensePath  = AppConfigReadingService.GetConfigSetting("metadataFileDirectory") + "\\Licensing.txt";
            string savedLicense = IOService.ReadTextFileToString(licensePath);
            string validLicense = FingerPrint.Value();

            if (savedLicense == validLicense)
            {
                StartPage startPage = new StartPage();
                mainFrame.NavigationService.Navigate(startPage);
            }
            else
            {
                string           sMessageBoxText = "程序启动失败,序列号错误";
                string           sCaption        = "程序启动失败";
                MessageBoxButton btnMessageBox   = MessageBoxButton.OK;
                MessageBoxImage  icnMessageBox   = MessageBoxImage.Error;
                MessageBoxResult rsltMessageBox  = MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);

                switch (rsltMessageBox)
                {
                case MessageBoxResult.OK:
                    Application.Current.Shutdown();
                    return;
                }
            }


            //Testing();
            //Testing2();
        }
Пример #3
0
        private void LoadListsFromTextFile()
        {
            string resourcePath = AppConfigReadingService.GetConfigSetting("metadataFileDirectory");

            productNameList    = IOService.ReadTextFileToList(resourcePath + "\\产品名称.txt");
            positionList       = IOService.ReadTextFileToList(resourcePath + "\\位置.txt");
            roomList           = IOService.ReadTextFileToList(resourcePath + "\\房间.txt");
            applydirectionList = IOService.ReadTextFileToList(resourcePath + "\\铺贴方向.txt");
        }
Пример #4
0
        private void LoadProjectButton_Click(object sender, RoutedEventArgs e)
        {
            ClearErrorMessage();

            // projectName:         Remington Drive
            string projectName = loadProjectNameTextBox.Text;
            // saveDirectoryPrefix: C:\Users\JZhang\Desktop\表格\Remington Drive
            // full file path:      C:\Users\JZhang\Desktop\表格\Remington Drive-xxxx表.xlsx
            string saveDirectoryPrefix = AppConfigReadingService.GetConfigSetting("formSaveDirectory") + "\\" + projectName;

            try
            {
                List <InputItem> inputItems    = IOService.ReadInputCheckingSheetToInputItemList(saveDirectoryPrefix + "-输入校对表" + AppConfigReadingService.GetSpreadSheetExtention());
                ItemInputPage    itemInputPage = new ItemInputPage(inputItems, saveDirectoryPrefix);
                this.NavigationService.Navigate(itemInputPage);
            }
            catch (Exception ex)
            {
                loadProjectErrMsgTextBlock.Visibility = Visibility.Visible;
                loadProjectErrMsgTextBlock.Text       = "工程名不存在或输入校对表未关闭导致读取失败";
            }
        }
Пример #5
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);
            }
        }
Пример #6
0
        private void GoToPriceInputPageButton_Click(object sender, RoutedEventArgs e)
        {
            // Warn user if any field on left column is not clear but filled with value
            if (!AllInputFieldsClear())
            {
                string           sMessageBoxText = "左侧输入栏仍有值未保存,选择继续将丢失这些值,确定继续?";
                string           sCaption        = "输入栏有未保存值";
                MessageBoxButton btnMessageBox   = MessageBoxButton.YesNo;
                MessageBoxImage  icnMessageBox   = MessageBoxImage.Warning;
                MessageBoxResult rsltMessageBox  = MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);

                switch (rsltMessageBox)
                {
                case MessageBoxResult.Yes:
                    break;

                case MessageBoxResult.No:
                    return;
                }
            }

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

            try
            {
                IOService.GenerateInputCheckingSheet(saveDirectoryPrefix + "-输入校对表" + AppConfigReadingService.GetSpreadSheetExtention(), inputItemList);

                PriceInputPage priceInputPage = new PriceInputPage(summedItemList, inputItemList, saveDirectoryPrefix);
                this.NavigationService.Navigate(priceInputPage);
            }
            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);
            }
        }
Пример #7
0
        private void SaveAndCloseButton_Click(object sender, RoutedEventArgs e)
        {
            // Warn user if any field on left column is not clear but filled with value
            if (!AllInputFieldsClear())
            {
                string           sMessageBoxText = "左侧输入栏仍有值未保存,选择继续将丢失这些值,确定继续?";
                string           sCaption        = "输入栏有未保存值";
                MessageBoxButton btnMessageBox   = MessageBoxButton.YesNo;
                MessageBoxImage  icnMessageBox   = MessageBoxImage.Warning;
                MessageBoxResult rsltMessageBox  = MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);

                switch (rsltMessageBox)
                {
                case MessageBoxResult.Yes:
                    break;

                case MessageBoxResult.No:
                    return;
                }
            }

            try
            {
                IOService.GenerateInputCheckingSheet(saveDirectoryPrefix + "-输入校对表" + AppConfigReadingService.GetSpreadSheetExtention(), inputItemOC.ToList());

                Application.Current.Shutdown();
            }
            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);
            }
        }