private void tvProjectList_AfterSelect(object sender, TreeViewEventArgs e) { List <List <object> > objectList = new List <List <object> >(); if (e.Node.Tag is Catalog) { //项目年度列表 Catalog catalogObj = (Catalog)e.Node.Tag; #region 显示数据 DataTable dt = getTempDataTable("row", 9); foreach (TreeNode ptnss in e.Node.Nodes) { MoneySends moneySendObj = (MoneySends)ptnss.Tag; foreach (TreeNode tns in ptnss.Nodes) { Subject subjectObj = (Subject)tns.Tag; //显示节点经费 List <Contact_Table5> moneyss = ConnectionManager.Context.table("Contact_Table5").where ("NodeID='" + moneySendObj.MSID + "' and SubjectID = '" + subjectObj.SubjectID + "'").select("*").getList <Contact_Table5>(new Contact_Table5()); foreach (Contact_Table5 mObj in moneyss) { List <object> cells = new List <object>(); cells.Add(subjectObj.SubjectName); cells.Add(mObj.SubjectWorkUnit); cells.Add(mObj.SubjectTotalMoney); cells.Add(mObj.SubjectSendMoney); cells.Add(ExcelHelper.getDateTimeForString(mObj.SubjectSendTime, "yyyy年MM月dd日", string.Empty)); cells.Add(mObj.SubjectSendedMoney); cells.Add(mObj.SubjectUseMoney); cells.Add(mObj.SubjectNoSendMoney); cells.Add(ptnss.Text); dt.Rows.Add(cells.ToArray()); } gcGrid.DataSource = dt; } } #endregion } else if (e.Node.Tag is Subject) { //项目年度列表 Subject subjectObj = (Subject)e.Node.Tag; MoneySends moneySendObj = (MoneySends)e.Node.Parent.Tag; #region 显示数据 DataTable dt = getTempDataTable("row", 9); //显示节点经费 List <Contact_Table5> moneyss = ConnectionManager.Context.table("Contact_Table5").where ("NodeID='" + moneySendObj.MSID + "' and SubjectID = '" + subjectObj.SubjectID + "'").select("*").getList <Contact_Table5>(new Contact_Table5()); foreach (Contact_Table5 mObj in moneyss) { List <object> cells = new List <object>(); cells.Add(subjectObj.SubjectName); cells.Add(mObj.SubjectWorkUnit); cells.Add(mObj.SubjectTotalMoney); cells.Add(mObj.SubjectSendMoney); cells.Add(ExcelHelper.getDateTimeForString(mObj.SubjectSendTime, "yyyy年MM月dd日", string.Empty)); cells.Add(mObj.SubjectSendedMoney); cells.Add(mObj.SubjectUseMoney); cells.Add(mObj.SubjectNoSendMoney); cells.Add(e.Node.Text); dt.Rows.Add(cells.ToArray()); } gcGrid.DataSource = dt; #endregion } else if (e.Node.Tag is MoneySends) { //项目年度列表 MoneySends moneySendObj = (MoneySends)e.Node.Tag; #region 显示数据 DataTable dt = getTempDataTable("row", 9); foreach (TreeNode tns in e.Node.Nodes) { Subject subjectObj = (Subject)tns.Tag; //显示节点经费 List <Contact_Table5> moneyss = ConnectionManager.Context.table("Contact_Table5").where ("NodeID='" + moneySendObj.MSID + "' and SubjectID = '" + subjectObj.SubjectID + "'").select("*").getList <Contact_Table5>(new Contact_Table5()); foreach (Contact_Table5 mObj in moneyss) { List <object> cells = new List <object>(); cells.Add(subjectObj.SubjectName); cells.Add(mObj.SubjectWorkUnit); cells.Add(mObj.SubjectTotalMoney); cells.Add(mObj.SubjectSendMoney); cells.Add(ExcelHelper.getDateTimeForString(mObj.SubjectSendTime, "yyyy年MM月dd日", string.Empty)); cells.Add(mObj.SubjectSendedMoney); cells.Add(mObj.SubjectUseMoney); cells.Add(mObj.SubjectNoSendMoney); cells.Add(e.Node.Text); dt.Rows.Add(cells.ToArray()); } gcGrid.DataSource = dt; } #endregion } }
private void nodeImport(string catalogID, string nodeId) { MoneySends mss = ConnectionManager.Context.table("MoneySends").where ("MSID='" + nodeId + "' and CatalogID='" + catalogID + "'").select("*").getItem <MoneySends>(new MoneySends()); if (mss != null && string.IsNullOrEmpty(mss.MSID)) { return; } OpenFileDialog sfd = new OpenFileDialog(); sfd.FileName = string.Empty; sfd.Filter = "*.xlsx|*.xlsx"; if (sfd.ShowDialog() == DialogResult.OK) { try { int subjectCount = 0; List <string> errorSubjectList = new List <string>(); DataSet ds = ExcelHelper.ExcelToDataSet(sfd.FileName); if (ds != null && ds.Tables.Count >= 2) { #region 清除数据 ConnectionManager.Context.table("Contact_Table1").where ("NodeID='" + nodeId + "'").delete(); ConnectionManager.Context.table("Contact_Table2").where ("NodeID='" + nodeId + "'").delete(); ConnectionManager.Context.table("Contact_Table3").where ("NodeID='" + nodeId + "'").delete(); ConnectionManager.Context.table("Contact_Table4").where ("NodeID='" + nodeId + "'").delete(); ConnectionManager.Context.table("Contact_Table5").where ("NodeID='" + nodeId + "'").delete(); #endregion foreach (DataTable dt in ds.Tables) { switch (dt.TableName) { case "项目基本情况": #region 项目基本情况 foreach (DataRow dr in dt.Rows) { string value1 = dr["项目名称"] != null ? dr["项目名称"].ToString() : string.Empty; string value2 = dr["项目牵头单位"] != null ? dr["项目牵头单位"].ToString() : string.Empty; string value3 = dr["项目总负责人"] != null ? dr["项目总负责人"].ToString() : string.Empty; string value4 = dr["项目总经费"] != null ? dr["项目总经费"].ToString() : string.Empty; string value5 = dr["项目到位经费"] != null ? dr["项目到位经费"].ToString() : string.Empty; string value6 = dr["节点评估时间"] != null ? dr["节点评估时间"].ToString() : string.Empty; string value7 = dr["节点评估意见"] != null ? dr["节点评估意见"].ToString() : string.Empty; string value8 = dr["节点评估等级"] != null ? dr["节点评估等级"].ToString() : string.Empty; string value9 = dr["节点评估专家"] != null ? dr["节点评估专家"].ToString() : string.Empty; //添加节点-项目信息 Contact_Table1 ct1 = new Contact_Table1(); ct1.TID = Guid.NewGuid().ToString(); ct1.CatalogID = mss.CatalogID; ct1.ProjectID = mss.ProjectID; ct1.NodeID = mss.MSID; ct1.ProjectName = value1; ct1.WorkUnit = value2; ct1.ProjectMaster = value3; try { ct1.TotalMoney = decimal.Parse(value4); } catch (Exception ex) { MessageBox.Show("对不起,项目(" + value1 + ")的总经费错误!"); } try { ct1.TotalMoneyNow = decimal.Parse(value5); } catch (Exception ex) { MessageBox.Show("对不起,项目(" + value1 + ")的到位错误!"); } ct1.copyTo(ConnectionManager.Context.table(typeof(Contact_Table1).Name)).insert(); //更新节点信息 try { mss.NodeWillTime = DateTime.Parse(value6); } catch (Exception ex) { } mss.WillContent = value7; mss.WillLevel = value8; mss.WillWorker = value9; mss.copyTo(ConnectionManager.Context.table("MoneySends")).where ("MSID='" + nodeId + "' and CatalogID='" + catalogID + "'").update(); } #endregion break; case "项目办公室组成": #region 项目办公室组成 foreach (DataRow dr in dt.Rows) { string value1 = dr["项目办公室职务"] != null ? dr["项目办公室职务"].ToString() : string.Empty; string value2 = dr["姓名"] != null ? dr["姓名"].ToString() : string.Empty; string value3 = dr["单位"] != null ? dr["单位"].ToString() : string.Empty; string value4 = dr["职务/职称"] != null ? dr["职务/职称"].ToString() : string.Empty; string value5 = dr["联系电话"] != null ? dr["联系电话"].ToString() : string.Empty; Contact_Table2 ct2 = new Contact_Table2(); ct2.TID = Guid.NewGuid().ToString(); ct2.CatalogID = mss.CatalogID; ct2.ProjectID = mss.ProjectID; ct2.NodeID = mss.MSID; ct2.WorkDeskJob = value1; ct2.PersonName = value2; ct2.PersonUnit = value3; ct2.PersonJob = value4; ct2.PersonPhone = value5; ct2.copyTo(ConnectionManager.Context.table(typeof(Contact_Table2).Name)).insert(); } #endregion break; case "项目完成情况": #region 项目完成情况 foreach (DataColumn dc in dt.Columns) { if (string.IsNullOrEmpty(dc.ColumnName)) { continue; } int rowIndexxx = 0; foreach (DataRow dr in dt.Rows) { rowIndexxx++; string valueStr = dr[dc.ColumnName] != null ? dr[dc.ColumnName].ToString() : string.Empty; Contact_Table3 ct3 = new Contact_Table3(); ct3.TID = Guid.NewGuid().ToString(); ct3.CatalogID = mss.CatalogID; ct3.ProjectID = mss.ProjectID; ct3.NodeID = mss.MSID; ct3.ModuleName = dc.ColumnName + "xxxxx" + rowIndexxx; ct3.ModuleValue = valueStr; ct3.copyTo(ConnectionManager.Context.table(typeof(Contact_Table3).Name)).insert(); } } #endregion break; case "项目经费使用情况": #region 导入 项目经费使用情况 foreach (DataColumn dc in dt.Columns) { if (dc.ColumnName == "科目名称") { continue; } //添数据 int rowIndexx = 0; foreach (DataRow dr in dt.Rows) { rowIndexx++; //取值 string valStr = dr[dc.ColumnName] != null ? dr[dc.ColumnName].ToString() : string.Empty; Contact_Table4 ct4 = new Contact_Table4(); ct4.TID = Guid.NewGuid().ToString(); ct4.CatalogID = mss.CatalogID; ct4.ProjectID = mss.ProjectID; ct4.NodeID = mss.MSID; ct4.ModuleName = dc.ColumnName + "xxxxx" + rowIndexx; ct4.ModuleValue = valStr; ct4.copyTo(ConnectionManager.Context.table("Contact_Table4")).insert(); } } #endregion break; case "课题经费拨付与支出情况": #region 导入 课题经费拨付与支出情况 foreach (DataRow dr in dt.Rows) { subjectCount++; string value1 = dr["课题名称"] != null ? dr["课题名称"].ToString() : string.Empty; string value2 = dr["课题负责单位"] != null ? dr["课题负责单位"].ToString() : string.Empty; string value3 = dr["课题合同总价款"] != null ? dr["课题合同总价款"].ToString() : string.Empty; string value4 = dr["课题应拨经费"] != null ? dr["课题应拨经费"].ToString() : string.Empty; string value5 = dr["课题经费拨付时间"] != null ? dr["课题经费拨付时间"].ToString() : string.Empty; string value6 = dr["课题已拨经费"] != null ? dr["课题已拨经费"].ToString() : string.Empty; string value7 = dr["课题支出经费"] != null ? dr["课题支出经费"].ToString() : string.Empty; string value8 = dr["课题应拨未拨经费"] != null ? dr["课题应拨未拨经费"].ToString() : string.Empty; if (string.IsNullOrEmpty(value1)) { errorSubjectList.Add(value1); continue; } Subject subjectObj = ConnectionManager.Context.table("Subject").where ("CatalogID='" + mss.CatalogID + "' and SubjectName='" + value1 + "'").select("*").getItem <Subject>(new Subject()); if (subjectObj != null && string.IsNullOrEmpty(subjectObj.SubjectID)) { errorSubjectList.Add(value1); continue; } Contact_Table5 ct5 = new Contact_Table5(); ct5.TID = Guid.NewGuid().ToString(); ct5.CatalogID = mss.CatalogID; ct5.ProjectID = mss.ProjectID; ct5.NodeID = mss.MSID; ct5.SubjectID = subjectObj.SubjectID; ct5.SubjectWorkUnit = value2; ct5.SubjectTotalMoney = decimal.Parse(value3); ct5.SubjectSendMoney = decimal.Parse(value4); ct5.SubjectSendTime = DateTime.Parse(value5); ct5.SubjectSendedMoney = decimal.Parse(value6); ct5.SubjectUseMoney = decimal.Parse(value7); ct5.SubjectNoSendMoney = decimal.Parse(value8); ct5.copyTo(ConnectionManager.Context.table("Contact_Table5")).insert(); } #endregion break; } } //组织文字 StringBuilder importResult = new StringBuilder(); importResult.Append("导入成功!").Append("共找到课题经费拨付支出情况").Append(subjectCount).Append("条,其中").Append(errorSubjectList.Count).Append("条导入错误!"); if (errorSubjectList.Count >= 1) { importResult.Append("分别是("); foreach (string s in errorSubjectList) { importResult.Append("\"").Append(s).Append("\","); } importResult.Remove(importResult.Length - 1, 1); importResult.Append(")"); } MessageBox.Show(importResult.ToString()); } srpSearch.search(); } catch (Exception ex) { MessageBox.Show("对不起,Excel导入失败!Ex:" + ex.ToString()); } } }
private void tvProjectList_AfterSelect(object sender, TreeViewEventArgs e) { DataTable dtSubject = null; DataTable dtUnit = null; //清理经费显示区域 tpTag1.Controls.Clear(); if (e.Node.Tag is Catalog) { //项目金额 Catalog catalogObj = (Catalog)e.Node.Tag; tpTag1.PageVisible = true; xtcData.SelectedTabPage = tpTag1; #region 显示经费表 List <Dicts> projectDicts = ConnectionManager.Context.table("Dicts").where ("CatalogID='" + catalogObj.CatalogID + "' and ProjectID='" + catalogObj.CatalogID + "' and (SubjectID is null or SubjectID= '')").select("*").getList <Dicts>(new Dicts()); addMoneyTablePage(catalogObj.CatalogID, catalogObj.CatalogName, projectDicts); #endregion List <Subject> subjectList = ConnectionManager.Context.table("Subject").where ("CatalogID='" + catalogObj.CatalogID + "'").select("*").getList <Subject>(new Subject()); //生成列 makeTableColumnsForCatalogID(catalogObj.CatalogID); dtSubject = BaseModuleController.getTempDataTable("row", gvDetailForSubject.Columns.Count); dtUnit = BaseModuleController.getTempDataTable("row", gvDetailForSubject.Columns.Count); #region 组织课题经费数据 foreach (Subject sObj in subjectList) { List <SubjectMoneys> lxSubjects = ConnectionManager.Context.table("SubjectMoneys").where ("CatalogID='" + catalogObj.CatalogID + "' and SubjectID='" + sObj.SubjectID + "'").orderBy("CatalogID,SubjectID,SMName").select("*").getList <SubjectMoneys>(new SubjectMoneys()); int totalValue = 0; DataRow drr = dtSubject.NewRow(); drr[nodeColDict["****名称"]] = sObj.SubjectName; foreach (SubjectMoneys sms in lxSubjects) { MoneySends mss = ConnectionManager.Context.table("MoneySends").where ("MSID='" + sms.NodeID + "'").select("*").getItem <MoneySends>(new MoneySends()); if (string.IsNullOrEmpty(mss.MSID)) { continue; } try { totalValue += int.Parse(sms.SMValue); } catch (Exception ex) { } if (nodeColDict.ContainsKey(mss.SendRule)) { drr[nodeColDict[mss.SendRule]] = sms.SMValue; } } drr[nodeColDict["****合计"]] = totalValue.ToString(); dtSubject.Rows.Add(drr); } #endregion #region 组织单位经费数据 List <string> unitList = new List <string>(); List <UnitMoneys> unitMoneysList = ConnectionManager.Context.table("UnitMoneys").where ("CatalogID='" + catalogObj.CatalogID + "'").select("*").getList <UnitMoneys>(new UnitMoneys()); foreach (UnitMoneys ums in unitMoneysList) { if (unitList.Contains(ums.UnitName)) { continue; } else { unitList.Add(ums.UnitName); } } foreach (string unitName in unitList) { List <UnitMoneys> lxUnits = ConnectionManager.Context.table("UnitMoneys").where ("CatalogID='" + catalogObj.CatalogID + "' and UnitName='" + unitName + "'").orderBy("CatalogID,UnitName,UMName").select("*").getList <UnitMoneys>(new UnitMoneys()); int totalValue = 0; DataRow drr = dtUnit.NewRow(); drr[nodeColDict["****名称"]] = unitName; foreach (UnitMoneys ums in lxUnits) { MoneySends mss = ConnectionManager.Context.table("MoneySends").where ("MSID='" + ums.NodeID + "'").select("*").getItem <MoneySends>(new MoneySends()); if (string.IsNullOrEmpty(mss.MSID)) { continue; } try { totalValue += int.Parse(ums.UMValue); } catch (Exception ex) { } if (nodeColDict.ContainsKey(mss.SendRule)) { drr[nodeColDict[mss.SendRule]] = ums.UMValue; } } drr[nodeColDict["****合计"]] = totalValue.ToString(); dtUnit.Rows.Add(drr); } #endregion } else if (e.Node.Tag is Subject) { //课题金额 Subject subectObj = (Subject)e.Node.Tag; tpTag1.PageVisible = false; //生成列 makeTableColumnsForCatalogID(subectObj.CatalogID); dtSubject = BaseModuleController.getTempDataTable("row", gvDetailForSubject.Columns.Count); dtUnit = BaseModuleController.getTempDataTable("row", gvDetailForSubject.Columns.Count); #region 组织课题经费数据 List <SubjectMoneys> lxSubjects = ConnectionManager.Context.table("SubjectMoneys").where ("CatalogID='" + subectObj.CatalogID + "' and SubjectID='" + subectObj.SubjectID + "'").orderBy("CatalogID,SubjectID,SMName").select("*").getList <SubjectMoneys>(new SubjectMoneys()); int totalValue = 0; DataRow drr = dtSubject.NewRow(); drr[nodeColDict["****名称"]] = subectObj.SubjectName; foreach (SubjectMoneys sms in lxSubjects) { MoneySends mss = ConnectionManager.Context.table("MoneySends").where ("MSID='" + sms.NodeID + "'").select("*").getItem <MoneySends>(new MoneySends()); if (string.IsNullOrEmpty(mss.MSID)) { continue; } try { totalValue += int.Parse(sms.SMValue); } catch (Exception ex) { } if (nodeColDict.ContainsKey(mss.SendRule)) { drr[nodeColDict[mss.SendRule]] = sms.SMValue; } } drr[nodeColDict["****合计"]] = totalValue.ToString(); dtSubject.Rows.Add(drr); #endregion #region 组织单位经费数据 #endregion } gcGridForSubject.DataSource = dtSubject; gcGridForUnit.DataSource = dtUnit; }
/// <summary> /// 导入数据库 /// </summary> /// <param name="catalogNumber"></param> /// <param name="sourceFile"></param> /// <param name="localContext"></param> /// <returns></returns> protected override string importDB(string catalogNumber, string sourceFile, Noear.Weed.DbContext localContext) { Dictionary <string, Subject> subjectDict = new Dictionary <string, Subject>(); //数据库版本号 string catalogVersionStr = "v1.1"; //附件目录 string filesDir = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(sourceFile), "Files"); //处理项目信息 DataItem diProject = localContext.table("JiBenXinXiBiao").select("*").getDataItem(); if (diProject != null && diProject.count() >= 1) { #region 读取版本号并更新Catalog信息 //读取版本号 try { catalogVersionStr = localContext.table("Version").select("VersionNum").getValue <string>(catalogVersionStr); } catch (Exception ex) { } //更新Catalog Catalog catalog = updateAndClearCatalog(catalogNumber, getValueWithDefault <string>(diProject.get("HeTongMingCheng"), string.Empty), "合同书", catalogVersionStr, false, string.Empty, System.IO.Path.GetDirectoryName(sourceFile)); #endregion #region 导入项目及课题信息 //处理项目信息 Project proj = new Project(); proj.ProjectID = catalog.CatalogID; proj.CatalogID = catalog.CatalogID; proj.ProjectName = catalog.CatalogName; proj.SecretLevel = getValueWithDefault <string>(diProject.get("HeTongMiJi"), string.Empty); proj.TotalMoney = diProject.get("HeTongJiaKuan") != null?decimal.Parse(diProject.get("HeTongJiaKuan").ToString()) : 0; proj.ProjectNumber = getValueWithDefault <string>(diProject.get("HeTongBianHao"), string.Empty); proj.IsNeedHide = "0"; int totalYear = 0; try { DateTime startTime = diProject.getDateTime("HeTongKaiShiShiJian"); DateTime endTime = diProject.getDateTime("HeTongJieShuShiJian"); totalYear = (endTime.Year + 1) - startTime.Year; } catch (Exception ex) { } proj.TotalTime = totalYear; proj.DutyNormalUnit = string.Empty; //导入1.3版之后版本新添加的字段 switch (catalogVersionStr) { case "v1.1": break; case "v1.2": break; case "v1.3": break; case "v1.4": proj.Keywords = getValueWithDefault <string>(diProject.get("HeTongGuanJianZi"), string.Empty); proj.Domains = getValueWithDefault <string>(diProject.get("HeTongSuoShuLingYu"), string.Empty); proj.DutyUnit = getValueWithDefault <string>(diProject.get("HeTongFuZeDanWei"), string.Empty); proj.DutyUnitOrg = getValueWithDefault <string>(diProject.get("HeTongSuoShuBuMen"), string.Empty); proj.DutyUnitAddress = getAddress(getValueWithDefault <string>(diProject.get("HeTongSuoShuDiDian"), string.Empty)); break; case "v1.5": proj.Keywords = getValueWithDefault <string>(diProject.get("HeTongGuanJianZi"), string.Empty); proj.Domains = getValueWithDefault <string>(diProject.get("HeTongSuoShuLingYu"), string.Empty); proj.DutyUnit = getValueWithDefault <string>(diProject.get("HeTongFuZeDanWei"), string.Empty); proj.DutyUnitOrg = getValueWithDefault <string>(diProject.get("HeTongSuoShuBuMen"), string.Empty); proj.DutyUnitAddress = getAddress(getValueWithDefault <string>(diProject.get("HeTongSuoShuDiDian"), string.Empty)); proj.DutyNormalUnit = getValueWithDefault <string>(diProject.get("HeTongFuZeDanWeiChangYongMingCheng"), string.Empty); break; } proj.copyTo(ConnectionManager.Context.table("Project")).insert(); //处理课题列表 DataList dlSubject = localContext.table("KeTiBiao").orderBy("ZhuangTai,ModifyTime").select("*").getDataList(); foreach (DataItem di in dlSubject.getRows()) { Subject obj = new Subject(); obj.SubjectID = getValueWithDefault <string>(di.get("BianHao"), string.Empty); obj.CatalogID = proj.CatalogID; obj.ProjectID = proj.ProjectID; obj.SubjectName = getValueWithDefault <string>(di.get("KeTiMingCheng"), string.Empty); //obj.TotalMoney = di.get("") != null ? decimal.Parse(di.get("").ToString()) : 0; obj.WorkDest = getValueWithDefault <string>(di.get("KeTiYanJiuMuBiao"), string.Empty); obj.WorkContent = getValueWithDefault <string>(di.get("KeTiYanJiuNeiRong"), string.Empty); obj.WorkTask = getValueWithDefault <string>(di.get("KeTiCanJiaDanWeiFenGong"), string.Empty); obj.SecretLevel = "公开"; obj.TotalMoney = 0; //导入1.3版之后版本新添加的字段 switch (catalogVersionStr) { case "v1.1": break; case "v1.2": break; case "v1.3": break; case "v1.4": obj.DutyUnit = getValueWithDefault <string>(di.get("KeTiFuZeDanWei"), string.Empty); obj.DutyUnitOrg = getValueWithDefault <string>(di.get("KeTiSuoShuBuMen"), string.Empty); obj.DutyUnitAddress = getAddress(getValueWithDefault <string>(di.get("KeTiSuoShuDiDian"), string.Empty)); //处理参加单位分工 StringBuilder sbWorkTask = new StringBuilder(); DataList items = localContext.table("RenWuBiao").where ("KeTiBianHao='" + getValueWithDefault <string>(di.get("BianHao"), string.Empty) + "'").select("*").getDataList(); if (items.getRowCount() >= 1) { sbWorkTask.Append("该课题由").Append(getValueWithDefault <string>(items.getRow(0).get("DanWeiMing"), string.Empty)).Append("单位负责,承担").Append(getValueWithDefault <string>(items.getRow(0).get("RenWuFenGong"), string.Empty)).Append("等任务;").AppendLine(); } for (int kk = 1; kk < items.getRowCount(); kk++) { DataItem rwb = items.getRow(kk); sbWorkTask.Append(getValueWithDefault <string>(rwb.get("DanWeiMing"), string.Empty)).Append("单位参加,承担").Append(getValueWithDefault <string>(rwb.get("RenWuFenGong"), string.Empty)).Append("等任务;\n"); } if (sbWorkTask.Length >= 1) { sbWorkTask.Remove(sbWorkTask.Length - 1, 1); } obj.WorkTask = sbWorkTask.ToString(); break; case "v1.5": obj.DutyUnit = getValueWithDefault <string>(di.get("KeTiFuZeDanWei"), string.Empty); obj.DutyUnitOrg = getValueWithDefault <string>(di.get("KeTiSuoShuBuMen"), string.Empty); obj.DutyUnitAddress = getAddress(getValueWithDefault <string>(di.get("KeTiSuoShuDiDian"), string.Empty)); //处理参加单位分工 sbWorkTask = new StringBuilder(); items = localContext.table("RenWuBiao").where ("KeTiBianHao='" + getValueWithDefault <string>(di.get("BianHao"), string.Empty) + "'").select("*").getDataList(); if (items.getRowCount() >= 1) { sbWorkTask.Append("该课题由").Append(getValueWithDefault <string>(items.getRow(0).get("DanWeiMing"), string.Empty)).Append("单位负责,承担").Append(getValueWithDefault <string>(items.getRow(0).get("RenWuFenGong"), string.Empty)).Append("等任务;").AppendLine(); } for (int kk = 1; kk < items.getRowCount(); kk++) { DataItem rwb = items.getRow(kk); sbWorkTask.Append(getValueWithDefault <string>(rwb.get("DanWeiMing"), string.Empty)).Append("单位参加,承担").Append(getValueWithDefault <string>(rwb.get("RenWuFenGong"), string.Empty)).Append("等任务;\n"); } if (sbWorkTask.Length >= 1) { sbWorkTask.Remove(sbWorkTask.Length - 1, 1); } obj.WorkTask = sbWorkTask.ToString(); obj.SecretLevel = getValueWithDefault <string>(di.get("KeTiBaoMiDengJi"), string.Empty); break; } obj.copyTo(ConnectionManager.Context.table("Subject")).insert(); subjectDict[obj.SubjectID] = obj; } #endregion #region 判断是否需要隐藏建议书-proj.ProjectNumber //string contactNumber = string.Empty; //if (proj.ProjectNumber.EndsWith("-00")) //{ // contactNumber = proj.ProjectNumber.Replace("-00", string.Empty); //} //else //{ // contactNumber = proj.ProjectNumber; //} //Catalog catalogReporter = ConnectionManager.Context.table("Catalog").where("CatalogNumber like '%" + contactNumber + "%' and CatalogType = '建议书'").select("*").getItem<Catalog>(new Catalog()); //if (!string.IsNullOrEmpty(catalogReporter.CatalogID)) //{ // catalogReporter.IsNeedHide = "1"; // catalogReporter.copyTo(ConnectionManager.Context.table("Catalog").where("CatalogNumber like '%" + contactNumber + "%' and CatalogType = '建议书'")).update(); // Project projReporter = ConnectionManager.Context.table("Project").where("CatalogID='" + catalogReporter.CatalogID + "'").select("*").getItem<Project>(new Project()); // if (!string.IsNullOrEmpty(projReporter.ProjectID)) // { // projReporter.IsNeedHide = "1"; // projReporter.copyTo(ConnectionManager.Context.table("Project").where("CatalogID='" + catalogReporter.CatalogID + "'")).update(); // } //} #endregion #region 更新项目编号字段 catalog.CatalogNumber = proj.ProjectNumber; catalog.copyTo(ConnectionManager.Context.table("Catalog").where ("CatalogID='" + catalog.CatalogID + "'")).update(); #endregion #region 导入人员信息 //处理人员信息 DataList dlPerson = localContext.table("RenYuanBiao").orderBy("ZhuangTai").select("*").getDataList(); foreach (DataItem di in dlPerson.getRows()) { Person obj = new Person(); obj.PersonID = Guid.NewGuid().ToString(); obj.CatalogID = proj.CatalogID; obj.ProjectID = proj.ProjectID; obj.SubjectID = getValueWithDefault <string>(di.get("KeTiBiaoHao"), string.Empty); obj.PersonName = getValueWithDefault <string>(di.get("XingMing"), string.Empty); obj.PersonIDCard = getValueWithDefault <string>(di.get("ShenFenZhengHao"), string.Empty); obj.PersonSex = getValueWithDefault <string>(di.get("XingBie"), string.Empty); obj.PersonJob = getValueWithDefault <string>(di.get("ZhiCheng"), string.Empty); obj.PersonSpecialty = getValueWithDefault <string>(di.get("ZhuanYe"), string.Empty); obj.TotalTime = di.getInt("MeiNianTouRuShiJian"); obj.TaskContent = getValueWithDefault <string>(di.get("RenWuFenGong"), string.Empty); obj.WorkUnit = getValueWithDefault <string>(di.get("GongZuoDanWei"), string.Empty); obj.Telephone = di.exists("DianHua") ? getValueWithDefault <string>(di.get("DianHua"), string.Empty) : string.Empty; obj.Mobilephone = di.exists("ShouJi") ? getValueWithDefault <string>(di.get("ShouJi"), string.Empty) : string.Empty; //设置项目中职务 obj.JobInProject = getValueWithDefault <string>(di.get("ZhiWu"), string.Empty); //是否为项目负责人 switch (getValueWithDefault <string>(di.get("ShiXiangMuFuZeRen"), string.Empty)) { case "rbIsOnlyProject": obj.PersonID = Guid.NewGuid().ToString(); obj.SubjectID = string.Empty; obj.IsProjectMaster = "true"; //插入数据 obj.copyTo(ConnectionManager.Context.table("Person")).insert(); break; case "rbIsProjectAndSubject": string oldSubjectID = obj.SubjectID; //保存项目负责人 obj.PersonID = Guid.NewGuid().ToString(); obj.SubjectID = string.Empty; obj.IsProjectMaster = "true"; //插入数据 obj.copyTo(ConnectionManager.Context.table("Person")).insert(); //保存课题负责人 obj.PersonID = Guid.NewGuid().ToString(); obj.SubjectID = oldSubjectID; obj.IsProjectMaster = "false"; //插入数据 obj.copyTo(ConnectionManager.Context.table("Person")).insert(); break; case "rbIsOnlySubject": //保存课题负责人或成员 obj.PersonID = Guid.NewGuid().ToString(); obj.IsProjectMaster = "false"; //插入数据 obj.copyTo(ConnectionManager.Context.table("Person")).insert(); break; } } #endregion #region 写入金额数据 DataList dlMoneys = localContext.table("YuSuanBiao").select("*").getDataList(); if (dlMoneys != null && dlMoneys.getRowCount() >= 1) { foreach (DataItem di in dlMoneys.getRows()) { //添加字典 addDict(catalog, proj, "Money,Info", (di.get("MingCheng") != null ? di.get("MingCheng").ToString() : string.Empty), (di.get("ShuJu") != null ? di.get("ShuJu").ToString() : string.Empty), string.Empty); } } #endregion #region 写入研究进度安排 DataList dlProgress = localContext.table("JinDuBiao").orderBy("ZhuangTai,ModifyTime").select("*").getDataList(); foreach (DataItem diProgress in dlProgress.getRows()) { try { WorkSteps ws = new WorkSteps(); ws.WSID = Guid.NewGuid().ToString(); ws.CatalogID = catalog.CatalogID; ws.ProjectID = proj.ProjectID; ws.WorkTime = DateTime.Parse(diProgress.get("ShiJian") != null ? diProgress.get("ShiJian").ToString() : DateTime.MinValue.ToString()); ws.DestAndContent = diProgress.get("JieDuanMuBiao") != null?diProgress.get("JieDuanMuBiao").ToString() : string.Empty; ws.ResultMethod = diProgress.get("JieDuanChengGuo") != null?diProgress.get("JieDuanChengGuo").ToString() : string.Empty; ws.copyTo(ConnectionManager.Context.table("WorkSteps")).insert(); } catch (Exception ex) { } } #endregion //节点字典(Key=名称,Value=记录ID) Dictionary <string, string> nodeDict = new Dictionary <string, string>(); #region 写入拨付约定 int nodeIndexx = 0; DataList dlRules = localContext.table("BoFuBiao").orderBy("ZhuangTai,ModifyTime").select("*").getDataList(); foreach (DataItem diRule in dlRules.getRows()) { nodeIndexx++; try { MoneySends ms = new MoneySends(); ms.MSID = diRule.get("BianHao") != null?diRule.get("BianHao").ToString() : Guid.NewGuid().ToString(); ms.CatalogID = catalog.CatalogID; ms.ProjectID = proj.ProjectID; ms.NodeIndex = nodeIndexx; ms.SendRule = diRule.get("BoFuTiaoJian") != null?diRule.get("BoFuTiaoJian").ToString() : string.Empty; ms.WillTime = DateTime.Parse(diRule.get("YuJiShiJian") != null ? diRule.get("YuJiShiJian").ToString() : DateTime.MinValue.ToString()); ms.TotalMoney = decimal.Parse(diRule.get("JingFeiJinQian") != null ? diRule.get("JingFeiJinQian").ToString() : "0"); ms.MemoText = diRule.get("BeiZhu") != null?diRule.get("BeiZhu").ToString() : string.Empty; ms.copyTo(ConnectionManager.Context.table("MoneySends")).insert(); if (string.IsNullOrEmpty(ms.SendRule)) { continue; } else { nodeDict[ms.SendRule] = ms.MSID; } } catch (Exception ex) { } } #endregion try { //尝试写入1.5中新加的课题节点经费和单位节点经费表 #region 写入课题节点经费 DataList dlSubjectMoneys = localContext.table("KeTiJieDianJingFeiBiao").orderBy("ZhuangTai,ModifyTime").select("*").getDataList(); foreach (DataItem di in dlSubjectMoneys.getRows()) { string oldSubjectId = di.get("KeTiBianHao") != null?di.get("KeTiBianHao").ToString() : string.Empty; string oldNodeId = di.get("BoFuBianHao") != null?di.get("BoFuBianHao").ToString() : string.Empty; string moduleName = "current"; string moduleValue = di.get("JingFei") != null?di.get("JingFei").ToString() : string.Empty; string oldSubjectName = localContext.table("KeTiBiao").where ("BianHao='" + oldSubjectId + "'").select("KeTiMingCheng").getValue <string>(string.Empty); string newSubjectID = ConnectionManager.Context.table("Subject").where ("SubjectName='" + oldSubjectName + "'").select("SubjectID").getValue <string>(string.Empty); string oldNodeName = localContext.table("BoFuBiao").where ("BianHao='" + oldNodeId + "'").select("BoFuTiaoJian").getValue <string>(string.Empty); string newNodeID = oldNodeId; if (nodeDict.ContainsKey(oldNodeName)) { newNodeID = nodeDict[oldNodeName]; SubjectMoneys obj = new SubjectMoneys(); obj.SMID = Guid.NewGuid().ToString(); obj.CatalogID = catalog.CatalogID; obj.ProjectID = catalog.CatalogID; obj.SubjectID = newSubjectID; obj.NodeID = newNodeID; obj.SMName = moduleName; obj.SMValue = moduleValue; obj.copyTo(ConnectionManager.Context.table("SubjectMoneys")).insert(); decimal nodeMoney = 0; try { nodeMoney = decimal.Parse(obj.SMValue); } catch (Exception ex) { } if (subjectDict.ContainsKey(obj.SubjectID)) { subjectDict[obj.SubjectID].TotalMoney += nodeMoney; } } } #endregion #region 写入单位节点经费 DataList dlUnitMoneys = localContext.table("DanWeiJieDianJingFeiBiao").orderBy("ZhuangTai,ModifyTime").select("*").getDataList(); foreach (DataItem di in dlUnitMoneys.getRows()) { string unitName = di.get("DanWeiMingCheng") != null?di.get("DanWeiMingCheng").ToString() : string.Empty; string oldNodeId = di.get("BoFuBianHao") != null?di.get("BoFuBianHao").ToString() : string.Empty; string moduleName = "current"; string moduleValue = di.get("JingFei") != null?di.get("JingFei").ToString() : string.Empty; string oldNodeName = localContext.table("BoFuBiao").where ("BianHao='" + oldNodeId + "'").select("BoFuTiaoJian").getValue <string>(string.Empty); string newNodeID = oldNodeId; if (nodeDict.ContainsKey(oldNodeName)) { newNodeID = nodeDict[oldNodeName]; UnitMoneys obj = new UnitMoneys(); obj.UMID = Guid.NewGuid().ToString(); obj.CatalogID = catalog.CatalogID; obj.ProjectID = catalog.CatalogID; obj.NodeID = newNodeID; obj.UnitName = unitName; obj.UMName = moduleName; obj.UMValue = moduleValue; obj.copyTo(ConnectionManager.Context.table("UnitMoneys")).insert(); } } #endregion #region 更新课题总经费 foreach (Subject subObj in subjectDict.Values) { subObj.copyTo(ConnectionManager.Context.table("Subject").where ("CatalogID = '" + subObj.CatalogID + "' and SubjectID = '" + subObj.SubjectID + "'")).update(); } #endregion } catch (Exception ex) { System.Console.WriteLine(ex.ToString()); } #region 处理归一化单位列 int checkCount = 0; int errorCount = 0; checkCount++; proj.DutyNormalUnit = getNormalNameWithDutyUnit(proj.DutyUnit); proj.copyTo(ConnectionManager.Context.table("Project")).where ("ProjectID='" + proj.ProjectID + "'").update(); if (proj.DutyNormalUnit == "未匹配") { errorCount++; } List <Subject> subjectList22 = ConnectionManager.Context.table("Subject").where ("ProjectID='" + proj.ProjectID + "' and ProjectID = '" + proj.ProjectID + "'").select("*").getList <Subject>(new Subject()); foreach (Subject sub22 in subjectList22) { checkCount++; sub22.DutyNormalUnit = getNormalNameWithDutyUnit(sub22.DutyUnit); sub22.copyTo(ConnectionManager.Context.table("Subject")).where ("SubjectID='" + sub22.SubjectID + "' and ProjectID = '" + proj.ProjectID + "'").update(); if (sub22.DutyNormalUnit == "未匹配") { errorCount++; } } List <Person> personList22 = ConnectionManager.Context.table("Person").where ("ProjectID='" + proj.ProjectID + "'").select("*").getList <Person>(new Person()); foreach (Person per22 in personList22) { checkCount++; per22.WorkNormalUnit = getNormalNameWithDutyUnit(per22.WorkUnit); per22.copyTo(ConnectionManager.Context.table("Person")).where ("PersonID='" + per22.PersonID + "' and ProjectID = '" + proj.ProjectID + "'").update(); if (per22.WorkNormalUnit == "未匹配") { errorCount++; } } catalog.IsCheckUnitComplete = errorCount == 0 ? "通过" : "不通过"; proj.IsCheckUnitComplete = errorCount == 0 ? "通过" : "不通过"; proj.copyTo(ConnectionManager.Context.table("Project")).where ("ProjectID='" + proj.ProjectID + "'").update(); catalog.copyTo(ConnectionManager.Context.table("Catalog")).where ("CatalogID='" + catalog.CatalogID + "'").update(); #endregion return(catalog.CatalogID); } else { return(string.Empty); } }
private void tvProjectList_AfterSelect(object sender, TreeViewEventArgs e) { if (e.Node.Tag is Catalog) { Catalog catalogObj = (Catalog)e.Node.Tag; DataTable dtCatalog = mlpMoneys.getTempMoneyTable("row", e.Node.Nodes.Count); mlpMoneys.showOrHideTopPanel(true); mlpMoneys.setNodeName(""); mlpMoneys.showOrHideColumn(dtCatalog.Columns.Count - 1, false); mlpMoneys.showOrHideColumn(dtCatalog.Columns.Count - 2, true); for (int yyy = 0; yyy < e.Node.Nodes.Count; yyy++) { mlpMoneys.showOrHideColumn(2 + yyy, true); } Application.DoEvents(); #region 显示总表 int nodeIndex = 0; foreach (TreeNode sub in e.Node.Nodes) { MoneySends mss = (MoneySends)sub.Tag; List <Contact_Table4> moneyss = ConnectionManager.Context.table("Contact_Table4").where ("NodeID='" + mss.MSID + "'").select("*").getList <Contact_Table4>(new Contact_Table4()); foreach (Contact_Table4 mObj in moneyss) { try { if (mObj.ModuleName != null) { if (mObj.ModuleName.StartsWith("项目合同")) { string[] tttt = mObj.ModuleName.Split(new string[] { "xxxxx" }, StringSplitOptions.None); if (tttt != null && tttt.Length >= 2) { decimal val = 0; try { val = decimal.Parse(mObj.ModuleValue); } catch (Exception ex) { } decimal total = 0; try { total = decimal.Parse(dtCatalog.Rows[(int.Parse(tttt[1]) - 1)][1].ToString()); } catch (Exception ex) { } dtCatalog.Rows[(int.Parse(tttt[1]) - 1)][1] = total + val; } } else if (mObj.ModuleName.StartsWith("本阶段支出经费")) { string[] tttt = mObj.ModuleName.Split(new string[] { "xxxxx" }, StringSplitOptions.None); if (tttt != null && tttt.Length >= 2) { decimal val = 0; try { val = decimal.Parse(mObj.ModuleValue); } catch (Exception ex) { } decimal total = 0; try { total = decimal.Parse(dtCatalog.Rows[(int.Parse(tttt[1]) - 1)][dtCatalog.Columns.Count - 2].ToString()); } catch (Exception ex) { } mlpMoneys.showOrHideColumn(2 + nodeIndex, true); dtCatalog.Rows[(int.Parse(tttt[1]) - 1)][2 + nodeIndex] = val; total += val; dtCatalog.Rows[(int.Parse(tttt[1]) - 1)][dtCatalog.Columns.Count - 2] = total; } } //else if (mObj.ModuleName.StartsWith("备注")) //{ // string[] tttt = mObj.ModuleName.Split(new string[] { "xxxxx" }, StringSplitOptions.None); // if (tttt != null && tttt.Length >= 2) // { // dtData.Rows[(int.Parse(tttt[1]) - 1)][dtData.Columns.Count - 1] = mObj.ModuleValue; // } //} } } catch (Exception ex) { } } nodeIndex++; } mlpMoneys.setTableDataSource(dtCatalog); #endregion #region 显示标题栏的值 //合同金额 Project proj = ConnectionManager.Context.table("Project").where ("ProjectID='" + catalogObj.CatalogID + "'").select("*").getItem <Project>(new Project()); mlpMoneys.setTag1Value(proj.TotalMoney != null ? proj.TotalMoney.ToString() : string.Empty); //累计预算= 项目节点管理中的经费金额 decimal totalVal = 0; foreach (TreeNode tn in e.Node.Nodes) { totalVal += ((MoneySends)tn.Tag).TotalMoney; } mlpMoneys.setTag2Value(totalVal + ""); //累计到位= 项目基本情况——项目到位经费 totalVal = 0; foreach (TreeNode tn in e.Node.Nodes) { List <Contact_Table1> table1sss = ConnectionManager.Context.table("Contact_Table1").where ("NodeID='" + ((MoneySends)tn.Tag).MSID + "'").select("*").getList <Contact_Table1>(new Contact_Table1()); foreach (Contact_Table1 table1 in table1sss) { if (string.IsNullOrEmpty(table1.TID)) { continue; } totalVal += table1.TotalMoneyNow; } } mlpMoneys.setTag3Value(totalVal + ""); //累计支出= 项目经费使用情况——本阶段支出经费——合计 totalVal = 0; foreach (TreeNode tn in e.Node.Nodes) { Contact_Table4 table1 = ConnectionManager.Context.table("Contact_Table4").where ("NodeID='" + ((MoneySends)tn.Tag).MSID + "' and ModuleName = '本阶段支出经费xxxxx16'").select("*").getItem <Contact_Table4>(new Contact_Table4()); if (string.IsNullOrEmpty(table1.TID)) { continue; } decimal vall = 0; try { vall = decimal.Parse(table1.ModuleValue); } catch (Exception ex) { } totalVal += vall; } mlpMoneys.setTag4Value(totalVal + ""); #endregion } else if (e.Node.Tag is MoneySends) { MoneySends moneySendObj = (MoneySends)e.Node.Tag; DataTable dtData = mlpMoneys.getTempMoneyTable("row", e.Node.Parent.Nodes.Count); mlpMoneys.showOrHideTopPanel(false); mlpMoneys.setNodeName(e.Node.Text); int nodeIndex = e.Node.Parent.Nodes.IndexOf(e.Node); mlpMoneys.showOrHideColumn(dtData.Columns.Count - 1, true); mlpMoneys.showOrHideColumn(dtData.Columns.Count - 2, false); for (int ttt = 0; ttt < e.Node.Parent.Nodes.Count; ttt++) { mlpMoneys.showOrHideColumn(2 + ttt, false); } #region 显示金额表 //显示节点经费 List <Contact_Table4> moneyss = ConnectionManager.Context.table("Contact_Table4").where ("NodeID='" + moneySendObj.MSID + "'").select("*").getList <Contact_Table4>(new Contact_Table4()); foreach (Contact_Table4 mObj in moneyss) { try { if (mObj.ModuleName != null) { if (mObj.ModuleName.StartsWith("项目合同")) { string[] tttt = mObj.ModuleName.Split(new string[] { "xxxxx" }, StringSplitOptions.None); if (tttt != null && tttt.Length >= 2) { dtData.Rows[(int.Parse(tttt[1]) - 1)][1] = mObj.ModuleValue; } } else if (mObj.ModuleName.StartsWith("本阶段支出经费")) { string[] tttt = mObj.ModuleName.Split(new string[] { "xxxxx" }, StringSplitOptions.None); if (tttt != null && tttt.Length >= 2) { mlpMoneys.showOrHideColumn(2 + nodeIndex, true); dtData.Rows[(int.Parse(tttt[1]) - 1)][2 + nodeIndex] = mObj.ModuleValue; } } else if (mObj.ModuleName.StartsWith("备注")) { string[] tttt = mObj.ModuleName.Split(new string[] { "xxxxx" }, StringSplitOptions.None); if (tttt != null && tttt.Length >= 2) { dtData.Rows[(int.Parse(tttt[1]) - 1)][dtData.Columns.Count - 1] = mObj.ModuleValue; } } } } catch (Exception ex) { } } mlpMoneys.setTableDataSource(dtData); #endregion } }