| 发表于:2007-07-16 13:58:554楼 得分:0 |
conetent page using system; using system.data; using system.configuration; using system.collections; using system.web; using system.web.security; using system.web.ui; using system.web.ui.webcontrols; using system.web.ui.webcontrols.webparts; using system.web.ui.htmlcontrols; public partial class admin_adduser : system.web.ui.page { dbconnection db = new dbconnection(); string username = " "; string userpwd = " "; string sex = " "; string dept = " "; string email = " "; string mobile = " "; string officetel = " "; int userid = 0; protected void page_load(object sender, eventargs e) { getdept(); getmaxitemnum(); } private void getdept() { string sql_dept = "select dept_id,dept_name from dc_department "; dataset ds = db.db_createdataset(sql_dept); ddldept.datasource = ds.tables[0]; ddldept.datatextfield = "dept_name "; ddldept.datavaluefield = "dept_id "; ddldept.databind(); } private void getmaxitemnum() { string sql_itemnumber = "select max(convert(int,user_id)) from dc_user "; system.data.dataset ds_itemnumber = db.db_createdataset(sql_itemnumber); userid = convert.toint32(ds_itemnumber.tables[0].rows[0][0]); db.close(); } protected void imgok_click(object sender, imageclickeventargs e) { username = this.txtusername.text.trim(); userpwd = this.txtuserpwd.text.trim(); sex = this.rblsex.selectedvalue.tostring(); dept = this.ddldept.selecteditem.value; email = this.txtemail.text.trim(); mobile = this.txtmobile.text.trim(); officetel = this.txtofficetel.text.trim(); userid = userid+1; string sql = "insert into dc_user (user_id,user_name,sex,dept_id,password,email,mobile,officetel) values ( ' " + userid + " ', ' " + username + " ', ' " + sex + " ', ' " + dept + " ', ' " + userpwd + " ', ' " + email + " ', ' " + mobile + " ', ' " + officetel + " ') "; db.db_EXECutenonquery(sql); db.close(); } } | | |
|