|
|
|
|
using CrystalDecisions.CrystalReports.Engine;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing.Printing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Web.UI;
|
|
|
|
|
using System.Web.UI.WebControls;
|
|
|
|
|
using TradeData;
|
|
|
|
|
using TradeModel;
|
|
|
|
|
|
|
|
|
|
namespace TradeManage.PrintTemplate
|
|
|
|
|
{
|
|
|
|
|
public partial class GoodPrint : System.Web.UI.Page
|
|
|
|
|
{
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
PrintDocument prtdoc = new PrintDocument();
|
|
|
|
|
string strDefaultPrinter = prtdoc.PrinterSettings.PrinterName;//获取默认的打印机名
|
|
|
|
|
foreach (String strPrinter in PrinterSettings.InstalledPrinters)
|
|
|
|
|
//在列表框中列出所有的打印机,
|
|
|
|
|
{
|
|
|
|
|
printerList.Items.Add(strPrinter);
|
|
|
|
|
//if (strPrinter == strDefaultPrinter)//把默认打印机设为缺省值
|
|
|
|
|
//{
|
|
|
|
|
// printerList.SelectedIndex = printerList.Items.IndexOf(strPrinter);
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
//return;
|
|
|
|
|
|
|
|
|
|
//string[] idarr = Request.QueryString["Detail"].ToString().Trim(',').Split(',');
|
|
|
|
|
//if (!IsPostBack)
|
|
|
|
|
//{
|
|
|
|
|
List<GoodWarePrint> gwplist = new List<GoodWarePrint>();
|
|
|
|
|
|
|
|
|
|
GoodWarePrint md = new GoodWarePrint();
|
|
|
|
|
|
|
|
|
|
if (Session["GoodWarePrint"] != null)
|
|
|
|
|
gwplist = (List<GoodWarePrint>)Session["GoodWarePrint"];
|
|
|
|
|
|
|
|
|
|
//HuoWuData hwd = new HuoWuData();
|
|
|
|
|
|
|
|
|
|
//for (int i = 0; i < idarr.Length; i++)
|
|
|
|
|
//{
|
|
|
|
|
// string[] goodstr = idarr[i].ToString().Split('-');
|
|
|
|
|
// int total = Convert.ToInt32(goodstr[goodstr.Length - 2].ToString());
|
|
|
|
|
// string wareno = goodstr[goodstr.Length - 1].ToString();
|
|
|
|
|
// for(int j=0;j<total;j++)
|
|
|
|
|
// {
|
|
|
|
|
// GoodWarePrint gwp = new GoodWarePrint();
|
|
|
|
|
|
|
|
|
|
// gwp.WareNo = wareno;
|
|
|
|
|
// gwp.GoodNo = goodstr[0] == null ? goodstr[1] : (goodstr[0] == "" ? goodstr[1] : goodstr[0]) + "-" + goodstr[2];
|
|
|
|
|
// gwp.Descript = goodstr[3] + " " + goodstr[4];
|
|
|
|
|
|
|
|
|
|
// gwplist.Add(gwp);
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
if (gwplist == null || gwplist.Count == 0)
|
|
|
|
|
return;
|
|
|
|
|
CrystalReportSource1.ReportDocument.SetDataSource(gwplist);
|
|
|
|
|
|
|
|
|
|
CrystalReportSource1.DataBind();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//CrystalReportViewer1.PrintMode = CrystalDecisions.Web.PrintMode.ActiveX;
|
|
|
|
|
//PrintDocument prtdoc = new PrintDocument();
|
|
|
|
|
//ReportDocument rptSales = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void Find_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
List<GoodWarePrint> gwplist = new List<GoodWarePrint>();
|
|
|
|
|
if (Session["GoodWarePrint"] != null)
|
|
|
|
|
gwplist = (List<GoodWarePrint>)Session["GoodWarePrint"];
|
|
|
|
|
ReportDocument rptSales = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
|
|
|
|
|
rptSales.FileName = Server.MapPath("GoodBatch.rpt");
|
|
|
|
|
rptSales.SetDataSource(gwplist);
|
|
|
|
|
//PrintDocument prtdoc = new PrintDocument();
|
|
|
|
|
//string strDefaultPrinter = prtdoc.PrinterSettings.PrinterName;
|
|
|
|
|
|
|
|
|
|
// then print, this is the important thing here
|
|
|
|
|
//rptSales.PrintOptions.PrinterName = printerList.SelectedValue;
|
|
|
|
|
//rptSales.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.DefaultPaperSize;
|
|
|
|
|
//rptSales.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Auto;
|
|
|
|
|
|
|
|
|
|
//parameters here depending on your situation.
|
|
|
|
|
rptSales.PrintToPrinter(1, true, 1, 9999);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|