自定义打印时,创建dataset保存多个入参

发布时间:2023年12月21日

?private void GetPrint(DataSet ds_print1, string jzxh, string jkr, string jzrq, string skrc, string skyj, string tkyj, string stks, string kyjhj, string today)
? ? ? ? {
? ? ? ? ? ? DataSet ds_show = new DataSet();//声明一个dataset?ds_show
? ? ? ? ? ? // 为表ds_show 增加列 ? ? ? ? ?
? ? ? ? ? ? DataTable dt = new DataTable();
? ? ? ? ? ? dt.Columns.Add(new DataColumn("hospital", typeof(string)));
? ? ? ? ? ? dt.Columns.Add(new DataColumn("jzxh", typeof(string)));
? ? ? ? ? ? dt.Columns.Add(new DataColumn("jkr", typeof(string)));
? ? ? ? ? ? dt.Columns.Add(new DataColumn("jzrq", typeof(string)));
? ? ? ? ? ? dt.Columns.Add(new DataColumn("skrc", typeof(string)));
? ? ? ? ? ? dt.Columns.Add(new DataColumn("skyj", typeof(string)));
? ? ? ? ? ? dt.Columns.Add(new DataColumn("tkyj", typeof(string)));
? ? ? ? ? ? dt.Columns.Add(new DataColumn("stks", typeof(string)));
? ? ? ? ? ? dt.Columns.Add(new DataColumn("kyjhj", typeof(string)));
? ? ? ? ? ? dt.Columns.Add(new DataColumn("today", typeof(string)));
? ? ? ? ? ? dt.TableName = "Table1";
? ? ? ? ? ? ds_show.Tables.Add(dt);
? ? ? ? ? ? //为表ds_show赋值
? ? ? ? ? ? DataRow dr_show = ds_show.Tables[0].NewRow();
? ? ? ? ? ? dr_show["hospital"] = SystemParm.HospitalID;
? ? ? ? ? ? dr_show["jzxh"] = jzxh;
? ? ? ? ? ? dr_show["jkr"] = jkr;
? ? ? ? ? ? dr_show["jzrq"] = jzrq;
? ? ? ? ? ? dr_show["skrc"] = skrc;
? ? ? ? ? ? dr_show["skyj"] = skyj;
? ? ? ? ? ? dr_show["tkyj"] = tkyj;
? ? ? ? ? ? dr_show["stks"] = stks;
? ? ? ? ? ? dr_show["kyjhj"] = kyjhj;
? ? ? ? ? ? dr_show["today"] = today;
? ? ? ? ? ? ds_show.Tables[0].Rows.Add(dr_show);

//声明新的dt1和dt2
? ? ? ? ? ? DataTable dt1 = ds_show.Tables[0].Copy();
? ? ? ? ? ? DataTable dt2 = ds_print1.Tables[0].Copy();
? ? ? ? ? ? dt1.TableName = "Table_show";
? ? ? ? ? ? dt2.TableName = "Table_print";

//声明新的ds,把dt1和dt2都放入ds

? ? ? ? ? ? DataSet ds = new DataSet();
? ? ? ? ? ? ds.Tables.Add(dt1);
? ? ? ? ? ? ds.Tables.Add(dt2);
? ? ? ? ? ? String printName = "结账";
? ? ? ? ? ? XtraReportHelper.Print(printName, ds, this.AppCode);//自定义打印
? ? ? ? ? ? //XR_Prepay_acct report = new XR_Prepay_acct(ds);
? ? ? ? ? ? //report.SaveLayoutToXml(@"d:\XR_Prepay_acct.xml");
? ? ? ? ? ? //report.ShowPrintMarginsWarning = false;
? ? ? ? ? ? //report.ShowPrintStatusDialog = false;
? ? ? ? ? ? //report.Print();
? ? ? ? }

文章来源:https://blog.csdn.net/sunping177/article/details/135123473
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。