- 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_proman 的摘要说明。
- /// </summary>
- public partial class ST_Admin_proman : 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(!IsPostBack)
- {
- string ST_strsql;
- ST_strsql = "SELECT * FROM ST_tProduct 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_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 from ST_tProduct where ST_ID="+ST_myid;
- ST_database.execsql(ST_strsql);
- ST_strsql="SELECT * FROM ST_tProduct order by ST_ID desc";
- DataTable ST_dt = ST_database.ReadTable(ST_strsql);
- DataGrid1.DataSource = ST_dt;
- DataGrid1.DataBind();
- }
- private void DataGrid1_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
- {
- DataGrid1.EditItemIndex = -1;
- string ST_strsql;
- ST_strsql= "SELECT * FROM ST_tProduct 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;
- ST_id = e.Item.Cells[0].Text;
- TextBox tb=(TextBox)e.Item.Cells[1].Controls[0];
- ST_strsql="update ST_tProduct set ST_productname='"+((TextBox)(e.Item.Cells[1].Controls[0])).Text
- +"',ST_productprice='"+((TextBox)(e.Item.Cells[2].Controls[0])).Text+"',ST_productpic='"+((TextBox)(e.Item.Cells[3].Controls[0])).Text
- +"' where ST_ID="+ST_id;
- ST_database.execsql(ST_strsql);
- ST_strsql="SELECT * FROM ST_tProduct order by ST_ID desc";
- DataGrid1.EditItemIndex = -1;
- 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_tProduct order by ST_ID desc";
- DataTable ST_dt = ST_database.ReadTable(ST_strsql);
- DataGrid1.DataSource = ST_dt;
- DataGrid1.DataBind();
- }
- }
- }