/// <summary> /// 获取场地选择状态的数据主键ID集合 lwl /// </summary> /// <param name="parentNode">父级节点</param> private void GetSiteCheckedNode(TreeListNode parentNode, ref List <SiteBean> lblist) { if (parentNode.Nodes.Count == 0) { return;//递归终止 } foreach (TreeListNode node in parentNode.Nodes) { if (node.CheckState == CheckState.Checked) { TreeBean nodeInfo = node.TreeList.GetDataRecordByNode(node) as TreeBean; LineBean lb = nodeInfo.Tag as LineBean; if (lb == null) { SiteBean tag = SiteBll.Instance.GetWhere(new { SITECODE = nodeInfo.Tag.ToString() }).ToList()[0]; if (tag != null) { lblist.Add(tag); } } } GetSiteCheckedNode(node, ref lblist); } }
public void WriteContent(LineBean lb) { try { this.pdfViewer.CloseDocument(); if (File.Exists(pFilePath)) { File.Delete(pFilePath); } FileStream myStream = new FileStream(pFilePath, FileMode.Create); //文件流 iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.A4); //创建A4纸、横向PDF文档 PdfWriter writer = PdfWriter.GetInstance(document, myStream); //将PDF文档写入创建的文件中 document.Open(); //要在PDF文档中写入中文必须指定中文字体,否则无法写入中文 BaseFont bftitle = BaseFont.CreateFont("C:\\Windows\\Fonts\\SIMHEI.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); //用系统中的字体文件SimHei.ttf创建文件字体 iTextSharp.text.Font fonttitle = new iTextSharp.text.Font(bftitle, 22); //标题字体,大小30 //单元格中的字体,大小12 //添加标题 iTextSharp.text.Paragraph Title = new iTextSharp.text.Paragraph(lb.OBSLINENAME + " 测线基本情况", fonttitle); //添加段落,第二个参数指定使用fonttitle格式的字体,写入中文必须指定字体否则无法显示中文 Title.Alignment = iTextSharp.text.Rectangle.ALIGN_CENTER; //设置居中 document.Add(Title); //将标题段加入PDF文档中 //空一行 BaseFont bf1 = BaseFont.CreateFont("C:\\Windows\\Fonts\\SIMSUN.TTC,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); //用系统中的字体文件SimSun.ttc创建文件字体 iTextSharp.text.Font ftitle = new iTextSharp.text.Font(bf1, 15); iTextSharp.text.Paragraph nullp = new iTextSharp.text.Paragraph(" ", ftitle); document.Add(nullp); PdfPTable table = CreateTable(lb); document.Add(table); //将表格加入PDF文档中 document.Close(); myStream.Close(); // PDFOperation pdf = new PDFOperation(); //pdf.Open(new FileStream(pFilePath, FileMode.Create)); //pdf.SetBaseFont("C:\\WINDOWS\\FONTS\\STSONG.TTF"); ////pdf.SetFont(20); //pdf.AddParagraph(sb.SiteName + " 跨断层监测场地基本情况", 15, 1, 20, 0, 0); //pdf.Close(); } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// 获取测线选择状态的数据主键ID集合 lwl /// </summary> /// <param name="parentNode">父级节点</param> private void GetCheckedNode(TreeListNode parentNode, ref List <LineBean> lblist) { if (parentNode.Nodes.Count == 0) { return;//递归终止 } foreach (TreeListNode node in parentNode.Nodes) { if (node.CheckState == CheckState.Checked) { TreeBean nodeInfo = node.TreeList.GetDataRecordByNode(node) as TreeBean; LineBean tag = nodeInfo.Tag as LineBean; if (tag != null) { lblist.Add(tag); } } GetCheckedNode(node, ref lblist); } }
/// <summary> /// 初始化测项树列表 /// </summary> private void InitTree() { List <String> remoteExcelList = new List <string>(); remoteExcelList = getFile(SystemInfo.DatabaseCache); List <TreeBean> tblist = new List <TreeBean>(); foreach (string remoteLineCode in remoteExcelList) { try { string subLineCode = remoteLineCode.Substring(0, remoteLineCode.Length - 4); LineBean ol = LineBll.Instance.GetInfoByID(subLineCode); TreeBean tb = new TreeBean(); tb.KeyFieldName = ol.OBSLINECODE; tb.ParentFieldName = ol.SITECODE; tb.Caption = ol.OBSLINENAME; tb.Tag = ol;//lwl tblist.Add(tb); } catch (Exception ex) { continue; } } this.treeListData.ClearNodes(); this.treeListData.DataSource = tblist; //树列表显示 this.treeListData.KeyFieldName = "KeyFieldName"; //这里绑定的ID的值必须是独一无二的 this.treeListData.ParentFieldName = "ParentFieldName"; //表示使用parentID进行树形绑定 this.treeListData.OptionsView.ShowCheckBoxes = true; this.treeListData.OptionsBehavior.AllowRecursiveNodeChecking = true; this.treeListData.OptionsBehavior.Editable = false; this.treeListData.ExpandAll(); }
/// <summary> /// 加载测项合并数列表 /// </summary> /// <returns></returns> public List <TreeBean> ObslineMergeTree() { List <TreeBean> tblist = new List <TreeBean>(); try { IEnumerable <UnitInfoBean> ubEnumt = UnitInfoBll.Instance.GetAll(); foreach (UnitInfoBean sb in ubEnumt) { TreeBean tb = new TreeBean(); if (sb.UnitCode == "152002" || sb.UnitCode == "152003" || sb.UnitCode == "152006" || sb.UnitCode == "152008" || sb.UnitCode == "152009" || sb.UnitCode == "152010" || sb.UnitCode == "152012" || sb.UnitCode == "152015" || sb.UnitCode == "152022" || sb.UnitCode == "152023" || sb.UnitCode == "152026" || sb.UnitCode == "152029" || sb.UnitCode == "152032" || sb.UnitCode == "152034" || sb.UnitCode == "152035" || sb.UnitCode == "152036" || sb.UnitCode == "152039" || sb.UnitCode == "152040" || sb.UnitCode == "152041" || sb.UnitCode == "152042" || sb.UnitCode == "152043" || sb.UnitCode == "152044" || sb.UnitCode == "152045" || sb.UnitCode == "152046" || sb.UnitCode == "152001" || sb.UnitCode == "152047") { continue; } tb.KeyFieldName = sb.UnitCode; tb.ParentFieldName = "0"; tb.Caption = sb.UnitName; tb.SiteType = ""; tb.LineStatus = ""; tb.Tag = sb;//lwl tblist.Add(tb); } List <SiteBean> sbEnumt = new List <SiteBean>(); DataTable dt = SiteBll.Instance.GetDataTable(@"select sitecode, unitcode,sitename from t_siteinfodb"); foreach (DataRow dr in dt.Rows) { SiteBean sgsb = new SiteBean(); sgsb.SiteCode = dr["sitecode"].ToString(); sgsb.SiteName = dr["sitename"].ToString(); sgsb.UnitCode = dr["unitcode"].ToString(); sbEnumt.Add(sgsb); } //场地列表显示 List <string> olSiteCode = new List <string>(); foreach (SiteBean sb in sbEnumt) { olSiteCode.Add(sb.SiteCode); TreeBean tb = new TreeBean(); tb.KeyFieldName = sb.SiteCode; tb.ParentFieldName = sb.UnitCode; tb.Caption = sb.SiteName; tb.SiteType = sb.SiteCode.Substring(0, 1) == "L" ? "流动" : "定点"; tb.Tag = sb.SiteCode;//lwl tblist.Add(tb); } List <String> remoteExcelList = new List <string>(); remoteExcelList = getFile(SystemInfo.DatabaseCache); foreach (string remoteLineCode in remoteExcelList) { string subLineCode = remoteLineCode.Substring(0, remoteLineCode.Length - 4); LineBean ol = LineBll.Instance.GetInfoByID(subLineCode); if (olSiteCode.Contains(ol.SITECODE)) { TreeBean tb = new TreeBean(); tb.KeyFieldName = ol.OBSLINECODE; tb.ParentFieldName = ol.SITECODE; tb.Caption = ol.OBSLINENAME; tb.Tag = ol;//lwl tblist.Add(tb); } } } catch { //throw new Exception(ex.Message); } return(tblist); }
public int Update(LineBean model) { return(LineDal.Instance.Update(model)); }
public int Add(LineBean model) { return(LineDal.Instance.Insert(model)); }
private PdfPTable CreateTable(LineBean lb) { BaseFont bf1 = BaseFont.CreateFont("C:\\Windows\\Fonts\\SIMSUN.TTC,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); //用系统中的字体文件SimSun.ttc创建文件字体 iTextSharp.text.Font namefont = new iTextSharp.text.Font(bf1, 12); iTextSharp.text.Font contentfont = new iTextSharp.text.Font(bf1, 10); contentfont.SetColor(105, 105, 105); PdfPTable table = new PdfPTable(4); //table.TableEvent = new AlternatingBackground(); table.WidthPercentage = 85; //设置表格占的宽度,百分比 table.SetWidths(new int[] { 35, 65, 35, 65 }); //两个单元格所占比例 20% 80% //table.TotalWidth = 200;//设置表格占的宽度,单位点数 //table.SetTotalWidth(); //table.SetWidthPercentage(); //cell.Colspan = (4); //合并列; //cell.Rowspan = (1); //合并行; PdfPCell cell = new PdfPCell(new Phrase("测线名称", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.OBSLINENAME, contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("所属场地", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(SiteBll.Instance.GetSitenameByID(lb.SITECODE), contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("曾用名称", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.NAMEBEFORE, contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("基础测项", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.BASEOBSTYPE, contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("辅助测项", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.AIDSOBSTYPE, contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("观测周期", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.OBSCYCLE, contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("上盘-下盘", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.UP_BOT, contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("建立时间", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.BUILDDATE, contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("开测时间", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.STARTDATE, contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("停测时间", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.ENDDATE, contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("测线长度", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.LENGTH, contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("测站数", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.STATIONCOUNT, contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("所属断层", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.FAULTZONE, contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("断层走向", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.FAULTSTRIKE, contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("断层倾向", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.FAULTTENDENCY, contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("断层倾角", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.FAULTDIP, contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("夹角", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.LINE_FAULT_ANGLE, contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("测点岩性", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.PTROCK, contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("仪器更换情况", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.INSTRREPLACEDISCRIP, contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("运行状况", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.LINESTATUS, contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("起点", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.STARTPOINTCODE, contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("终点", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.ENDPOINTCODE, contentfont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase("备注", namefont)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE; cell.MinimumHeight = 30; table.AddCell(cell); cell = new PdfPCell(new Phrase(lb.NOTE, contentfont)); cell.Colspan = (3); //合并列; table.AddCell(cell); return(table); }