温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:人事管理系统(课程设计)源码
当前文件:
Mispersonal/WebFiles/Employee/Add_employee.aspx.cs,打开代码结构图
Mispersonal/WebFiles/Employee/Add_employee.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_Employee_Add_employee : System.Web.UI.Page 13
{ 14
protected void Page_Load(object sender, EventArgs e) 15
{ 16
if (!IsPostBack) 17
{ 18
this.tb_birth.Attributes.Add("onfocus", "javascript:calendar()"); 19
Image1.ImageUrl = "~/WebFiles/Images/" + picurl.SelectedValue + ".GIF"; 20
21
string connstr = ConfigurationManager.ConnectionStrings["Mispersonalconn"].ConnectionString; 22
SqlConnection Sqlconn = new SqlConnection(connstr); 23
DataSet ds = new DataSet(); 24
string Agreerstr = "select D_ID,D_Name from Tb_department order by D_ID desc"; 25
SqlDataAdapter SqlAgreer = new SqlDataAdapter(Agreerstr, Sqlconn); 26
SqlAgreer.Fill(ds, "Agreer"); 27
Agreer.DataSource = ds.Tables["Agreer"].DefaultView; 28
Agreer.DataTextField = "D_Name"; 29
Agreer.DataValueField = "D_ID"; 30
Agreer.DataBind(); 31
Sqlconn.Close(); 32
} 33
} 34
35
36
protected void add_Click(object sender, EventArgs e) 37
{ 38
if (tb_id.Text.Trim() == "") 39
{ 40
Response.Write("<script>alert('员工编号不能为空')</script>"); 41
return; 42
} 43
//if (tb_name.Text.Trim() == "") 44
// { 45
// Response.Write("<script>alert('员工姓名不能为空')</script>"); 46
// return; 47
// } 48
if (tb_birth.Text.Trim() == "") 49
{ 50
Response.Write("<script>alert('出生年月不能为空')</script>"); 51
return; 52
} 53
54
if (tb_tel.Text.Trim() == "") 55
{ 56
Response.Write("<script>alert('联系电话不能为空')</script>"); 57
return; 58
} 59
if (tb_address.Text.Trim() == "") 60
{ 61
Response.Write("<script>alert('联系地址不能为空')</script>"); 62
return; 63
} 64
Employ Registor = new Employ(); 65
string pic= "~/WebFiles/Images/" + picurl.SelectedValue + ".GIF"; 66
Registor.Insert(tb_id.Text.Trim(),tb_name.Text.Trim(),sex.SelectedValue,tb_birth.Text.Trim(),tb_tel.Text.Trim(),tb_address.Text.Trim(),Agreer.SelectedValue,tb_intro.Text.Trim(),pic); 67
Response.Redirect("~/WebFiles/Employee/List_employee.aspx"); 68
} 69
70
protected void cancel_Click(object sender, EventArgs e) 71
{ 72
tb_id.Text = ""; 73
tb_name.Text = ""; 74
tb_birth.Text = ""; 75
tb_tel.Text= ""; 76
tb_address.Text = ""; 77
tb_intro.Text = ""; 78
79
} 80
} 81





}
}