温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:网博直销系统软件源码
当前文件:
WangBoDirect/admin/hy_ok.aspx.cs,打开代码结构图
WangBoDirect/admin/hy_ok.aspx.cs,打开代码结构图1using System; 2
using System.IO; 3
using System.Data; 4
using System.Configuration; 5
using System.Collections; 6
using System.Web; 7
using System.Web.Security; 8
using System.Web.UI; 9
using System.Web.UI.WebControls; 10
using System.Web.UI.WebControls.WebParts; 11
using System.Web.UI.HtmlControls; 12
13
public partial class admin_hy_ok : System.Web.UI.Page 14
{ 15
protected void Page_Load(object sender, EventArgs e) 16
{ 17
if (Session["aid"] == null) 18
{ Response.Write("<script language=javascript>top.location.href='login.aspx';alert('您未登录!');</script>"); } 19
else { 20
bind(); 21
if (Request.QueryString["sid"] != null) 22
{ 23
sdate(); 24
} 25
} 26
} 27
void sdate() 28
{ 29
access.DoSql("delete * from webhww_hy where id=" + Request.QueryString["sid"] + ""); 30
bind(); 31
} 32
void bind() 33
{ 34
string sql = "select * from webhww_hy where webhww_sh=" + true + " and webhww_sort=0 order by id desc"; 35
if (access.GreatDs(sql).Tables[0].Rows.Count > 0) 36
{ 37
GridView1.DataSource = access.GreatDs(sql); 38
GridView1.DataBind(); 39
} 40
else 41
{ 42
Response.Write("无审核会员"); 43
} 44
} 45
protected void Button1_Click(object sender, EventArgs e) 46
{ 47
48
string sql = "select * from webhww_hy where webhww_sh=" + true + " and webhww_sort=0 order by id desc"; 49
DataTable dt = access.GreatDs(sql).Tables[0]; 50
string s = ""; 51
for (int i = 0; i < dt.Rows.Count; i++) 52
{ 53
54
for (int j = 0; j < dt.Columns.Count; j++) 55
{ 56
s += dt.Rows[i][j].ToString(); 57
if (j != dt.Columns.Count - 1) 58
{ 59
s += ","; 60
} 61
} 62
s += "\r\n"; 63
} 64
ScreenHtml(s); 65
//Response.Write(s); 66
//Response.End(); 67
} 68
/// <summary> 69
/// 写入流文件 70
/// </summary> 71
void ScreenHtml(string s) 72
{ 73
74
//byte[] myDataBuffer = byte.Parse(s); 75
76
// Display the downloaded data. 77
string download = s;//Encoding.Default.GetString(myDataBuffer);//Encoding.ASCII.GetString 78
79
string path = System.Web.HttpContext.Current.Server.MapPath("../") + "out.csv"; 80
81
// Delete the file if it exists. 82
if (File.Exists(path)) 83
{ 84
File.Delete(path); 85
} 86
87
StreamWriter sw = new StreamWriter(path, true, System.Text.Encoding.GetEncoding("GB2312")); 88
//sw=File.CreateText(pathto); 89
sw.Write(download, System.Text.Encoding.GetEncoding("GB2312")); 90
sw.Flush(); 91
sw.Close(); 92
Response.Write("更新成功!"); 93
//Response.Write(Request.Url.ToString().Replace("admin/ka_add.aspx", "") + "out.csv"); 94
//Response.End(); 95
Response.Redirect(Request.Url.ToString().Replace("admin/hy_ok.aspx", "") + "out.csv"); 96
} 97
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) 98
{ 99
GridView1.PageIndex = e.NewPageIndex; 100
bind(); 101
} 102
103
} 104





}
}