-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.aspx.cs
161 lines (132 loc) · 5.33 KB
/
index.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using WebApplication1.DAL;
using WebApplication1.BLL;
using System.IO;
namespace WebApplication1
{
public partial class index : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//DataTable dt_userinfo = BLL.BLL_Index.SelectUserinfo();
//GridView1.DataSource = dt_userinfo;
// tableVar.dbvar = dt_userinfo;
// GridView1.DataBind();
if (!IsPostBack)
{
string data1 = this.d12.Value.Trim();
string data2 = this.d13.Value.Trim();
DaltableVar daldb = new BLL.DaltableVar();
daldb = BLL.BLL_Index.SelectDays(data1, data2);
GridView1.DataSource = daldb.dbvar;
tableVar.dbvar = daldb.dbvar;
tableVar.sfile = daldb.sfile;
tableVar.stitle = daldb.stitle;
GridView1.DataBind();
Label1t1.Text = "kalaok0";
}
}
protected void B_que1_Click(object sender, EventArgs e)
{
string data1 = this.d12.Value.Trim();
string data2 = this.d13.Value.Trim();
Label1t1.Text = "natsuki";
DaltableVar daldb = new BLL.DaltableVar();
daldb = BLL.BLL_Index.SelectDays(data1, data2);
GridView1.DataSource = daldb.dbvar;
tableVar.dbvar = daldb.dbvar;
tableVar.sfile = daldb.sfile;
tableVar.stitle = daldb.stitle;
//DataTable dt_cur = BLL.BLL_Index.SelectCurrentDay();
//GridView1.DataSource = dt_cur;
//tableVar.dbvar = dt_cur;
GridView1.DataBind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataSource = tableVar.dbvar;
GridView1.DataBind();
//InitPage(); //重新绑定GridView数据的函数
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
/*
* http://blog.csdn.net/drr789/article/details/7949018
protected void getRefSet(DataSet ds)
{
lblCurrentIndex.Text = "第 " + (GridView1.PageIndex + 1).ToString() + " 页";
lblPageCount.Text = "共 " + GridView1.PageCount.ToString() + " 页";
lblRecordCount.Text = "总共 " + ds.Tables[0].Rows.Count.ToString() + " 条";
if (ds.Tables[0].Rows.Count == 0)
{
lnkbtnFirst.Visible = false;
lnkbtnPre.Visible = false;
lnkbtnNext.Visible = false;
lnkbtnLast.Visible = false;
lblCurrentIndex.Visible = false;
lblPageCount.Visible = false;
lblRecordCount.Visible = false;
}
else if (GridView1.PageCount == 1)
{
lnkbtnFirst.Visible = false;
lnkbtnPre.Visible = false;
lnkbtnNext.Visible = false;
lnkbtnLast.Visible = false;
}
lnkbtnFirst.CommandArgument = "1";
lnkbtnPre.CommandArgument = (GridView1.PageIndex == 0 ? "1" : GridView1.PageIndex.ToString());
lnkbtnNext.CommandArgument = (GridView1.PageCount == 1 ? GridView1.PageCount.ToString() : (GridView1.PageIndex + 2).ToString());
lnkbtnLast.CommandArgument = GridView1.PageCount.ToString();
}
*
* protected void PagerButtonClick(object sender, EventArgs e)
{
GridView1.PageIndex = Convert.ToInt32(((LinkButton)sender).CommandArgument) - 1;
GridView1.DataSource = tableVar.dbvar;
GridView1.DataBind();
}
protected void lnkbtnJumpPage_Click(object sender, EventArgs e)
{
GridView1.PageIndex = int.Parse(txtJumpPage.Text) - 1;
lblCurrentIndex.Text = "第 " + (GridView1.PageIndex + 1).ToString() + " 页";
GridView1.DataSource = tableVar.dbvar;
GridView1.DataBind();
}
*
*
*/
public class tableVar
{
public static DataTable dbvar;
public static string stitle;
public static string sfile;
}
protected void B_save_Click(object sender, EventArgs e)
{
string filename = tableVar.stitle;
string filepath = tableVar.sfile;
BLL.BLL_Index.DataToCsv(tableVar.dbvar, filepath);
FileInfo infofile = new FileInfo(filepath);
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
Response.AddHeader("Content-Length", infofile.Length.ToString());
Response.AddHeader("Content-Transfer-Encoding", "binary");
Response.ContentType = "application/octet-stream";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
Response.WriteFile(infofile.FullName);
Response.Flush();
Response.End();
}
}
}