protected void btnPrint_Click(object sender, EventArgs e) { try { GetSession session = new GetSession(); string databaseDateFormat = "yyyy/MM/dd"; if (Request.Form["rangeBa"] == string.Empty || Request.Form["rangeBb"] == string.Empty || ddlInstrument.SelectedIndex < 0) { ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script type='text/javascript'>alert('please select date');window.location='Ledger.aspx';</script>'"); } else { Session["instrumentName"] = ddlInstrument.SelectedValue; Session["FromoDate"] = DateTime.ParseExact(Request.Form["rangeBa"], "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); Session["ToDate"] = DateTime.ParseExact(Request.Form["rangeBb"], "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); string fromDate = DateTime.ParseExact(Request.Form["rangeBa"], "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); string toDate = DateTime.ParseExact(Request.Form["rangeBb"], "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); ReportDocument oInvestorProtfilioStatement = new ReportDocument(); //CrystalReportDataSet ds = new CrystalReportDataSet(); oInvestorProtfilioStatement.Load(Server.MapPath(@"..\..\DSEInstrumentLedger.rpt")); Session["ReportName"] = "InstrumentWiseLedger"; LedgerLoader oLoder = new LedgerLoader(session.AccountNumber, fromDate, toDate, ddlInstrument.SelectedItem.Text, oInvestorProtfilioStatement); ReportDocument rd = (ReportDocument)oLoder.GetReportSource(); Session["ReportDocumentObj"] = rd; ResponseHelper.Redirect(Response, "ReportViwer.aspx", "_blank", "menubar=0,width=800,height=600"); } } catch (Exception ex) { Response.Redirect("../../LoginErrorPage.aspx?ex=" + Server.UrlEncode(ex.Message) + "&st=" + Server.UrlEncode(ex.StackTrace)); } }
protected void Print_Click(Object sender, CommandEventArgs e) { string reportName = e.CommandArgument.ToString(); string rangeA = Request.Form["rangeBa"]; string rangeB = Request.Form["rangeBb"]; if (reportName == "Portfolio Statement") { try { GetSession session = new GetSession(); string Investor = session.AccountNumber; DateTime fromDate = DateTime.Today; DateTime dateFrom = DateTime.Today; Session["ReportName"] = "InvestorPortfolioStatementWeb"; ReportDocument oInvestorProtfilioStatement = new ReportDocument(); //JScript.Alert(Server.MapPath(@"Reports\InvestorPortfolioStatement.rpt"), Page); oInvestorProtfilioStatement.Load(Server.MapPath(@"..\..\InvestorPortfolioStatement.rpt")); //JScript.Alert("Load Report pass", Page); InvestorPortfolioStatementLoader oLoder = new InvestorPortfolioStatementLoader(Investor, dateFrom, oInvestorProtfilioStatement); //JScript.Alert("after Report pass", Page); ReportDocument rd = (ReportDocument)oLoder.GetReportSource(); Session["ReportDocumentObj"] = rd; // const string url = ""; ResponseHelper.Redirect(Response, "ReportViwer.aspx", "_blank", "menubar=0,width=800,height=600"); //MemoryStream oStream; //oStream = (MemoryStream)rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); //Response.Clear(); //Response.Buffer = true; //Response.ContentType = "application/pdf"; //Response.BinaryWrite(oStream.ToArray()); //Response.Flush(); //Response.End(); //Response.Redirect(Global.BaseUrl + "ReportViewer.aspx"); // Response.Redirect("../../ReportViewer.aspx"); } catch (Exception ex) { //JScript.Alert(ex.Message, Page); throw ex; } } else if (reportName == "Client Ledger Statement") { GetSession session = new GetSession(); string databaseDateFormat = "yyyy/MM/dd"; if (Request.Form["rangeBa"] == string.Empty || Request.Form["rangeBb"] == string.Empty) { ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script type='text/javascript'>alert('please select date');window.location='Reports.aspx';</script>'"); } else { string dateFrom = DateTime.ParseExact(rangeA, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); string date = DateTime.Parse(dateFrom).AddDays(-1).ToString("yyyy/MM/dd"); Session["date"] = date; Session["FromoDate"] = DateTime.ParseExact(rangeA, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); Session["ToDate"] = DateTime.ParseExact(rangeB, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); string fromDate = DateTime.ParseExact(rangeA, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); string toDate = DateTime.ParseExact(rangeB, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); ReportDocument oInvestorProtfilioStatement = new ReportDocument(); //CrystalReportDataSet ds = new CrystalReportDataSet(); oInvestorProtfilioStatement.Load(Server.MapPath(@"..\..\InvestorLedgerStatement.rpt")); Session["ReportName"] = "InvestorLedgerStatement"; InvestorLedgerStatementLoader oLoder = new InvestorLedgerStatementLoader(session.AccountNumber, fromDate, toDate, oInvestorProtfilioStatement); ReportDocument rd = (ReportDocument)oLoder.GetReportSource(); Session["ReportDocumentObj"] = rd; ResponseHelper.Redirect(Response, "ReportViwer.aspx", "_blank", "menubar=0,width=800,height=600"); //MemoryStream oStream; //oStream = (MemoryStream)rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); //Response.Clear(); //Response.Buffer = true; //Response.ContentType = "application/pdf"; //Response.BinaryWrite(oStream.ToArray()); //Response.Flush(); //Response.End(); } } else if (reportName == "Instrument Ledger") { try { GetSession session = new GetSession(); string databaseDateFormat = "yyyy/MM/dd"; if (Request.Form["rangeBa"] == string.Empty || Request.Form["rangeBb"] == string.Empty || ddlInstrument.SelectedIndex < 0) { ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script type='text/javascript'>alert('please select date');window.location='Ledger.aspx';</script>'"); } else { Session["instrumentName"] = ddlInstrument.SelectedValue; Session["FromoDate"] = DateTime.ParseExact(Request.Form["rangeBa"], "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); Session["ToDate"] = DateTime.ParseExact(Request.Form["rangeBb"], "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); string fromDate = DateTime.ParseExact(Request.Form["rangeBa"], "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); string toDate = DateTime.ParseExact(Request.Form["rangeBb"], "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); ReportDocument oInvestorProtfilioStatement = new ReportDocument(); //CrystalReportDataSet ds = new CrystalReportDataSet(); oInvestorProtfilioStatement.Load(Server.MapPath(@"..\..\DSEInstrumentLedger.rpt")); Session["ReportName"] = "InstrumentWiseLedger"; LedgerLoader oLoder = new LedgerLoader(session.AccountNumber, fromDate, toDate, ddlInstrument.SelectedItem.Text, oInvestorProtfilioStatement); ReportDocument rd = (ReportDocument)oLoder.GetReportSource(); Session["ReportDocumentObj"] = rd; ResponseHelper.Redirect(Response, "ReportViwer.aspx", "_blank", "menubar=0,width=800,height=600"); } } catch (Exception ex) { Response.Redirect("../../LoginErrorPage.aspx?ex=" + Server.UrlEncode(ex.Message) + "&st=" + Server.UrlEncode(ex.StackTrace)); } } else if (reportName == "Tax Certificate") { GetSession session = new GetSession(); string databaseDateFormat = "yyyy/MM/dd"; if (Request.Form["rangeBa"] == string.Empty || Request.Form["rangeBb"] == string.Empty) { ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script type='text/javascript'>alert('please select date');window.location='Reports.aspx';</script>'"); } else { Session["FromoDate"] = DateTime.ParseExact(Request.Form["rangeBa"], "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); Session["ToDate"] = DateTime.ParseExact(Request.Form["rangeBb"], "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); string fromDate = DateTime.ParseExact(Request.Form["rangeBa"], "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); string toDate = DateTime.ParseExact(Request.Form["rangeBb"], "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); ReportDocument oTaxReport = new ReportDocument(); //CrystalReportDataSet ds = new CrystalReportDataSet(); oTaxReport.Load(Server.MapPath(@"..\..\InvestorTaxCertificate.rpt")); Session["ReportName"] = "Tax Report"; TaxReportLoader oLoder = new TaxReportLoader(session.AccountNumber, fromDate, toDate, oTaxReport); ReportDocument rd = (ReportDocument)oLoder.GetReportSource(); Session["ReportDocumentObj"] = rd; ResponseHelper.Redirect(Response, "ReportViwer.aspx", "_blank", "menubar=0,width=800,height=600"); } } else if (reportName == "Trade Confirmation") { GetSession session = new GetSession(); string databaseDateFormat = "yyyy/MM/dd"; if (Request.Form["rangeBa"] == string.Empty || Request.Form["rangeBb"] == string.Empty) { ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script type='text/javascript'>alert('please select date');window.location='Reports.aspx';</script>'"); } else { string dateFrom = DateTime.ParseExact(rangeA, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); string date = DateTime.Parse(dateFrom).AddDays(-1).ToString("yyyy/MM/dd"); Session["date"] = date; Session["FromoDate"] = DateTime.ParseExact(rangeA, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); Session["ToDate"] = DateTime.ParseExact(rangeB, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); string fromDate = DateTime.ParseExact(rangeA, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); string toDate = DateTime.ParseExact(rangeB, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); ReportDocument oReportDoc = new ReportDocument(); //CrystalReportDataSet ds = new CrystalReportDataSet(); oReportDoc.Load(Server.MapPath(@"..\..\TradeConfirmationSummaryNew.rpt")); Session["ReportName"] = "TradeConfirmationSummaryNew"; TradeConfirmationLoader oLoder = new TradeConfirmationLoader(session.AccountNumber, fromDate, toDate, oReportDoc); ReportDocument rd = (ReportDocument)oLoder.GetReportSource(); Session["ReportDocumentObj"] = rd; ResponseHelper.Redirect(Response, "ReportViwer.aspx", "_blank", "menubar=0,width=800,height=600"); MemoryStream oStream; oStream = (MemoryStream)rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); Response.Clear(); Response.Buffer = true; Response.ContentType = "application/pdf"; Response.BinaryWrite(oStream.ToArray()); Response.Flush(); Response.End(); } } else if (reportName == "BO Acknowledgement") { GetSession session = new GetSession(); string databaseDateFormat = "yyyy/MM/dd"; if (Request.Form["rangeBa"] == string.Empty || Request.Form["rangeBb"] == string.Empty) { ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script type='text/javascript'>alert('please select date');window.location='Reports.aspx';</script>'"); } else { Session["FromoDate"] = DateTime.ParseExact(Request.Form["rangeBa"], "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); Session["ToDate"] = DateTime.ParseExact(Request.Form["rangeBb"], "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); string fromDate = DateTime.ParseExact(Request.Form["rangeBa"], "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); string toDate = DateTime.ParseExact(Request.Form["rangeBb"], "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None).ToString(databaseDateFormat); ReportDocument oBOAcknowledgement = new ReportDocument(); //CrystalReportDataSet ds = new CrystalReportDataSet(); oBOAcknowledgement.Load(Server.MapPath(@"..\..\BOOpened.rpt")); Session["ReportName"] = "Tax Report"; BOOpenLoader oLoder = new BOOpenLoader(session.AccountNumber, fromDate, toDate, oBOAcknowledgement); ReportDocument rd = (ReportDocument)oLoder.GetReportSource(); Session["ReportDocumentObj"] = rd; ResponseHelper.Redirect(Response, "ReportViwer.aspx", "_blank", "menubar=0,width=800,height=600"); } } }