protected void btnGenerateReport_click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["EMSConnectionString"].ConnectionString); if (con.State == ConnectionState.Closed) { con.Open(); } SqlDataAdapter adp = new SqlDataAdapter("select * from tbChallan", con); try { DataSet ds = new DataSet(); adp.Fill(ds); ExportData.Export o = new ExportData.Export("Web"); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count <= 0) { ds.Tables[0].Rows.Add(ds.Tables[0].NewRow()); } o.ExportDetails(ds.Tables[0], ExportData.Export.ExportFormat.Excel, "Quarter report.xls"); } } finally { adp.Dispose(); con.Close(); } }
protected void btnGenerateReport_click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["EMSConnectionString"].ConnectionString); if (con.State == ConnectionState.Closed) { con.Open(); } SqlDataAdapter adp = new SqlDataAdapter("select ROW_NUMBER() OVER(ORDER BY DateOfVacation DESC) AS [Sr no], quarternumber as [Quarter number],CONVERT(VARCHAR(10), DateOfVacation, 103) as [Date Of Vacation] from tblquarters where isnull(status,0) = 0 and isnull(Category,0)=" + drpQuarterCat.SelectedValue + " order by DateOfVacation DESC ", con); try { DataSet ds = new DataSet(); adp.Fill(ds); ExportData.Export o = new ExportData.Export("Web"); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count <= 0) { ds.Tables[0].Rows.Add(ds.Tables[0].NewRow()); } o.ExportDetails(ds.Tables[0], ExportData.Export.ExportFormat.Excel, "Vacant Quarter report.xls"); } } finally { adp.Dispose(); con.Close(); } }
protected void btnGenerateReport_click(object sender, EventArgs e) { DateTime startdate, enddate; DateTime.TryParse(txtstartdate.Text, out startdate); DateTime.TryParse(txtenddate.Text, out enddate); SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["EMSConnectionString"].ConnectionString); if (con.State == ConnectionState.Closed) { con.Open(); } string query = @" select Q.quarternumber,u.fullname as [Name of allotte],fee,actualfee,balance from tbQuarterLicenceFee ql inner join tblquarters q on q.id=ql.quarterid inner join dbo.tblUsers u on ql.aan=u.aan inner join dbo.tblOffices o on o.id=u.baseofficeid where q.category= " + drpQuarterCat.SelectedValue + "and o.id = " + drpOffice.SelectedValue + " and ql.month > convert(datetime,'" + startdate.ToShortDateString() + "',103) and ql.month < convert(datetime,'" + enddate.ToShortDateString() + "',103)"; SqlDataAdapter adp = new SqlDataAdapter(query, con); try { DataSet ds = new DataSet(); adp.Fill(ds); ExportData.Export o = new ExportData.Export("Web"); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count <= 0) { ds.Tables[0].Rows.Add(ds.Tables[0].NewRow()); } o.ExportDetails(ds.Tables[0], ExportData.Export.ExportFormat.Excel, "Licence fee report.xls"); } } finally { adp.Dispose(); con.Close(); } }
protected void btnGenerateReport_click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["EMSConnectionString"].ConnectionString); if (con.State == ConnectionState.Closed) { con.Open(); } string query = @"select ROW_NUMBER() OVER(ORDER BY a.DateOfRetensionUpto DESC) AS [Sr no], a.quarternumber,u.fullname as [Name of allotte],d.name as Designation,o.name as office,CONVERT(VARCHAR(10), a.DateOfRetensionUpto, 103) as [Date Of RetensionUpto] from dbo.tblAllottee a inner join tblquarters q on q.quarternumber=a.quarternumber inner join dbo.tblUsers u on a.aan=u.aan inner join dbo.tblOffices o on o.id=u.baseofficeid inner join dbo.tblDesignations d on u.designation=d.id where a.status=4 and q.category=" + drpQuarterCat.SelectedValue + " and o.id=" + drpOffice.SelectedValue + " ORDER BY a.DateOfRetensionUpto DESC"; SqlDataAdapter adp = new SqlDataAdapter(query, con); try { DataSet ds = new DataSet(); adp.Fill(ds); ExportData.Export o = new ExportData.Export("Web"); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count <= 0) { ds.Tables[0].Rows.Add(ds.Tables[0].NewRow()); } o.ExportDetails(ds.Tables[0], ExportData.Export.ExportFormat.Excel, "Retension Quarter report.xls"); } } finally { adp.Dispose(); con.Close(); } }