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; }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { string filepath = @"App\data\"; DirectoryInfo dir = new DirectoryInfo(filepath); obc_department = new ObservableCollection <DepartmentBudgetFilled>(); if (dir.Exists) { FileInfo[] fiList = dir.GetFiles(); foreach (FileInfo f in fiList) { if (f.Extension == ".est") { DepartmentBudgetFilled budgetary = new DepartmentBudgetFilled(f.Name.Split('.')[0]); budgetary.NumberOnly = obc_department.Count + 1; obc_department.Add(budgetary); } } } this.DG1.ItemsSource = obc_department; }