-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDetailed_Closed_Report.aspx.cs
102 lines (93 loc) · 3.14 KB
/
Detailed_Closed_Report.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Security.Cryptography;
using System.IO;
using System.Text;
using System.Net.Mail;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.UrlReferrer == null)
{
Response.Redirect("LoginCheck.aspx");
}
else
{
if (!IsPostBack)
{
if (Session.Count == 0)
{
Response.Redirect("LoginCheck.aspx");
}
else
{
((Label)Master.FindControl("lblName")).Text = Session["Name"].ToString();
btnExporttoExcel.Visible = false;
mtdComplaintsReportGrid_OpenComplaints();
}
}
}
}
#region Updateing Grid with Open Complainst Detail Till date
public void mtdComplaintsReportGrid_OpenComplaints()
{
SqlConnection Conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnString2DB"].ConnectionString);
Conn.Open();
SqlCommand Cmd = new SqlCommand("sp_Get_Complaints_closed_status", Conn);
Cmd.CommandType = CommandType.StoredProcedure;
Cmd.ExecuteNonQuery();
DataTable dtLogin = new DataTable();
SqlDataAdapter daLogin = new SqlDataAdapter(Cmd);
daLogin.Fill(dtLogin);
if (dtLogin.Rows.Count == 0)
{
lblMsg.Text = "No data found";
btnExporttoExcel.Visible = false;
}
else
{
btnExporttoExcel.Visible = true;
grdComplaintsReport.DataSource = dtLogin;
grdComplaintsReport.DataBind();
// grdComplaintsReport.Columns[14].Visible = false;
// grdComplaintsReport.Columns[15].Visible = false;
// grdComplaintsReport.Columns[16].Visible = false;
btnExporttoExcel.Visible = true;
}
Conn.Close();
Conn.Dispose();
}
#endregion
#region Export to excel method
public void Exporttoexcel()
{
//grdComplaintsReport.Columns[14].Visible = true;
//grdComplaintsReport.Columns[15].Visible = true;
//grdComplaintsReport.Columns[16].Visible = true;
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=Closed_Complaints_Report.xls");
Response.ContentType = "application/vnd.xlsx";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
grdComplaintsReport.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
}
protected void btnExporttoExcel_Click(object sender, EventArgs e)
{
Exporttoexcel();
}
#endregion
}