标签:textbox 类型 lin font sum idt spel enc margin
/// <summary>
/// 生成grid++report模板
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public int GenerateNurModel(DataTable dt)
{
BNuringList BNu=new BNuringList ();
string NurName = dt.Rows[0]["NurName"].ToString();
string NurName1 = dt.Rows[0]["NurName1"].ToString();
string SpellNurName = GetSpellCode(NurName);
string SpellNurName1 = GetSpellCode(NurName1);
DataTable fielddt = BNu.FliterTree("-1",dt);
string filepath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
filepath += "H11111\\rpt\\" + SpellNurName + "(" + SpellNurName1 + ")" + ".grf";
//@"F:\" + NurName +"("+NurName1+")"+ ".grf"
// MessageBox.Show(filepath);
FileInfo myFile = new FileInfo(filepath);
StreamWriter sw = myFile.CreateText();
string str = "Object Report \r\n"
+ "Version=‘6.2.0.0‘\r\n"
+ " Title=‘" + NurName + "‘\r\n"
+ " PrintAsDesignPaper=F \r\n"
+ " Object Font\r\n"
+ " Name=‘宋体‘\r\n"
+ " Size=105000,0\r\n"
+ " Weight=400\r\n"
+ " Charset=134\r\n"
+ " End\r\n"
+ " Object Printer\r\n"
+ " Oriention=Landscape\r\n"
+ " LeftMargin=1\r\n"
+ " TopMargin=2\r\n"
+ " RightMargin=1\r\n"
+ " BottomMargin=2\r\n"
+ " End\r\n";
str += " Object DetailGrid\r\n"
+ " CenterView=T\r\n"
+ " AppendBlankRow=T\r\n"
+ " Object Recordset\r\n"
+ " ConnectionString=‘Provider=SQLOLEDB.1;Persist Security Info=True;User"
+ "ID=sa;Initial Catalog=HISONE_V5;Data Source=DPT0103;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=DPT0103;Use Encryption for Data=False;Tag with column collation when possible=False‘\r\n";
//生成字段域
str += "Items Field\r\n";
string ColumnContentCell = "";
string ItemsColumn = "";
string ColumnTitleCell = "";
string paramater = "";
for (int i = 0; i < fielddt.Rows.Count; i++)
{
string field = fielddt.Rows[i]["DataName"].ToString();
str += "Item\r\n"
+ " Name=‘" + EnCode16ASI(field) + "‘\r\n"//生成字段EnCode16ASI
+" End\r\n";
ItemsColumn += "Item\r\n"
+" Name=‘"+fielddt.Rows[i]["DataName"].ToString()+"‘\r\n"
+" Width=1\r\n"
+" End\r\n";
ColumnContentCell += "Item\r\n"
+ " Column=‘" + fielddt.Rows[i]["DataName"].ToString() + "‘\r\n"
//+ " DataField=‘" + fielddt.Rows[i]["DataName"].ToString() + "‘\r\n"
+ " FreeCell=T\r\n"
+ "CanGrow=T\r\n"
+"CanShrink=T\r\n"
+"Items Control\r\n"
+" Item\r\n"
+ " Type=FieldBox\r\n" //修改他的输入框类型 列如:PictureBox
+" Name=‘PictureBox"+i+"‘\r\n"
+" Dock=Fill\r\n"
+ " DataField=‘" + EnCode16ASI(field) + "‘\r\n"//绑定字段和列
+" End\r\n"
+"End\r\n"
+" End\r\n";
}
str += "End \r\n End\r\n";
str += "Items Column\r\n" + ItemsColumn + "End \r\n";
str += "Object ColumnContent\r\n"
+ "Height=0.73\r\n"
+ " Object Font\r\n"
+ " Name=‘宋体‘\r\n"
+ " Size=90000,0\r\n"
+ " Weight=400\r\n"
+ " Charset=134\r\n"
+ " End\r\n"
+ " Items ColumnContentCell\r\n";
str += ColumnContentCell;
str += "End \r\n End\r\n";
//生成多表头
ColumnTitleCell += "Object ColumnTitle\r\n"
+ " Height=2.77813\r\n"
+ " Object Font\r\n"
+ " Name=‘宋体‘\r\n"
+ " Bold=T\r\n"
+ " Charset=134\r\n"
+ " End\r\n";
ColumnTitleCell+= StringMulTitle(dt, 0);
ColumnTitleCell += "End\r\n";
str += ColumnTitleCell;
paramater+="Object PageHeader\r\n"
+ " Height=0\r\n"
+ " End\r\n"
+ " Object PageFooter\r\n"
+ " Height=1.00542\r\n"
+ " Items Control\r\n"
+ " Item\r\n"
+ " Type=RichTextBox\r\n"
+ " Name=‘RichTextBox1‘\r\n"
+ " Left=16.5894\r\n"
+ " Top=1.40229\r\n"
+ " Width=2.4\r\n"
+ " Height=0.5\r\n"
+ " End\r\n"
+ " Item\r\n"
+ " Type=MemoBox\r\n"
+ " Name=‘MemoBox2‘\r\n"
+ " Left=0.79375\r\n"
+ " Top=0.211667\r\n"
+ " Width=26.0085\r\n"
+ " Height=0.608542\r\n"
+ " TextAlign=MiddleCenter\r\n"
+ " Text=‘第 [#SystemVar(PageNumber)#] 页‘\r\n"
+ " End\r\n"
+ " End\r\n"
+ "End\r\n"
+ "Items Parameter\r\n"
+ " Item\r\n"
+ " Name=‘病区‘\r\n"
+ " End\r\n"
+ " Item\r\n"
+ " Name=‘床号‘\r\n"
+ " End\r\n"
+ " Item\r\n"
+ " Name=‘姓名‘\r\n"
+ " End\r\n"
+ " Item\r\n"
+ " Name=‘性别‘\r\n"
+ " End\r\n"
+ " Item\r\n"
+ " Name=‘年龄‘\r\n"
+ " End\r\n"
+ " Item\r\n"
+ " Name=‘住院号‘\r\n"
+ " End\r\n"
+ " Item\r\n"
+ " Name=‘入院日期‘\r\n"
+ " End\r\n"
+ " Item\r\n"
+ " Name=‘诊断‘\r\n"
+ " End\r\n"
+ " Item\r\n"
+ " Name=‘科别‘\r\n"
+ " End\r\n"
+ "End\r\n"
+ "Items ReportHeader\r\n"
+ " Item\r\n"
+ " Name=‘ReportHeader1‘\r\n"
+ " Height=2.59292\r\n"
+ " Items Control\r\n"
+ " Item\r\n"
+ " Type=MemoBox\r\n"
+ " Name=‘科别‘\r\n"
+ " Top=1.5875\r\n"
+ " Width=26.8023\r\n"
+ " Height=1.00542\r\n"
+ " Text=‘科别:[#科别#] 病区:[#病区#] 床号:[#床号#] 姓名:[#姓名#] 性别:[#性别#] 年龄:[#年龄#] 住院号:[#住院号#] 入院日期:[#入院日期#] 诊断:[#诊断#]‘\r\n"
+ " End\r\n"
+ " Item\r\n"
+ " Type=MemoBox\r\n"
+ " Name=‘MemoBox1‘\r\n"
+ " Dock=Top\r\n"
+ " Center=Horizontal\r\n"
+ " Height=1.5875\r\n"
+ " Object Font\r\n"
+ " Name=‘宋体‘\r\n"
+ " Size=157500,0\r\n"
+ " Bold=T\r\n"
+ " Charset=134\r\n"
+ " End\r\n"
+ " TextAlign=MiddleCenter\r\n"
+ " Text=‘"+NurName+"‘\r\n"
+ " End\r\n"
+ " End\r\n"
+ " RepeatOnPage=T\r\n"
+ " End\r\n"
+ "End\r\n";
str += paramater;
str += "End";
sw.WriteLine(str);
sw.Close();
return 0;
}
根据dataTable动态生成grid++report 的方法
标签:textbox 类型 lin font sum idt spel enc margin
原文地址:http://www.cnblogs.com/tanhu/p/7306620.html