个别打印
来源:互联网 发布:sql from unixtime 编辑:程序博客网 时间:2024/09/21 09:21
private void btnPrint_Click(object sender, System.EventArgs e)
{
try
{
string strCount="select count(xjh) from xs_ksxx where xjh='"+this.gXJH.Text.Trim()+"'";
LocalDb ldb=new LocalDb();
if(ldb.ExecScalar(strCount)==0)//不存在该学生
{
((CrystalDecisions.CrystalReports.Engine.TextObject)crenp.ReportDefinition.ReportObjects["TxtTitle"]).Text="打印考生"+this.gXM.Text.Trim()+"的准考证";
//建表
this.ds.Tables.Clear();
this.ds.Tables.Add("zkz");
// 添加两个字段
ds.Tables[0].Columns.Add("xjh", System.Type.GetType("System.String"));
ds.Tables[0].Columns.Add("zkzh", System.Type.GetType("System.String"));
ds.Tables[0].Columns.Add("xxdm", System.Type.GetType("System.String"));
ds.Tables[0].Columns.Add("xm", System.Type.GetType("System.String"));
ds.Tables[0].Columns.Add("xb", System.Type.GetType("System.String"));
ds.Tables[0].Columns.Add("zp", System.Type.GetType("System.Byte[]"));
ds.Tables[0].Columns.Add("kch", System.Type.GetType("System.Int32"));
ds.Tables[0].Columns.Add("kc", System.Type.GetType("System.String"));
ds.Tables[0].Columns.Add("zwh", System.Type.GetType("System.String"));
ds.Tables[0].Columns.Add("kssj", System.Type.GetType("System.String"));
ds.Tables[0].Columns.Add("jssj", System.Type.GetType("System.String"));
// 添加
AddImageRow(this.ds.Tables[0],this.gXJH.Text.Trim(),this.gZKZH.Text.Trim(),this.gKD.Text.Trim(),this.gXM.Text.Trim(),this.cbbXB.Text.Trim(),Application.StartupPath+"//Images//NoPhoto.jpg",Convert.ToInt32(this.gKCH.Text.Trim()),"",this.gZWH.Text.Trim(),this.dtpKSSJ.Value.ToString().Trim(),this.dtpJSSJ.ToString().Trim());
//Directory.GetCurrentDirectory()
}
else
{
string str="select j.xjh,s.zkzh,j.xxdm,j.xm,j.xb,j.zp,s.kch,s.kc,s.zwh,k.kssj,k.jssj from(xs_ksxx s inner join xs_jbxx j on s.xjh=j.xjh) inner join ks_kcsj k on s.ksh=k.ksh and s.kc=k.kc where s.xjh='"+this.gXJH.Text.Trim()+"'";
ldb.Exec4DS(str,"zkz",out ds);
((CrystalDecisions.CrystalReports.Engine.TextObject)crenp.ReportDefinition.ReportObjects["TxtTitle"]).Text="打印考生"+ds.Tables[0].Rows[0]["xm"].ToString().Trim()+"的准考证";
}
crenp.SetDataSource(this.ds);
crenp.OpenSubreport("CRcg").SetDataSource(this.ds.Tables[0].Rows[0]["zp"]);
crenp.OpenSubreport("CRzkz").SetDataSource(this.ds.Tables[0].Rows[0]["zp"]);
crenp.Refresh();
FmExamNoPrint enp=new FmExamNoPrint();
enp.Show();
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
/// <summary>
/// 添加图片
/// </summary>
/// <param name="tbl"></param>
/// <param name="name"></param>
/// <param name="filename"></param>
private void AddImageRow(DataTable tbl,string xjh,string zkzh,string xxdm,string xm,string xb,string filename,int kch,string kc,string zwh,string kssj,string jssj)
{
FileStream fs = new FileStream(filename, FileMode.Open); // 创建文件流
BinaryReader br = new BinaryReader(fs); // 创建二进制读取器
DataRow row;
// 创建一个新的数据行
row = tbl.NewRow();
// 设置 country 字段和 image 字段
row["xjh"] = xjh;
row["zkzh"] = zkzh;
row["xxdm"] = xxdm;
row["xm"] = xm;
row["xb"] = xb;
row["zp"] = br.ReadBytes((int)br.BaseStream.Length);
row["kch"] = kch;
row["kc"] = kc;
row["zwh"] = zwh;
row["kssj"] = kssj;
row["jssj"]=jssj;
// 将数据行添加到表中
tbl.Rows.Add(row);
// 清除
br = null;
fs = null;
}
- 个别打印
- gdb调试个别问题
- sql操作个别语句
- 严重BS个别网站
- 了非个别
- 个别计价法
- socket个别函数
- CSS3圆角(个别的)
- C# 个别类型转换
- UIBtutton 个别翻译
- 树形DP(个别未完成)
- 个别网页打不开怎么办
- Java个别关键字
- iOS 个别问题
- Git个别理解
- 关于JqueryUI个别属性
- SSL握手中的个别细节
- 给表建个别名
- 关于jspsmartupload的上传
- 终于在csdn上安家了!这个博客将作为我学习java历程,记录我心得的一个地方
- C#使用ICSharpCode.SharpZipLib压缩文件
- 遍历文件夹中指定文件
- MYSQL操作类
- 个别打印
- window.showModelessDialog()
- test图片
- ADO访问数据库.
- 基于PHP开发WEB程序之工具推荐
- 关于最近工作的一点感想
- 使用遗传算法计算方程的最大值
- jspsmartupload配置问题
- ComboBox的下拉选项的树状显示的几种方法对比