温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:小区物业管理系统源码
当前文件:
SmallHouse/admin/addemployee.aspx.cs,打开代码结构图
SmallHouse/admin/addemployee.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
using System.IO; 13
14
public partial class admin_Default2 : System.Web.UI.Page 15
{ 16
public static string picpath="..\\photo\\default.gif";//存放照片的地址 17
18
protected void Page_Load(object sender, EventArgs e) 19
{ 20
if (Convert.ToString(Session["UID"]) == "") 21
{ 22
Response.Redirect("login.aspx"); 23
24
} 25
26
} 27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//上传图片文件 46
protected void Button3_Click(object sender, EventArgs e) 47
{ 48
string str= this.FileUpload1.PostedFile.FileName; 49
if (str == "") 50
{ 51
Response.Write("<script>alert('请选择图片!');</script>"); 52
return; 53
} 54
55
string name=str.Substring(str.LastIndexOf("\\")+1);//获得文件名称 56
string path=Server.MapPath("..\\photo\\")+name;//获得图片上传到系统之后的物理路径 57
picpath = "..\\photo\\" + name;//存放到数据库的图片路径 58
59
//Response.Write(path); 60
//Response.End(); 61
if(File.Exists(path)) 62
{ 63
Response.Write("<script>alert('图片已存在,请选择其它图片!');</script>"); 64
return; 65
} 66
this.FileUpload1.SaveAs(path); 67
Image1.Visible = true; 68
Image1.ImageUrl = picpath; 69
70
} 71
protected void Button1_Click(object sender, EventArgs e) 72
{ 73
BaseClass bc = new BaseClass(); 74
string id = ID.Text; 75
string name = Name.Text; 76
string sex = SEX.SelectedValue.ToString(); 77
string job = Job.Text; 78
string arrage=Arrage .Text; 79
string cardid = CardID.Text; 80
string address = Address.Text; 81
string mobile = Mobile.Text; 82
string tel = TEL.Text; 83
string sql = "select count(*) from employee where ID='" + id + "'"; 84
int count = (int)bc.ExecCscalar(sql); 85
if (count > 0) 86
{ 87
Response.Write("<script>alert('编号重复');</script>"); 88
return; 89
} 90
91
sql="insert into employee(ID,name,sex,job,arrage,address,tel,mobile,cardID,photoPath) values('"; 92
sql=sql+id+"','"+name+"',"+sex+",'"+job+"','"+arrage+"','"+address+"','"+tel+"','"+mobile+"','"+cardid+"','"+picpath+"')"; 93
94
// Response.Write(sql); 95
// Response.End(); 96
97
if (bc.ExecSql(sql)) 98
{ 99
Response.Write("<script language=javascript>alert('添加物业管理人员成功!');location='employee.aspx'</script>"); 100
} 101
else 102
{ 103
Response.Write("<script>alert('添加失败,请重试!');</script>"); 104
} 105
106
107
108
} 109
} 110





}
}