温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:库存管理系统V1.0源码
当前文件:
StoreManage/AddCangku.aspx.cs,打开代码结构图
StoreManage/AddCangku.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 AddCangku : System.Web.UI.Page 15
{ 16
protected void Page_Load(object sender, EventArgs e) 17
{ 18
19
} 20
protected void Button1_Click(object sender, EventArgs e) 21
{ 22
if (kong()) 23
{ 24
//定义变量 25
string aa, bb, cc; 26
aa = this.TextBox1.Text; 27
bb = this.TextBox2.Text; 28
cc = this.TextBox5.Text; 29
SqlConnection scon = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]); 30
scon.Open(); 31
SqlCommand scmd = new SqlCommand("insert into cangku(Name,ckbm,beizhu) values ('" + aa + "','" + bb + "','" + cc + "')", scon); 32
scmd.ExecuteNonQuery(); 33
scmd.Dispose(); 34
scon.Close(); 35
Response.Write("<script language='javascript'>alert('添加成功!');</script>"); 36
Server.Transfer("manageCangku.aspx"); 37
} 38
} 39
private bool kong() 40
{ 41
if (this.TextBox1.Text == "") 42
{ 43
Response.Write("<script language='javascript'>alert('仓库名称不能为空!');</script>"); 44
return false; 45
} 46
else 47
{ 48
if (this.TextBox2.Text == "") 49
{ 50
Response.Write("<script language='javascript'>alert('仓库编码不能为空!');</script>"); 51
return false; 52
} 53
else 54
{ 55
return true; 56
} 57
} 58
} 59
protected void Button2_Click(object sender, EventArgs e) 60
{ 61
Server.Transfer("manageCangku.aspx"); 62
} 63
} 64





}
}