using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using CrystalDecisions.CrystalReports; using CrystalDecisions.Shared; using CrystalDecisions.Web; namespace WebApplication1.Reports { public partial class rptLoanApp : System.Web.UI.Page { SqlConnection con = new SqlConnection(@"Data Source=BISTASOLU\BISTASOL;MultipleActiveResultSets = true;Initial Catalog=HeartLand;Integrated Security=True"); DataSet dst = new DataSet(); SqlDataAdapter dat = null; SqlCommand comm = new SqlCommand(); protected void Page_Load(object sender, EventArgs e) { comm.CommandText = "SELECT * FROM vwLoanApp"; comm.CommandType = CommandType.Text; comm.Connection = con; comm.Connection.Open(); dat = new SqlDataAdapter(); dat.SelectCommand = comm; dat.Fill(dst, "vwLoanApp"); crptAppLoans app = new crptAppLoans(); app.Load(Server.MapPath("~/Reports/crptAppLoans.rpt")); app.SetDataSource(dst); CrystalReportViewer1.ReportSource = app; CrystalReportViewer1.DataBind(); comm.Connection.Close(); } protected void btnSearch_Click(object sender, EventArgs e) { if (CheckBox1.Checked == true) { DateTime Datefrom = Convert.ToDateTime(txtDateFrm.Text); DateTime Dateto = Convert.ToDateTime(txtDateTo.Text); comm.CommandText = "SELECT * FROM vwLoanApp WHERE APP_DATE > '"+ Datefrom +"'AND APP_DATE < '"+ Dateto +"' "; comm.CommandType = CommandType.Text; comm.Connection = con; comm.Connection.Open(); dat = new SqlDataAdapter(); dat.SelectCommand = comm; dat.Fill(dst, "vwLoanApp"); crptAppLoans app = new crptAppLoans(); app.Load(Server.MapPath("~/Reports/crptAppLoans.rpt")); app.SetDataSource(dst); CrystalReportViewer1.ReportSource = app; CrystalReportViewer1.DataBind(); comm.Connection.Close(); } else { if (txtReq.Text != "" && txtCustID.Text == "") { string reqID = txtReq.Text; comm.CommandText = "SELECT * FROM vwLoanApp WHERE REQUEST_ID = '" + reqID + "'"; comm.CommandType = CommandType.Text; comm.Connection = con; comm.Connection.Open(); dat = new SqlDataAdapter(); dat.SelectCommand = comm; dat.Fill(dst, "vwLoanApp"); crptAppLoans app = new crptAppLoans(); app.Load(Server.MapPath("~/Reports/crptAppLoans.rpt")); app.SetDataSource(dst); CrystalReportViewer1.ReportSource = app; CrystalReportViewer1.DataBind(); } else if (txtReq.Text != "" && txtCustID.Text != "") { string reqID = txtReq.Text; int custID = Convert.ToInt32(txtCustID.Text); comm.CommandText = "SELECT * FROM vwLoanApp WHERE REQUEST_ID = '" + reqID + "' AND CUST_ID = '"+ custID +"'"; comm.CommandType = CommandType.Text; comm.Connection = con; comm.Connection.Open(); dat = new SqlDataAdapter(); dat.SelectCommand = comm; dat.Fill(dst, "vwLoanApp"); crptAppLoans app = new crptAppLoans(); app.Load(Server.MapPath("~/Reports/crptAppLoans.rpt")); app.SetDataSource(dst); CrystalReportViewer1.ReportSource = app; CrystalReportViewer1.DataBind(); comm.Connection.Close(); } else { Label1.Text = "PLEASE PROVIDE SEARCH PARAMETER"; } } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)