温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:库存管理系统V1.0源码
当前文件:
StoreManage/Addhuo.aspx.cs,打开代码结构图
StoreManage/Addhuo.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 Addhuo : System.Web.UI.Page 14
{ 15
protected void Page_Load(object sender, EventArgs e) 16
{ 17
18
} 19
protected void Button1_Click(object sender, EventArgs e) 20
{ 21
if (kong()) 22
{ 23
//定义变量 24
string aa, bb, cc, dd,ee,ff,gg,hh,ii; 25
aa = this.TextBox1.Text; 26
bb = this.TextBox2.Text; 27
cc = this.TextBox3.Text; 28
dd = this.DropDownList1.Text; 29
ee = this.TextBox5.Text; 30
ff = this.TextBox6.Text; 31
gg = this.TextBox7.Text; 32
hh = this.TextBox8.Text; 33
ii = this.TextBox9.Text; 34
35
SqlConnection scon = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]); 36
scon.Open(); 37
SqlCommand scmd = new SqlCommand("insert into huopin(huoName,bianma,huoDanwei,cfck,rkdw,ckdw,yskc,dixian,gaoxian) values ('" + aa + "','" + bb + "','" + cc + "','" + dd + "','" + ee + "','" + ff + "','" + gg + "','" + hh + "','" + ii + "')", scon); 38
scmd.ExecuteNonQuery(); 39
scmd.Dispose(); 40
scon.Close(); 41
Response.Write("<script language='javascript'>alert('添加成功!');</script>"); 42
Server.Transfer("Managehuo.aspx"); 43
} 44
} 45
private bool kong() 46
{ 47
if (this.TextBox1.Text == "") 48
{ 49
Response.Write("<script language='javascript'>alert('其他不能为空!');</script>"); 50
return false; 51
} 52
else 53
{ 54
if (this.TextBox2.Text == "") 55
{ 56
Response.Write("<script language='javascript'>alert('其他不能为空!');</script>"); 57
return false; 58
} 59
else 60
{ 61
if (this.TextBox3.Text == "") 62
{ 63
Response.Write("<script language='javascript'>alert('其他不能为空!');</script>"); 64
return false; 65
} 66
67
else 68
{ 69
if (this.TextBox5.Text == "") 70
{ 71
Response.Write("<script language='javascript'>alert('其他不能为空!');</script>"); 72
return false; 73
} 74
else 75
{ 76
if (this.TextBox6.Text == "") 77
{ 78
Response.Write("<script language='javascript'>alert('其他不能为空!');</script>"); 79
return false; 80
} 81
else 82
{ 83
if (this.TextBox7.Text == "") 84
{ 85
Response.Write("<script language='javascript'>alert('其他不能为空!');</script>"); 86
return false; 87
} 88
else 89
{ 90
if (this.TextBox8.Text == "") 91
{ 92
Response.Write("<script language='javascript'>alert('其他不能为空!');</script>"); 93
return false; 94
} 95
else 96
{ 97
if (this.TextBox9.Text == "") 98
{ 99
Response.Write("<script language='javascript'>alert('其他不能为空!');</script>"); 100
return false; 101
} 102
else 103
{ 104
return true; 105
} 106
} 107
} 108
} 109
} 110
} 111
} 112
} 113
} 114
protected void Button2_Click(object sender, EventArgs e) 115
{ 116
Server.Transfer("manage.aspx"); 117
} 118
} 119





}
}