温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:小区物业管理系统源码
当前文件:
SmallHouse/admin/editemployee.aspx.cs,打开代码结构图
SmallHouse/admin/editemployee.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
BaseClass bc = new BaseClass(); 17
public static string picpath;//存放照片的地址 18
19
protected void Page_Load(object sender, EventArgs e) 20
{ 21
if (Convert.ToString(Session["UID"]) == "") 22
{ 23
Response.Redirect("login.aspx"); 24
25
} 26
27
if (!IsPostBack) 28
{ 29
this.bind(); 30
} 31
} 32
protected void bind() 33
{ 34
string id = Request.QueryString["ID"].ToString(); 35
string sqlstr = "select * from employee where ID='" + id + "'"; 36
try 37
{ 38
SqlDataReader sda = bc.ExecRead(sqlstr); 39
if (sda.Read()) 40
{ 41
ID.Text = id; 42
Name.Text = sda["Name"].ToString(); 43
SEX.Text = sda["sex"].ToString(); 44
Job.Text = sda["job"].ToString(); 45
Arrage.Text = sda["arrage"].ToString(); 46
Address.Text = sda["address"].ToString(); 47
TEL.Text = sda["tel"].ToString(); 48
Mobile.Text = sda["mobile"].ToString(); 49
CardID.Text = sda["cardID"].ToString(); 50
Image1.ImageUrl = sda["photoPath"].ToString(); 51
picpath = sda["photoPath"].ToString(); 52
//Response.Write(sda["photoPath"].ToString()); 53
//Response.End(); 54
} 55
else 56
{ 57
Response.Write("<script>alert('数据读取错误,请重试!');</script>"); 58
return; 59
} 60
} 61
catch (Exception ex) 62
{ 63
Response.Write("系统出错,出错原因:"+ex.Message); 64
return; 65
} 66
} 67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//上传图片文件 84
protected void Button3_Click(object sender, EventArgs e) 85
{ 86
string str= this.FileUpload1.PostedFile.FileName; 87
if (str == "") 88
{ 89
Response.Write("<script>alert('请选择图片!');</script>"); 90
return; 91
} 92
93
string name=str.Substring(str.LastIndexOf("\\")+1); 94
string path=Server.MapPath("..\\photo\\")+name;//获得图片上传到系统之后的物理路径 95
picpath = "..\\photo\\" + name;//存放到数据库的图片路径 96
97
//Response.Write(path); 98
//Response.End(); 99
if(File.Exists(path)) 100
{ 101
Response.Write("<script>alert('图片已存在,请选择其它图片!');</script>"); 102
return; 103
} 104
this.FileUpload1.SaveAs(path); 105
Image1.Visible = true; 106
Image1.ImageUrl = picpath; 107
108
} 109
protected void Button1_Click(object sender, EventArgs e) 110
{ 111
112
113
string id = ID.Text; 114
string name = Name.Text; 115
string sex = SEX.SelectedValue.ToString(); 116
string job = Job.Text; 117
string arrage=Arrage .Text; 118
string cardid = CardID.Text; 119
string address = Address.Text; 120
string mobile = Mobile.Text; 121
string tel = TEL.Text; 122
123
124
string sql = "update employee set ID='" + id + ",Name='" + name + "',sex=" + sex + ",job='" + job + "',arrage='" + arrage + "',cardID='" + cardid + "',address='"; 125
sql = sql + address + "',mobile='" + mobile + "',tel='" + tel + "',photoPath='" + picpath+"'"+" where ID="+id+""; 126
//Response.Write(sql); 127
//Response.End(); 128
129
if (bc.ExecSql(sql)) 130
{ 131
Response.Write("<script language=javascript>alert('更新物业管理人员成功!');location='employee.aspx'</script>"); 132
} 133
else 134
{ 135
Response.Write("<script>alert('编辑失败,请重试!');</script>"); 136
} 137
138
139
140
} 141
142
} 143




BaseClass bc 
}
}