温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:库存管理系统V1.0源码
当前文件:
StoreManage/managechuku.aspx.cs,打开代码结构图
StoreManage/managechuku.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
//该源码下载自www.51aspx.com(51aspx.com) 13
14
public partial class managechuku : System.Web.UI.Page 15
{ 16
protected void Page_Load(object sender, EventArgs e) 17
{ 18
if (!IsPostBack) 19
{ 20
gridviewBind(); 21
} 22
} 23
//gridview绑定 24
private void gridviewBind() 25
{ 26
string str = "select rukuID,rukuDate,rukuBianma,huoName,shuliang,jinjia,zhonge,ghdw,jingbanren,huokuan from chuku order by rukuID desc"; 27
SqlConnection scon = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]); 28
scon.Open(); 29
SqlDataAdapter dbAdapter = new SqlDataAdapter(str, scon); 30
DataSet ds = new DataSet(); 31
dbAdapter.Fill(ds); 32
scon.Close(); 33
GridView1.DataSource = ds.Tables[0].DefaultView; 34
GridView1.DataKeyNames = new string[] { "rukuID" }; 35
GridView1.DataBind(); 36
} 37
////f分页 38
protected void GridView1_PageIndexChanging1(object sender, GridViewPageEventArgs e) 39
{ 40
GridView1.PageIndex = e.NewPageIndex; 41
GridView1.DataBind(); 42
gridviewBind(); 43
} 44
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) 45
{ 46
string ss = "delete from chuku where rukuID='" + this.GridView1.DataKeys[e.RowIndex].Value.ToString() + "'"; 47
SqlConnection scon = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]); 48
scon.Open(); 49
SqlCommand scmd = new SqlCommand(ss, scon); 50
scmd.ExecuteNonQuery(); 51
scon.Close(); 52
GridView1.DataBind(); 53
gridviewBind(); 54
} 55
}





}
}