您目前尚未登陆,请选择【登陆】或【注册
首页->上传下载->明日企业下载管理系统源码>>BackAdmin/SettleProject/SettleProject.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:明日企业下载管理系统源码
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11using System.Data.SqlClient; 12using System.IO; 13 14public partial class BackAdmin_SettleProject : System.Web.UI.Page 15{ 16 protected void Page_Load(object sender, EventArgs e) 17 { 18 string ConStr = "server=(local);user id=sa;PWD=sa;DataBase=db_ComPany"; 19 SqlConnection myconnection = new SqlConnection(ConStr); 20 string SqlStr = "select * from SettView ORDER BY ID DESC"; 21 SqlDataAdapter myadapter = new SqlDataAdapter(SqlStr, myconnection); 22 myconnection.Open(); 23 DataSet myset = new DataSet(); 24 myadapter.Fill(myset); 25 GridView1.DataSource = myset; 26 GridView1.DataKeyNames = new string[] { "id" }; 27 GridView1.DataBind(); 28 myconnection.Close(); 29 30 } 31 protected void LinkButton1_Click(object sender, EventArgs e) 32 { 33 Page.Response.Redirect("InsertSettleProject.aspx"); 34 } 35 protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) 36 { 37 GridView1.PageIndex = e.NewPageIndex; 38 GridView1.DataBind(); 39 } 40 protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) 41 { 42 43 44 SqlConnection con = new SqlConnection("server=(local);user id=sa;PWD=sa;DataBase=db_ComPany"); 45 con.Open(); 46 SqlDataAdapter ada = new SqlDataAdapter("select * from tb_SettleProject where ID='" + this.GridView1.DataKeys[e.RowIndex].Value.ToString() + "'", con); 47 DataSet ds = new DataSet(); 48 ada.Fill(ds, "tb_SettleProject"); 49 DataRow[] row = ds.Tables[0].Select(); 50 foreach (DataRow rs in row) //将检索到的数据逐一,循环添加到Listbox1中 51 { 52 if (rs["img"].ToString() != "") 53 { 54 FileInfo file = new FileInfo(Server.MapPath("../../" + rs["img"].ToString())); 55 file.Delete(); 56 } 57 } 58 59 60 SqlConnection myconnection = new SqlConnection("server=(local);user id=sa;PWD=sa;DataBase=db_ComPany"); 61 myconnection.Open(); 62 string SqlStr = "delete from tb_SettleProject where id='" + GridView1.DataKeys[e.RowIndex].Value + "'"; 63 SqlCommand mycommand = new SqlCommand(SqlStr, myconnection); 64 mycommand.ExecuteNonQuery(); 65 SqlDataAdapter myadapter = new SqlDataAdapter("select * from SettView ORDER BY ID DESC", myconnection); 66 DataSet myset = new DataSet(); 67 myadapter.Fill(myset); 68 GridView1.DataSource = myset; 69 GridView1.DataBind(); 70 myconnection.Close(); 71 72 } 73 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 74 { 75 if (e.Row.RowType == DataControlRowType.DataRow) 76 { 77 e.Row.Cells[3].Text = Convert.ToString(Convert.ToDateTime(e.Row.Cells[3].Text).ToShortDateString()); 78 ((LinkButton)(e.Row.Cells[7].Controls[0])).Attributes.Add("onclick", "return confirm('确定删除吗?')"); 79 e.Row.Cells[4].Text = new CAN().SubStr(e.Row.Cells[4].Text.ToString(), 6); 80 e.Row.Cells[0].Text = new CAN().SubStr(e.Row.Cells[0].Text.ToString(), 4); 81 } 82 } 83} 84
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:明日企业下载管理系统源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号