using System.Web.UI.HtmlControls; using System.Data.SqlClient;
public partial class WebFiles_Department_View_Depart : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
if (!IsPostBack) {
string id = Request[\ string name = Request[\ Session[\ Session[\ Bond(); } }
private void Bond() {
string id = (string)Session[\
string sql = \+ \
string connstr =
ConfigurationManager.ConnectionStrings[\tring;
SqlConnection Sqlconn = new SqlConnection(connstr); Sqlconn.Open();
SqlCommand sc = new SqlCommand(sql, Sqlconn); SqlDataReader myreader = sc.ExecuteReader(); if (myreader.Read()) {
TxtID.Text = myreader[0].ToString();
- 19 -
TxtName.Text = myreader[1].ToString(); TxtTel.Text = myreader[2].ToString(); TxtAddress.Text = myreader[3].ToString(); TxtChief.Text = myreader[4].ToString(); TxtBelong.Text = myreader[5].ToString(); Sqlconn.Close(); } }
protected void Edit_Click(object sender, EventArgs e) {
if ((string)Session[\ {
if ((string)Session[\管理员\ {
string sql = \ +TxtName.Text.Trim()+\ +TxtTel.Text.Trim()+\ +TxtAddress.Text.Trim()+\ +TxtChief.Text.Trim()+\ +TxtBelong.Text.Trim()+\ +TxtID.Text.Trim()+\ string connstr =
ConfigurationManager.ConnectionStrings[\tring;
SqlConnection Sqlconn = new SqlConnection(connstr); Sqlconn.Open();
SqlCommand sc = new SqlCommand(sql, Sqlconn); sc.ExecuteNonQuery();
lbMessage.Text = \您已成功更新1条记录!\ Sqlconn.Close(); }
- 20 -
else {
Response.Write(\只有管理员才可以进行此操作!')\ } } else {
Response.Redirect(\ } }
protected void Delete_Click(object sender, EventArgs e) {
if ((string)Session[\ {
if ((string)Session[\管理员\ {
string id = (string)Session[\
string sql = \from [Tb_department] where D_ID='\+ id + \
string connstr =
ConfigurationManager.ConnectionStrings[\tring;
SqlConnection Sqlconn = new SqlConnection(connstr); Sqlconn.Open();
SqlCommand sc = new SqlCommand(sql, Sqlconn); sc.ExecuteNonQuery(); Sqlconn.Close();
Response.Redirect(\ }
- 21 -
else {
Response.Write(\只有管理员才可以进行此操作!')\ } } else {
Response.Redirect(\ } } }
3、List_Depart(列举部门信息) 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; using System.Data.SqlClient;
public partial class WebFiles_Department_List_Depart : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
if(!IsPostBack)
- 22 -