温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:库存管理系统V1.0源码
当前文件:
StoreManage/Editshdw.aspx.cs,打开代码结构图
StoreManage/Editshdw.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 Editshdw : 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 shdw where shouhuoID='" + 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["Bianma"].ToString(); 48
this.TextBox2.Text = dr["Name"].ToString(); 49
this.TextBox3.Text = dr["Address"].ToString(); 50
this.TextBox4.Text = dr["tel"].ToString(); 51
this.TextBox5.Text = dr["person"].ToString(); 52
} 53
//关闭数据库的连接 54
dr.Close(); 55
scon.Close(); 56
} 57
protected void Button1_Click(object sender, EventArgs e) 58
{ 59
if (kong()) 60
{ 61
//定义变量 62
string bbb = Request.QueryString["BID"]; 63
string aa, bb, cc, dd, ee; 64
aa = this.TextBox1.Text; 65
bb = this.TextBox2.Text; 66
cc = this.TextBox3.Text; 67
dd = this.TextBox4.Text; 68
ee = this.TextBox5.Text; 69
SqlConnection scon = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]); 70
scon.Open(); 71
SqlCommand scmd = new SqlCommand("update shdw set Bianma='" + aa + "',Address='" + cc + "',Name='" + bb + "',person='" + ee + "',tel='" + dd + "' where shouhuoID='" + bbb + "'", scon); 72
scmd.ExecuteNonQuery(); 73
scmd.Dispose(); 74
scon.Close(); 75
Response.Write("<script language='javascript'>alert('修改成功!');</script>"); 76
Server.Transfer("manageshdw.aspx"); 77
} 78
} 79
private bool kong() 80
{ 81
if (this.TextBox1.Text == "") 82
{ 83
Response.Write("<script language='javascript'>alert('单位编码不能为空!');</script>"); 84
return false; 85
} 86
else 87
{ 88
if (this.TextBox2.Text == "") 89
{ 90
Response.Write("<script language='javascript'>alert('单位名称不能为空!');</script>"); 91
return false; 92
} 93
else 94
{ 95
return true; 96
} 97
} 98
} 99
protected void Button2_Click(object sender, EventArgs e) 100
{ 101
Server.Transfer("manageshdw.aspx"); 102
} 103
} 104
105





}
}