📄 employeeadmin.aspx.cs
字号:
using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace NewGlassBook
{
public class EmployeeAdmin :MyPage
{
protected SuperDataGrid dgShow;
protected System.Web.UI.WebControls.Label lblWarning;
protected System.Web.UI.WebControls.LinkButton DeleteLink;
protected NewGlassBook.MyTextBox conditionValue;
protected System.Web.UI.WebControls.DropDownList condition;
protected NewGlassBook.MyButton dbtn_search;
protected NewGlassBook.SuperDataGrid SuperDataGrid1;
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dbtn_search.Click += new System.EventHandler(this.dbtn_search_Click);
this.dgShow.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgShow_EditCommand);
this.dgShow.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.dgShow_Change);
this.dgShow.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgShow_CancelCommand);
this.dgShow.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgShow_UpdateCommand);
this.dgShow.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgShow_DeleteCommand);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
string strSql;
Record r=new Record();
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
strSql="select * from employee a,company b where a.companyid=b.id and a.id<>'000'";
Session["strSql"]=strSql;
dgShowOpen();
}
}
public void dgShow_Change(Object sender, DataGridPageChangedEventArgs e)
{
dgShow.CurrentPageIndex = e.NewPageIndex;
dgShowOpen();
}
private void dgShowOpen()
{
DataSet ds=r.GetData("employee",Session["strSql"].ToString());
DataView dv=ds.Tables["employee"].DefaultView;
dgShow.DataSource=dv;
dgShow.PagerStyle.Mode=PagerMode.NumericPages;
dgShow.DataBind();
}
private void dbtn_search_Click(object sender, System.EventArgs e)
{
string strValue,strCondition;
strValue=conditionValue.Text;
strCondition=condition.SelectedItem.Value.ToString();
strSql="select * from employee a,company b where";
strSql=strSql + " a.companyid=b.id and "+strCondition+" like '%"+strValue+"%' and a.id<>'000'";
Session["strSql"]=strSql;
dgShow.CurrentPageIndex=0;
dgShowOpen();
}
private void dgShow_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
dgShow.EditItemIndex=e.Item.ItemIndex;
dgShowOpen();
}
private void dgShow_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
dgShow.EditItemIndex=-1;
dgShowOpen();
}
private void dgShow_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
strSql="update employee set password='"+((TextBox)(e.Item.Cells[1].Controls[0])).Text+"',";
strSql+="name='"+((TextBox)(e.Item.Cells[2].Controls[0])).Text+"',";
strSql+="Mobile='"+((TextBox)(e.Item.Cells[3].Controls[0])).Text+"',";
strSql+="Tel='"+((TextBox)(e.Item.Cells[4].Controls[0])).Text+"' ";
strSql+=" where id='";
strSql+=e.Item.Cells[0].Text +"'";
if(r.ExecuteQuery(strSql)!=1)
Response.Write("Update Error");
dgShow.EditItemIndex=-1;
dgShowOpen();
}
private void dgShow_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
strSql="delete from employee where id='"+e.Item.Cells[0].Text+"'";
r.ExecuteQuery(strSql);
dgShowOpen();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -