private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            string        filepath = @"App\data\";
            DirectoryInfo dir      = new DirectoryInfo(filepath);

            obc_import = new ObservableCollection <ProjectImportMouldViewModel>();
            if (dir.Exists)
            {
                FileInfo[] fiList = dir.GetFiles();
                foreach (FileInfo f in fiList)
                {
                    if (f.Extension == ".est")
                    {
                        DataTable dt = XmlHelper.GetTable(filepath + f.Name, XmlHelper.XmlType.File, "Estinates");
                        ProjectEstimateSetViewModel setViewModel = new ProjectEstimateSetViewModel(dt);
                        foreach (ProjectEstimateViewModel pvm in setViewModel.EstimateViewModels)
                        {
                            ProjectImportMouldViewModel import = new ProjectImportMouldViewModel();
                            import.GetData(pvm);
                            obc_import.Add(import);
                        }
                        DepartmentBudgetFilled department = new DepartmentBudgetFilled(setViewModel.TotalEstimateViewModel.ProjectName);
                        obc_import[obc_import.Count - 23].DepartmentFilledBudgetWithTax = department.DepartmentFilledBudgetWithTax;
                        obc_import[obc_import.Count - 23].YearBudgetWithoutTax          = 0;
                        for (int i = obc_import.Count - 1; i > obc_import.Count - 23; i--)
                        {
                            obc_import[i].DepartmentFilledBudgetWithTax             = (setViewModel.EstimateViewModels[i % 23].totalInvestmentWithTax / setViewModel.TotalInvestmentWithTax) * department.DepartmentFilledBudgetWithTax;
                            obc_import[i].YearBudgetWithoutTax                      = obc_import[i].DepartmentFilledBudgetWithTax / (1 + obc_import[i].deductibleVATRatio / 100);
                            obc_import[obc_import.Count - 23].YearBudgetWithoutTax += obc_import[i].YearBudgetWithoutTax;
                        }
                    }
                }
            }
            this.DG1.ItemsSource = obc_import;
        }
Example #2
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            string        filepath = @"App\data\";
            DirectoryInfo dir      = new DirectoryInfo(filepath);

            obc_project = new ObservableCollection <ProjectEstimateViewModel>();
            if (dir.Exists)
            {
                FileInfo[] fiList = dir.GetFiles();
                foreach (FileInfo f in fiList)
                {
                    if (f.Extension == ".est")
                    {
                        DataTable dt = XmlHelper.GetTable(filepath + f.Name, XmlHelper.XmlType.File, "Estinates");
                        ProjectEstimateSetViewModel setViewModel = new ProjectEstimateSetViewModel(dt);
                        foreach (ProjectEstimateViewModel pvm in setViewModel.EstimateViewModels)
                        {
                            obc_project.Add(pvm);
                        }
                    }
                }
            }
            //   this.DG1.Items.Clear();
            this.DG1.ItemsSource = obc_project;
        }
        //从文件获取数据
        private void GetData(ref ProjectEstimateSetViewModel projectEstimateSetViewModel, ref TailDifferenceViewModel tdvm)
        {
            string    datafile = _datapath + DataFileName;
            DataSet   ds       = XmlOperate.GetDataSet(datafile);
            DataTable dt       = ds.Tables[0];
            DataTable dt2      = ds.Tables[1];

            projectEstimateSetViewModel = new ProjectEstimateSetViewModel(dt);
            tdvm = new TailDifferenceViewModel();
            tdvm.TailDifference         = dt2.DefaultView[0]["TailDifference"].ToString();
            tdvm.ItemWithTailDifference = dt2.DefaultView[0]["ItemWithTailDifference"].ToString();
            tdvm.CompositeTaxRate       = dt2.DefaultView[0]["CompositeTaxRate"].ToString();
            tdvm.AnnualPriceDifference  = dt2.DefaultView[0]["AnnualPriceDifference"].ToString();
        }