温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:PowerOA办公自动化系统商业源码
当前文件:
PowerOA/AddressList/AddresslistModify.aspx.cs[4K,2009-6-12 11:52:10],打开代码结构图
PowerOA/AddressList/AddresslistModify.aspx.cs[4K,2009-6-12 11:52:10],打开代码结构图1/************************************************************************************** 2
作者:蒲丰. 3
创建日期:2003-11-24 4
修改者: 5
修改日期: 6
修改部分: 7
类功能: 通讯录的修改功能.. 8
****************************/ 9
10
using System; 11
using System.Collections; 12
using System.ComponentModel; 13
using System.Data; 14
using System.Drawing; 15
using System.Web; 16
using System.Web.SessionState; 17
using System.Web.UI; 18
using System.Web.UI.WebControls; 19
using System.Web.UI.HtmlControls; 20
21
namespace OI.AddressList 22
{ 23
/// <summary> 24
/// AddresslistModify 的摘要说明。 25
/// </summary> 26
public class AddresslistModify : OI.PageBase 27
{ 28
protected System.Web.UI.WebControls.TextBox TextBoxCompany; 29
protected System.Web.UI.WebControls.TextBox TextBoxEmail; 30
protected System.Web.UI.WebControls.TextBox TextBoxTel; 31
protected System.Web.UI.WebControls.TextBox TextBoxAddress; 32
protected System.Web.UI.WebControls.DropDownList DropDownListsex; 33
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1; 34
protected System.Web.UI.WebControls.TextBox TextBoxReletioner; 35
// int id; 36
protected System.Data .DataSet ds; 37
protected System.Web.UI.WebControls.ImageButton ImageButton1; 38
OI.DatabaseOper .DatabaseConnect Dbc=new OI.DatabaseOper.DatabaseConnect (); 39
private void Page_Load(object sender, System.EventArgs e) 40
{ 41
// 在此处放置用户代码以初始化页面 42
if (Session["userid"]==null) 43
{ 44
Response.Write ("<script>alert('超时,请重新登录');top.location.href='../userpass.aspx';</script>"); 45
return ; 46
} 47
if (!Page.IsPostBack ) 48
{ 49
try 50
{ 51
ViewState["id"]=int.Parse (Request.Params ["id"].ToString ()); 52
} 53
catch 54
{ 55
return ; 56
} 57
CreateDataSource(); 58
} 59
} 60
Web 窗体设计器生成的代码 81
private void Button1_Click(object sender, System.EventArgs e) 82
{ 83
84
} 85
private void CreateDataSource() 86
{ 87
string str="select * from addresslist where ListID=" +ViewState["id"].ToString (); 88
ds=new DataSet (); 89
ds=Dbc.getBinding (str,"t"); 90
if (ds.Tables[0].Rows .Count >0) 91
{ 92
DataRow dr=ds.Tables[0].Rows[0]; 93
TextBoxReletioner.Text =dr["Reletioner"].ToString (); 94
TextBoxAddress.Text =dr["Address"].ToString (); 95
TextBoxTel.Text =dr["Tel"].ToString (); 96
TextBoxEmail.Text =dr["Email"].ToString (); 97
TextBoxCompany.Text =dr["company"].ToString (); 98
if (dr["sex"].ToString ()=="True") 99
{ 100
DropDownListsex.Items.FindByValue ("1").Selected =true; 101
} 102
else 103
{ 104
DropDownListsex.Items.FindByValue ("0").Selected =true; 105
} 106
} 107
} 108
109
private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e) 110
{ 111
string str ="select count(*) from AddressList where ListID !="+ViewState["id"].ToString() +" and Reletioner ='"+TextBoxReletioner.Text .Replace ("'","''") +"'"; 112
if (int.Parse (Dbc.GetValueBySql(str) )>0) 113
{ 114
Page.RegisterStartupScript ("","<script>alert('这个联系人己经存在!')</script>"); 115
return ; 116
} 117
str = " update AddressList set Reletioner='"+TextBoxReletioner.Text.Replace ("'","''")+"',"; 118
str += "sex="+ DropDownListsex.SelectedValue+ ","; 119
str += "Address='"+TextBoxAddress.Text .Replace ("'","''")+"',"; 120
str += "Tel='"+TextBoxTel.Text+"',"; 121
str += "Email='"+TextBoxEmail.Text +"',"; 122
str += "Company='" +TextBoxCompany.Text.Replace ("'","''")+"',"; 123
str += "UserID=" + Session["userid"] ; 124
str += "where ListID ="+ViewState["id"].ToString (); 125
Dbc.ExecuteSQL (str); 126
Response.Redirect ("AddressList.aspx"); 127
} 128
} 129
} 130




作者:蒲丰.
***************************

