示例#1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            Recieptgeneral rpt = new Recieptgeneral();

            rpt.Site = this.Site;
            return(rpt);
        }
示例#2
0
        private void ReportData(string flag)
        {
            try
            {
                Recieptgeneral myreceiptreport = new Recieptgeneral();
                string         ReportPath      = Server.MapPath("Recieptgeneral.rpt");
                myreceiptreport.Load(ReportPath);
                //    ds.Tables[0] = TblAdmitCard;
                //    rpt.SetDataSource(ds.Tables["TblAdmitCard"]);

                //rpt.SetParameterValue("Semester", ddlsem.SelectedItem.Text);
                //rpt.SetParameterValue("RptHead", RptHead);

                myreceiptreport.SetParameterValue("par_rcptno", Session["rcptno1"].ToString());
                myreceiptreport.SetParameterValue("par_rcptdt", Session["date1"].ToString());
                myreceiptreport.SetParameterValue("par_lcocd", Session["lcocd1"].ToString());
                myreceiptreport.SetParameterValue("par_lconm", Session["lconm1"].ToString());
                myreceiptreport.SetParameterValue("par_cashier", Session["cashiername"].ToString());
                myreceiptreport.SetParameterValue("par_amt", Session["amt1"].ToString());
                myreceiptreport.SetParameterValue("par_paymode", Session["paymode1"].ToString());
                if (Session["paymode1"].ToString() == "Cheque" || Session["paymode1"].ToString() == "DD")
                {
                    myreceiptreport.SetParameterValue("par_cheqno", Session["cheqno1"].ToString());
                    myreceiptreport.SetParameterValue("par_bnknm", Session["bnknm1"].ToString());
                }
                else if (Session["paymode1"].ToString() == "Cash")
                {
                    myreceiptreport.SetParameterValue("par_cheqno", "N/A");
                    myreceiptreport.SetParameterValue("par_bnknm", "N/A");
                }
                myreceiptreport.SetParameterValue("par_premark", Session["premark1"].ToString());
                myreceiptreport.SetParameterValue("par_company", Session["company"].ToString());
                myreceiptreport.SetParameterValue("par_address", Session["address"].ToString());
                if (Session["paymode1"].ToString() == "Cheque")
                {
                    myreceiptreport.SetParameterValue("par_chq", "cheque is subject to clearance");
                }
                else
                {
                    myreceiptreport.SetParameterValue("par_chq", ".");
                }
                String ExportPath = Server.MapPath("..\\MyExcelFile\\") + Session["rcptno1"].ToString() + " myrecpt " + DateTime.Now.ToString("dd-MM-yy hh mm ss") + ".pdf";
                myreceiptreport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, ExportPath);

                FileStream fs = null;
                fs = File.Open(ExportPath, FileMode.Open);
                byte[] btFile = new byte[fs.Length];
                fs.Read(btFile, 0, Convert.ToInt32(fs.Length));
                fs.Close();
                Response.AddHeader("Content-disposition", "attachment; filename=" + Session["rcptno1"].ToString() + " myrecpt " + DateTime.Now.ToString("dd-MM-yy hh mm ss") + ".pdf");
                Response.ContentType = "application/octet-stream";
                Response.BinaryWrite(btFile);
                Response.End();
                //CrystalReportViewer1.ReportSource = myreceiptreport;  ..shri
                //CrystalReportViewer1.DataBind();
                //if (flag == "P")
                //{
                //    myreceiptreport.PrintToPrinter(1, false, 0, 0);
                //}
                //myreceiptreport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, @"C:\Temp\PDF\a.pdf");

                //myreceiptreport.Dispose();
                //myreceiptreport.Close();

                //FileStream fs = null;
                //fs = File.Open(@"C:\Temp\PDF\\a.pdf", System.IO.FileMode.Open);
                //byte[] btFile = new byte[fs.Length];
                //fs.Read(btFile, 0, Convert.ToInt32(fs.Length));
                //fs.Close();
                //Response.AddHeader("Content-disposition", "attachment; filename=a.pdf");
                //Response.ContentType = "application/octet-stream";
                //Response.BinaryWrite(btFile);
                //Response.End();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message.ToString());
            }
        }