//private bool CheckImportFile() //{ // ExcelHelper exceloper = new ExcelHelper(); // DataSet ds = exceloper.ExcelToDS(this.FilePath); // string tablenames = ""; // //所有表名称拼接 // for (int i = 0; i < ds.Tables.Count; i++) // { // tablenames = tablenames + ds.Tables[i].TableName; // } // if (!(tablenames.Contains("封面") && tablenames.Contains("总概算") && tablenames.Contains("其他费用1"))) // { // this.Comment = "Excel文件至少包含《封面》、《总概算》、《其他费用1》3个sheet!"; // this.Condition = "无法生成"; // return false; // } // //获取《封面》内容,根据封面内容获取项目名称、项目编号 // proc.ProjectName = exceloper.GetXValueByContainKeyWord(ds.Tables["封面$"], "工 程 名 称"); // proc.ProjectCode = exceloper.GetXValueByContainKeyWord(ds.Tables["封面$"], "工程编号", 6); // //获取《总概算》内容 // GetEstinateOverViewTableValues(ds.Tables["总概算$"], ref cellsSet); // GetCatagorySetValues(ds.Tables["总概算$"], cellsSet, ref catagorySet); // GetCatagorySetValues_Other(ds.Tables["其他费用1$"], ref catagorySet); // this.ProjectName = proc.ProjectName; // return true; //} private bool CheckImportFile() { ExcelHelper exceloper = new ExcelHelper(); DataSet ds = exceloper.ExcelToDS(this.FilePath); string tablenames = ""; //所有表名称拼接 for (int i = 0; i < ds.Tables.Count; i++) { tablenames = tablenames + ds.Tables[i].TableName; } if (!(tablenames.Contains("总概算") && tablenames.Contains("其他费用"))) { this.Comment = "Excel文件至少得包含《总概算》、《其他费用》或《其他费用1、2、3……》表"; this.Condition = "无法生成"; return(false); } //获取《封面》内容,根据封面内容获取项目名称、项目编号 proc = new ProjectClass(); try { proc.ProjectName = exceloper.GetXValueByContainKeyWord(ds.Tables["封面$"], "工 程 名 称"); proc.ProjectCode = exceloper.GetXValueByContainKeyWord(ds.Tables["封面$"], "工程编号", 6); } catch (Exception) { } //获取《总概算》内容 GetEstinateOverViewTableValues(ds.Tables["总概算$"], ref cellsSet); GetCatagorySetValues(ds.Tables["总概算$"], cellsSet, ref catagorySet); GetCatagorySetValues_Other(ds, ref catagorySet); return(true); }
//为financdata赋值 public void GetDataToFinanceData(ProjectClass proc, ProjectCostCatagorySet catagorySet) { foreach (ProjectEstimateViewModel pevm in EstimateViewModels) { pevm.ProjectName = proc.ProjectName; pevm.ProjectCode = proc.ProjectCode; if (pevm is ProjectTotalEstimateViewModel) { ((ProjectTotalEstimateViewModel)pevm).EstimateNumber = catagorySet.pcc_all.costValue.ToString(); continue; } switch (pevm.ExpanseCategory) { case "10KV(含20KV)及以下基建项目": pevm.EstimateNumber = catagorySet.pcc_all.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—配电站(开关站)工程—建筑工程": pevm.EstimateNumber = catagorySet.pcc_pd_jz.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—配电站(开关站)工程—安装工程": pevm.EstimateNumber = catagorySet.pcc_pd_az.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—配电站(开关站)工程—设备购置": pevm.EstimateNumber = catagorySet.pcc_pd_sb.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—通信及调度自动化—建筑工程": pevm.EstimateNumber = catagorySet.pcc_tx_jz.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—通信及调度自动化—安装工程": pevm.EstimateNumber = catagorySet.pcc_tx_az.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—通信及调度自动化—设备购置": pevm.EstimateNumber = catagorySet.pcc_tx_sb.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—架空线路工程—架空线路本体工程": pevm.EstimateNumber = catagorySet.pcc_jk.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—电缆线路工程—电缆本体工程": pevm.EstimateNumber = catagorySet.pcc_dl.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—其他费用—建设场地征用及清理费": pevm.EstimateNumber = catagorySet.pcc_other_cd.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—其他费用—项目建设管理费—项目管理经费": pevm.EstimateNumber = catagorySet.pcc_other_xmgl.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—其他费用—项目建设管理费—项目管理经费—其中:业务招待费": pevm.EstimateNumber = catagorySet.pcc_other_zd.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—其他费用—项目建设管理费—招标费": pevm.EstimateNumber = catagorySet.pcc_other_zb.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—其他费用—项目建设管理费—工程监理费": pevm.EstimateNumber = catagorySet.pcc_other_gcjl.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—其他费用—项目建设技术服务费—工程勘察费": pevm.EstimateNumber = catagorySet.pcc_other_kc.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—其他费用—项目建设技术服务费—工程设计费": pevm.EstimateNumber = catagorySet.pcc_other_sj.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—其他费用—项目建设技术服务费—设计文件评审费": pevm.EstimateNumber = catagorySet.pcc_other_ps.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—其他费用—项目建设技术服务费—项目后评价费": pevm.EstimateNumber = catagorySet.pcc_other_hpj.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—其他费用—项目建设技术服务费—技术经济标准编制管理费": pevm.EstimateNumber = catagorySet.pcc_other_bzbz.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—其他费用—工程建设监督检测费": pevm.EstimateNumber = catagorySet.pcc_other_jdjc.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—其他费用—生产准备费": pevm.EstimateNumber = catagorySet.pcc_other_sczb.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—其他费用—基本预备费": pevm.EstimateNumber = catagorySet.pcc_other_jbyb.costValue.ToString(); break; case "10KV(含20KV)及以下基建项目—建设期贷款利息": pevm.EstimateNumber = catagorySet.pcc_other_dklx.costValue.ToString(); break; default: System.Windows.Forms.MessageBox.Show("错误:未能识别的费用类别——" + pevm.ExpanseCategory + pevm.WBSCode); break; } } string temp = TotalEstimateViewModel.TotalInvestmentWithTax; //System.Windows.MessageBox.Show(MinWithoutRate().ToString()+" "+MaxWithoutRate().ToString()); }