日期:2014-05-20 浏览次数:20824 次
/// <summary> /// 打印机列表 /// </summary> /// <returns></returns> private ArrayList GetPrinter() { ArrayList array = new ArrayList(); foreach (string iprt in System.Drawing.Printing.PrinterSettings.InstalledPrinters) array.Add(iprt); return array; }
ReportDocument doc = new ReportDocument(); doc.PrintOptions.PrinterName = ddl_printList.SelectedValue.ToString(); CrytalName = "../PrintManager/Connection.rpt"; doc.Load(Server.MapPath("" + CrytalName + "")); doc.SetDataSource(dsDataSet); doc.PrintToPrinter(1, false, 0, 0);
/// <summary>
/// 打印
/// </summary>
/// <param name="sender"> </param>
/// <param name="e"> </param>
protected void btnSurePrint_Click(object sender, EventArgs e)
{
string id = Request.QueryString["id"];//结论书id
string printId = string.Empty;
for (int i = 0; i < this.cblPrint.Items.Count; i++)
{
if (this.cblPrint.Items[i].Selected)
{
printId += this.cblPrint.Items[i].Value+",";
}
}
printId += printId.Substring(0, printId.LastIndexOf(','));//需要打印的id
#region 选择性打印
DB_Conclusion dsDataSet = new DB_Conclusion();
string con = ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString;
using (SqlConnection objSqlConnection = new SqlConnection(con))
{
//结论书
string sql = "SELECT a.cId, a.cTotalNo, a.cTitle, a.cContent, a.cAddPeople, a.cDate, b.oName FROM Conclusion AS a INNER JOIN Office AS b ON a.cIdentificationUnit = b.oid and a.cid=" + id;
SqlDataAdapter sdaAdapter = new SqlDataAdapter(sql, objSqlConnection);
sdaAdapter.Fill(dsDataSet, "Conclusion");
sdaAdapter.Dispose();
//sdaAdapter.
//现场勘查表
string sql2 = "SELECT sId, sCid, sPeople, sDate, sPlace, sObject, sAcompany, sRemark, sIsregout FROM Scene where sCid=" + id;
SqlDataAdapter sdaAdapter2 = new SqlDataAdapter(sql2, objSqlConnection);
sdaAdapter2.Fill(dsDataSet, "Scene");
sdaAdapter2.Dispose();