我想在水晶报表中打印多个标签副本,这是我的代码一次打印一个标签,但是我希望用户输入参数以打印要打印的副本数量。
protected void tbsv_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("spInsertbigbale", con);
` { if (ddlBbitem.SelectedValue == "")`
{
Response.Write("<script>alert('Please Select Item Name')</script>");}
` else
{
cmd.CommandType = CommandType.StoredProcedure;
// cmd.Parameters.AddWithValue("@RollNo", TextBox4.Text.Trim());`
` cmd.Parameters.AddWithValue("@Codeitem", ddlBbitem.SelectedValue);`
` cmd.Parameters.AddWithValue("@Bweight", prdbqty.Text.Trim());`
` cmd.Parameters.AddWithValue("@Bpqty", opbbqty.Text.Trim());`
` cmd.Parameters.AddWithValue("@CID", ddlCID.SelectedValue);`
` cmd.Parameters.AddWithValue("@SecID", ddlSecID.SelectedValue);`
cmd.Parameters.AddWithValue("@EntryDate", txtbpentrydate.Text);
cmd.Parameters.Add("@BID", SqlDbType.Int);
cmd.Parameters["@BID"].Direction = ParameterDirection.Output;
` con.Open();`
` cmd.ExecuteNonQuery();`
` int ResultValue = Convert.ToInt32(cmd.Parameters["@BID"].Value);`
` if (ResultValue > 1)
{
Response.Redirect("BigBalePrint.aspx?BID=" + ResultValue + "");
}`
` else
{
Response.Write("<script>alert('Record Not save')</script>");
}
con.Close();
}
}
}
on this page BigBalePrint.aspx i set crystal report viewer
it behind code given below.
public partial class BigBalePrint : System.Web.UI.Page
{
SqlConnection con = new SqlConnection();
ReportDocument rpt = new ReportDocument();
protected void Page_Load(object sender, EventArgs e)
{
//if (!IsPostBack)
{
rpt.Dispose();
rpt.Close();
loadReport();
}
}
private void loadReport()
{
rpt.Dispose();
rpt.Close();`
` con = new SqlConnection("Data Source=DESKTOP-5PJ76B9;Integrated Security=SSPI;Initial` `Catalog=SilverProduction;MultipleActiveResultSets=True;");`
` try
{
con.Open();`
` SqlCommand cmd = new SqlCommand("spbigbaleprint", con);`
` cmd.CommandType = CommandType.StoredProcedure;`
` cmd.Parameters.AddWithValue("@BID", `Request.QueryString["BID"]);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
//SqlDataAdapter adp = new SqlDataAdapter("select prdno,orderno,Codeitem,prdqty from probale", con);
//DataSet ds = new DataSet();
//adp.Fill(ds);
var dialog = new PrintDialog();
{
//ReportDocument rpt = new ReportDocument();
rpt.Load(Server.MapPath("~/Bigbalprint.rpt"));
rpt.SetDataSource(ds.Tables["Table"]);
CRPBigbale.ReportSource = rpt;
rpt.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, false, "Bigbalprd");
}
}
catch (Exception ex) { }
}
protected void CRBigview_Unload(object sender, EventArgs e)
{
if (rpt != null)
{
rpt.Close();
rpt.Dispose();
}
}
}
}
` 请指导。