/Reports/Receipt.aspx.cs

http://github.com/khaneh/Orders · C# · 86 lines · 65 code · 11 blank · 10 comment · 2 complexity · d058c95f6f42006d5bca1193fb1b9a49 MD5 · raw file

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Web;
  7. using System.Web.SessionState;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.HtmlControls;
  11. using CrystalDecisions.CrystalReports.Engine;
  12. using CrystalDecisions.Shared;
  13. namespace Reports
  14. {
  15. /// <summary>
  16. /// Summary description for WebForm1.
  17. /// </summary>
  18. public class ReceiptWebForm : System.Web.UI.Page
  19. {
  20. protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
  21. protected System.Web.UI.WebControls.Button Button1;
  22. protected System.Web.UI.HtmlControls.HtmlForm Form1;
  23. protected ReportManager rm = new ReportManager();
  24. Receipt crReport = new Receipt();
  25. string paramName= "Recept_ID";
  26. string param;
  27. private void Page_Load(object sender, System.EventArgs e)
  28. {
  29. param = Request.QueryString.Get(paramName);
  30. Boolean x = rm.initReport(crReport, CrystalReportViewer1, param, paramName);
  31. if(!x)
  32. {
  33. Response.Write ("error: Parameter Needed");
  34. Response.End();
  35. }
  36. }
  37. #region Web Form Designer generated code
  38. override protected void OnInit(EventArgs e)
  39. {
  40. //
  41. // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  42. //
  43. InitializeComponent();
  44. base.OnInit(e);
  45. DataBind();
  46. }
  47. /// <summary>
  48. /// Required method for Designer support - do not modify
  49. /// the contents of this method with the code editor.
  50. /// </summary>
  51. private void InitializeComponent()
  52. {
  53. this.Button1.Click += new System.EventHandler(this.Button1_Click);
  54. this.Load += new System.EventHandler(this.Page_Load);
  55. }
  56. #endregion
  57. private void Button1_Click(object sender, System.EventArgs e)
  58. {
  59. rm.SetPrinter(Request.UserHostAddress);
  60. Boolean x = rm.printReport(crReport, CrystalReportViewer1, param, paramName);
  61. if(x)
  62. {
  63. Response.Write("<br><br><br><br><br><br><br><br><br><br><br><br><br><font face=titr color=red size=5><center>");
  64. Response.Write(" ǁ <br>");
  65. Response.Write(" "+crReport.PrintOptions.PrinterName);
  66. Response.Write("</center></font>");
  67. }
  68. else
  69. {
  70. Response.Write ("error: Problem in printing report");
  71. Response.End();
  72. }
  73. }
  74. }
  75. }