4,819
社区成员




//打印
protected void Button4_Click(object sender, EventArgs e)
{
string sqlstring=null;
Session["language"] = this.RBL_language.SelectedValue;
DataSet ds = new DataSet();
QuotationDB qdb = new QuotationDB();
if (this.Panel_quotNO.Visible)
{
if (this.RBL_language.SelectedValue == "C")
{
sqlstring = "select b.*,a.* from V_reportmaster b,V_reportFee a where b.QuotationCode = a.QuotationCode";
}
else if (this.RBL_language.SelectedValue == "E")
{
sqlstring = "select b.*,a.* from V_reportmasterE b,V_reportFee a where b.QuotationCode = a.QuotationCode";
}
else if (this.RBL_language.SelectedValue == "J")
{
sqlstring = "select b.*,a.* from V_reportmasterJ b,V_reportFee a where b.QuotationCode = a.QuotationCode";
}
// string sqlstring = "SELECT [QuotationCode] FROM [QuotationMaster]";
sqlstring += " and a.QuotationCode like '" + this.TB_QuotNO.Text + "'";
// this.SqlDataSource1.SelectCommand = sqlstring;
}
if (this.Panel_term.Visible)
{
if (this.RBL_language.SelectedValue == "C")
{
sqlstring="select *,V_reportFee.* from V_reportmaster a,V_reportFee where V_reportmaster.QuotationCode = V_reportFee.QuotationCode";
}else if(this.RBL_language.SelectedValue == "E")
{
sqlstring = "select *,V_reportFee.* from V_reportmasterE a,V_reportFee where V_reportmaster.QuotationCode = V_reportFee.QuotationCode";
}
else if (this.RBL_language.SelectedValue== "J")
{
sqlstring = "select *,V_reportFee.* from V_reportmasterJ a,V_reportFee where V_reportmaster.QuotationCode = V_reportFee.QuotationCode";
}
//客户条件
if (this.TBCustomerCode.Text != "")
{
sqlstring += " and a.CustomerID='" + this.TBCustomerCode.Text + "' ";
}
//发货人条件
if (this.TB_shipperCode.Text != "")
{
sqlstring += " and a.ShippersID='" + this.TB_shipperCode.Text + "' ";
}
//收货人条件
if (this.TB_consigneeCode.Text != "")
{
sqlstring += " and a.ConsigneeID='" + this.TB_consigneeCode.Text + "' ";
}
//目的港
if (this.TBPortCode.Text != "")
{
sqlstring += " and a.DestPort='" + this.TBPortCode.Text + "' ";
}
//担当条件
if (this.TBOperator.Text != "")
{
sqlstring += " and a.Operator='" + this.TBOperator.Text + "' ";
}
//有效期条件
if (this.TBvalidityDate.Text != "")
{
sqlstring += " and a.ValidityDate='" + this.TBvalidityDate.Text + "' ";
}
this.SqlDataSource1.SelectCommand = sqlstring;
}
ds = qdb.getQuotationC(sqlstring);
DataSourceSelectArguments selectArg = new DataSourceSelectArguments();
CrystalDecisions.Shared.ParameterDiscreteValue pcode = new CrystalDecisions.Shared.ParameterDiscreteValue();
CrystalDecisions.CrystalReports.Engine.ReportDocument rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
if (Session["language"] != null && Session["language"] != "")
{
rd.Load(Server.MapPath("report\\Quotation" + Session["language"].ToString() + ".rpt"));
}
else
{
rd.Load(Server.MapPath("report\\QuotationC.rpt"));
}
rd.PrintOptions.PrinterName = DDL_printer.SelectedValue;
rd.SetDataSource(ds.Tables[0]);
try
{
rd.PrintToPrinter(1,false,0,0);
// rd.PrintToPrinter(1, false, int.Parse(this.TB_Pfrom.Text), int.Parse(this.TB_Pto.Text));//20061215
rd.Dispose();
}
catch
{
Response.Write("<script>window.alert('打印机状态出错,请重新选择!')</script>");
}
}
private void PrintReport(string printerName)
{
PageMargins margins;
// 获取 PageMargins 结构并设置
// 报表的边距。
margins = Report.PrintOptions.PageMargins;
margins.bottomMargin = 350;
margins.leftMargin = 350;
margins.rightMargin = 350;
margins.topMargin = 350;
// 应用页边距。
Report.PrintOptions.ApplyPageMargins(margins);
// 选择打印机。
Report.PrintOptions.PrinterName = printerName;
// 打印报表。将 startPageN 和 endPageN
// 参数设置为 0 表示打印所有页。
Report.PrintToPrinter(1, false,0,0);
}