📄 supplyadmin.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
{
/// <summary>
/// Summary description for subcompany_admin.
/// </summary>
public class SupplyAdmin :MyPage
{
protected SuperDataGrid dgShow;
protected System.Web.UI.WebControls.LinkButton DeleteLink;
protected System.Web.UI.WebControls.Label lblWarning;
protected NewGlassBook.MyButton dbtn_search;
protected NewGlassBook.MyTextBox conditionValue;
protected System.Web.UI.WebControls.DropDownList condition;
Record r=new Record();//访问数据库用
string strSql;//Sql语句字符串
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
strSql="select * from supply where id<>'s0000' order by id";
Session["strSql"]=strSql;
dgShowOpen();//绑定datagrid
}
}
private void dgShowOpen()
{
DataSet ds=r.GetData("supply",Session["strSql"].ToString());
DataView dv=ds.Tables["supply"].DefaultView;
dgShow.DataSource=dv;
dgShow.DataBind();
}
public void dgShow_Change(Object sender, DataGridPageChangedEventArgs e)
{
dgShow.CurrentPageIndex = e.NewPageIndex;//更新datagrid的pageindex
dgShowOpen();
}
protected void dgShow_Delete(Object sender,DataGridCommandEventArgs e)
{
string item = e.Item.Cells[2].Text;//取得供应商id
string strSql="delete from supply where ID='"+item+"'";
if(r.GetData("select supplyid from brand where supplyid='"+item+"'",1)!="")
{
lblWarning.Text="请您先删除该供应商的品牌信息";
return;
}
if(r.ExecuteQuery(strSql)==1)
{
dgShowOpen();
}
else
{
lblWarning.Text=r.ErrMsg;
}
}
#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.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgShow_Delete);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void dbtn_search_Click(object sender, System.EventArgs e)
{
string strValue,strCondition;
strValue=conditionValue.Text;
strCondition=condition.SelectedItem.Value.ToString();
strSql="select * from supply where "+strCondition+" like '%"+strValue+ "%'";
Session["strSql"]=strSql;
dgShow.CurrentPageIndex=0;
dgShowOpen();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -