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





}
}