- using System;
- using System.Collections;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Web;
- using System.Web.SessionState;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- namespace ST_GROUP.EnterpriseOnlineInfoManage
- {
- /// <summary>
- /// ST_Admin_userman 的摘要说明。
- /// </summary>
- public partial class ST_Admin_userman : System.Web.UI.Page
- {
- ST_DataBase ST_database = new ST_DataBase();
- protected void Page_Load(object sender, System.EventArgs e)
- {
- // 在此处放置用户代码以初始化页面
- if (Session["admin"] == null)
- {
- //Response.Write("<script>alert("您还没有登录,不能进行接下来的操作,请登录后断续!");</script>");
- Response.Redirect("ST_contraller.aspx?cname=noadmin");
- }
- if(!Page.IsPostBack)
- {
- string ST_strsql;
- ST_strsql = "SELECT * FROM ST_tUser order by ST_ID desc ";
- DataTable ST_dt = ST_database.ReadTable(ST_strsql);
- DataGrid1.DataSource = ST_dt;
- DataGrid1.DataBind();
- }
- }
- #region Web 窗体设计器生成的代码
- override protected void OnInit(EventArgs e)
- {
- //
- // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
- //
- InitializeComponent();
- base.OnInit(e);
- }
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.DataGrid1.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_CancelCommand);
- this.DataGrid1.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_EditCommand);
- this.DataGrid1.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_UpdateCommand);
- this.DataGrid1.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_DeleteCommand);
- }
- #endregion
- private void DataGrid1_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
- {
- DataGrid1.EditItemIndex = -1;
- string ST_strsql;
- ST_strsql= "SELECT * FROM ST_tUser order by ST_ID desc ";
- DataTable ST_dt = ST_database.ReadTable(ST_strsql);
- DataGrid1.DataSource = ST_dt;
- DataGrid1.DataBind();
- }
- private void DataGrid1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
- {
- string ST_myid;
- string ST_strsql="";
- ST_myid =e.Item.Cells[0].Text;
- ST_strsql="delete * fromt ST_tUser where ST_ID="+ST_myid;
- ST_database.execsql(ST_strsql);
- ST_strsql= "SELECT * FROM ST_tUser order by ID desc ";
- DataTable ST_dt = ST_database.ReadTable(ST_strsql);
- DataGrid1.DataSource = ST_dt;
- DataGrid1.DataBind();
- }
- private void DataGrid1_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
- {
- DataGrid1.EditItemIndex = e.Item.ItemIndex;
- string ST_strsql;
- ST_strsql="SELECT * FROM ST_tUser order by ST_ID desc ";
- DataTable ST_dt = ST_database.ReadTable(ST_strsql);
- DataGrid1.DataSource = ST_dt;
- DataGrid1.DataBind();
- }
- private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
- {
- string ST_id;
- string ST_strsql;
- TextBox username,userpass,useracc;
- ST_id = e.Item.Cells[0].Text;
- username = (TextBox)(e.Item.Cells[1].Controls[0]);
- userpass = (TextBox)(e.Item.Cells[2].Controls[0]);
- useracc = (TextBox)(e.Item.Cells[6].Controls[0]);
- //TextBox3.Text=tb.Text;
- ST_strsql="update ST_tUser set ST_username='"+username.Text+"',ST_userpassword='" + userpass.Text+ "',ST_userclass="+ useracc.Text + " where ST_ID="+ST_id;
- //Response.Write(strsql);
- ST_database.execsql(ST_strsql);
- ST_strsql="SELECT * FROM ST_tUser order by ST_ID desc ";
- DataGrid1.EditItemIndex = -1;
- DataTable ST_dt = ST_database.ReadTable(ST_strsql);
- DataGrid1.DataSource = ST_dt;
- DataGrid1.DataBind();
- }
- }
- }