温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:库存管理系统V1.0源码
当前文件:
StoreManage/EditPeople.aspx.cs,打开代码结构图
StoreManage/EditPeople.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 EditPeople : System.Web.UI.Page 14
{ 15
private readonly string SqlConnectionString = ConfigurationManager.AppSettings["ConnectionString"].ToString(); 16
private string BID; 17
private int strID 18
{ 19
get 20
{ 21
return Convert.ToInt32(ViewState["_BID"]); 22
} 23
set 24
{ 25
ViewState["_BID"] = Request.QueryString["BID"]; 26
} 27
} 28
protected void Page_Load(object sender, EventArgs e) 29
{ 30
if (!IsPostBack) 31
{ 32
BID = Request["BID"].ToString(); 33
BindData(BID); 34
} 35
} 36
private void BindData(string BID) 37
{ 38
string sqlstr; 39
sqlstr = "select * from people where userID='" + BID + "'"; 40
SqlConnection scon = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]); 41
SqlCommand scm = new SqlCommand(sqlstr, scon); 42
//打开数据库并执行查询操作 43
scon.Open(); 44
SqlDataReader dr = scm.ExecuteReader(); 45
if (dr.Read()) 46
{ 47
this.TextBox1.Text = dr["Name"].ToString(); 48
this.TextBox2.Text = dr["bianma"].ToString(); 49
this.TextBox5.Text = dr["tel"].ToString(); 50
} 51
//关闭数据库的连接 52
dr.Close(); 53
scon.Close(); 54
} 55
protected void Button1_Click(object sender, EventArgs e) 56
{ 57
if (kong()) 58
{ 59
//定义变量 60
string bbb = Request.QueryString["BID"]; 61
string aa, bb, cc; 62
aa = this.TextBox1.Text; 63
bb = this.TextBox2.Text; 64
cc = this.TextBox5.Text; 65
SqlConnection scon = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]); 66
scon.Open(); 67
SqlCommand scmd = new SqlCommand("update people set Name='" + aa + "',tel='" + cc + "',bianma='" + bb + "' where userID='" + bbb + "'", scon); 68
scmd.ExecuteNonQuery(); 69
scmd.Dispose(); 70
scon.Close(); 71
Response.Write("<script language='javascript'>alert('修改成功!');</script>"); 72
Server.Transfer("managePeople.aspx"); 73
} 74
} 75
private bool kong() 76
{ 77
if (this.TextBox1.Text == "") 78
{ 79
Response.Write("<script language='javascript'>alert('经办人名称不能为空!');</script>"); 80
return false; 81
} 82
else 83
{ 84
if (this.TextBox2.Text == "") 85
{ 86
Response.Write("<script language='javascript'>alert('编码不能为空!');</script>"); 87
return false; 88
} 89
else 90
{ 91
return true; 92
} 93
} 94
} 95
protected void Button2_Click(object sender, EventArgs e) 96
{ 97
Server.Transfer("managePeople.aspx"); 98
} 99
} 100
101





}
}