温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:明日企业下载管理系统源码
当前文件:
MingriEnterprise/BackAdmin/Often/OftenSoft.aspx.cs,打开代码结构图
MingriEnterprise/BackAdmin/Often/OftenSoft.aspx.cs,打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
using System.Data.SqlClient; 12
using System.IO; 13
14
public partial class BackAdmin_Often_OftenSoft : System.Web.UI.Page 15
{ 16
CAN can = new CAN(); 17
protected void Page_Load(object sender, EventArgs e) 18
{ 19
can.ExecAdapterBindInfoString(GridView1, "select * from tb_smallsoft ORDER BY ID DESC", "id"); 20
//string ConStr = "server=(local);user id=sa;PWD=sa;DataBase=db_ComPany"; 21
//SqlConnection myconnection = new SqlConnection(ConStr); 22
//string SqlStr = "select * from tb_smallsoft ORDER BY ID DESC"; 23
//SqlDataAdapter myadapter = new SqlDataAdapter(SqlStr, myconnection); 24
//myconnection.Open(); 25
//DataSet myset = new DataSet(); 26
//myadapter.Fill(myset); 27
//GridView1.DataSource = myset; 28
//GridView1.DataKeyNames = new string[] { "id" }; 29
//GridView1.DataBind(); 30
//myconnection.Close(); 31
} 32
protected void LinkButton1_Click(object sender, EventArgs e) 33
{ 34
Page.Response.Redirect("UpOftenSoft.aspx"); 35
} 36
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) 37
{ 38
GridView1.PageIndex = e.NewPageIndex; 39
GridView1.DataBind(); 40
} 41
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) 42
{ 43
SqlConnection con = new SqlConnection("server=(local);user id=sa;PWD=sa;DataBase=db_ComPany"); 44
con.Open(); 45
SqlDataAdapter ada = new SqlDataAdapter("select * from tb_smallsoft where ID='" + this.GridView1.DataKeys[e.RowIndex].Value.ToString() + "'", con); 46
DataSet ds = new DataSet(); 47
ada.Fill(ds, "tb_smallsoft"); 48
//con.Close(); 49
DataRow[] row = ds.Tables[0].Select(); 50
foreach (DataRow rs in row) //将检索到的数据逐一,循环添加到Listbox1中 51
{ 52
if (rs["DownLoad"].ToString() != "") 53
{ 54
FileInfo file = new FileInfo(Server.MapPath("../../" + rs["DownLoad"].ToString())); 55
file.Delete(); 56
} 57
} 58
59
60
////清除相片文件(服务器) 61
//DataSet ds = bc.GetDataSet("select * from [file] where fileID='" + this.GridView1.DataKeys[e.RowIndex].Value.ToString() + "'", "file"); 62
//DataRow[] row = ds.Tables[0].Select(); 63
//foreach (DataRow rs in row) //将检索到的数据逐一,循环添加到Listbox1中 64
//{ 65
// FileInfo file = new FileInfo(Server.MapPath(rs["DownLoad"].ToString())); 66
// file.Delete(); 67
//} 68
//清除数据 69
SqlConnection myconnection = new SqlConnection("server=(local);user id=sa;PWD=sa;DataBase=db_ComPany"); 70
myconnection.Open(); 71
string SqlStr = "delete from tb_smallsoft where id='" + GridView1.DataKeys[e.RowIndex].Value + "'"; 72
SqlCommand mycommand = new SqlCommand(SqlStr, myconnection); 73
mycommand.ExecuteNonQuery(); 74
SqlDataAdapter myadapter = new SqlDataAdapter("select * from tb_smallsoft order by id desc", myconnection); 75
DataSet myset = new DataSet(); 76
myadapter.Fill(myset); 77
GridView1.DataSource = myset; 78
GridView1.DataBind(); 79
myconnection.Close(); 80
} 81
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 82
{ 83
if (e.Row.RowType == DataControlRowType.DataRow) 84
{ 85
((LinkButton)(e.Row.Cells[2].Controls[0])).Attributes.Add("onclick", "return confirm('确定删除吗?')"); 86
e.Row.Cells[0].Text = new CAN().SubStr(e.Row.Cells[0].Text.ToString(), 5); 87
} 88
} 89
} 90




CAN can 

}