01.
public
partial
class
Default2 : System.Web.UI.Page
02.
{
03.
SqlConnection objConn;
04.
Int16 Total2 = 0;
05.
06.
07.
protected
void
Page_Load(
object
sender, EventArgs e)
08.
{
09.
10.
if
(Session[
"User"
]!=
null
)
11.
{
12.
getdata();
13.
14.
}
15.
else
{
16.
Response.Redirect(
"Default3.aspx"
);
17.
}
18.
}
19.
20.
protected
void
myDataGrid_PageIndexChanging(
object
sender, System.Web.UI.WebControls.GridViewPageEventArgs e)
21.
{
22.
myDataGrid.PageIndex = e.NewPageIndex;
23.
getdata();
24.
25.
26.
}
27.
28.
public
void
getdata()
29.
{
30.
String strConnString;
31.
strConnString =
"Server=10.11.1.17;UID=userreport;PASSWORD=gztr1998;database=DW01;Max Pool Size=400;Connect Timeout=600;"
;
32.
33.
objConn =
new
SqlConnection(strConnString);
34.
objConn.Open();
35.
if
(objConn.State == ConnectionState.Open)
36.
{
37.
this
.lblText.Text =
"SQL Server Connected"
;
38.
}
39.
else
40.
{
41.
this
.lblText.Text =
"SQL Server Connect Failed"
;
42.
}
43.
String Sql =
"SELECT [Doc Date], [Package Name], SUM([SMS Code Sent]) AS [SMS Code Sent], SUM([SMS Payment-CS]) AS [Counter Service], SUM([PayDay-1]) AS [1 Day], SUM([PayDay-2]) AS [2 Days], SUM([PayDay-3]) AS [3 Days], SUM([PayDay-4]) AS [4 Days], SUM([PayDay-5]) AS [5 Days], SUM([PayDay-6]) AS [6 Days], SUM([PayDay-7]) AS [7 Days], SUM([PayDay-more7]) AS [more7], SUM([SMS Cancle]) AS [SMS Cancel] FROM CEM_SMSCODE_Summary where [DOC DATE] between '2013-05-21' and '2013-05-22' GROUP BY [Doc Date], [Package Name] ORDER BY [Doc Date], [Package Name]"
;
44.
SqlCommand com =
new
SqlCommand();
45.
com.Connection = objConn;
46.
com.CommandText = Sql;
47.
SqlDataReader dr = com.ExecuteReader();
48.
if
(dr.HasRows)
49.
{
50.
DataTable dt =
new
DataTable();
51.
dt.Load(dr);
52.
myDataGrid.DataSource = dt;
53.
myDataGrid.DataBind();
54.
55.
}
56.
57.
}
58.
protected
void
myDataGrid_RowDataBound(
object
sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
59.
{
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
if
(e.Row.RowType == DataControlRowType.DataRow)
71.
{
72.
Total2 += Convert.ToInt16(DataBinder.Eval(e.Row.DataItem,
"SMS Code Sent"
));
73.
}
74.
else
if
(e.Row.RowType == DataControlRowType.Footer)
75.
{
76.
e.Row.Cells[0].Text =
"Totals : "
;
77.
e.Row.Cells[2].Text = Total2.ToString();
78.
}
79.
}
80.
}