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





}
}