温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:人事管理系统(课程设计)源码
当前文件:
Mispersonal/WebFiles/Leaver/Add_leaver_kind.aspx.cs,打开代码结构图
Mispersonal/WebFiles/Leaver/Add_leaver_kind.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 WebFiles_Leaver_Add_leaver_kind : System.Web.UI.Page 13
{ 14
protected void Page_Load(object sender, EventArgs e) 15
{ 16
17
} 18
protected void btnAdd_Click(object sender, EventArgs e) 19
{ 20
if(TxtID.Text.Trim()=="") 21
{ 22
Response.Write("<script>alert('假别编号不能为空!')</script>"); 23
} 24
if(TxtName.Text.Trim()=="") 25
{ 26
Response.Write("<script>alert('假别名称不能为空!')</script>"); 27
} 28
29
if ((string)Session["Name"] != "") 30
{ 31
if ((string)Session["role"] == "管理员") 32
{ 33
if (IsSalaryOrNot.Checked) 34
{ 35
string connstr = ConfigurationManager.ConnectionStrings["Mispersonalconn"].ConnectionString; 36
SqlConnection Sqlconn = new SqlConnection(connstr); 37
SqlCommand Sqlcmd = new SqlCommand(); 38
Sqlcmd.CommandText = "insert into [Tb_leaver_kind] values('" + TxtID.Text.Trim() + "','" + TxtName.Text.Trim() + "','" + IsSalaryOrNot.Text + "')"; 39
Sqlcmd.Connection = Sqlconn; 40
Sqlconn.Open(); 41
Sqlcmd.ExecuteNonQuery(); 42
} 43
else 44
{ 45
string connstr = ConfigurationManager.ConnectionStrings["Mispersonalconn"].ConnectionString; 46
SqlConnection Sqlconn = new SqlConnection(connstr); 47
SqlCommand Sqlcmd = new SqlCommand(); 48
Sqlcmd.CommandText = "insert into [Tb_leaver_kind] values('" + TxtID.Text.Trim() + "','" + TxtName.Text.Trim() + "','否 ')"; 49
Sqlcmd.Connection = Sqlconn; 50
Sqlconn.Open(); 51
Sqlcmd.ExecuteNonQuery(); 52
lbMessage.Text = "您已成功添加1条记录!"; 53
} 54
} 55
else 56
{ 57
Response.Write("<script>alert('只有管理员才可以进行此操作!')</script>"); 58
} 59
} 60
else 61
{ 62
Response.Redirect("Default.aspx"); ; 63
} 64
65
} 66
} 67





}
}