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;
using System.Data.OleDb;
namespace ygdzwww
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.LinkButton PageFirst;
protected System.Web.UI.WebControls.LinkButton PageNext;
protected System.Web.UI.WebControls.LinkButton PageLast;
protected System.Web.UI.WebControls.LinkButton PagePre;
protected System.Web.UI.WebControls.Button BTXianDelete;
protected System.Web.UI.WebControls.Button BTXianSearch;
protected System.Web.UI.WebControls.Label LBXianName;
protected System.Web.UI.WebControls.TextBox TBXianName;
protected System.Web.UI.WebControls.Label LBPageCount;
protected System.Web.UI.WebControls.Button BTXianAdd;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!Page.IsPostBack)
{
DataGrid1.DataSource=new YGDZ.WKR_T01_01_1Service().GetAll();
DataGrid1.DataBind();
LBPageCount.Text = "第"+((Int32) DataGrid1.CurrentPageIndex +1)+"页"+"/共"+DataGrid1.PageCount +"页";
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.BTXianAdd.Click += new System.EventHandler(this.BTXianAdd_Click);
this.BTXianDelete.Click += new System.EventHandler(this.BTXianDelete_Click);
this.BTXianSearch.Click += new System.EventHandler(this.BTXianSearch_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void BTXianAdd_Click(object sender, System.EventArgs e)
{
Response.Redirect("YGDZ_xianadd.aspx" );
}
public void PageButton(object sender, System.EventArgs e)
{
string arg=((LinkButton)sender).CommandArgument;
switch(arg)
{
case ("pagefirst"):
DataGrid1.CurrentPageIndex=0;
break;
case ("pagenext"):
if(DataGrid1.CurrentPageIndex<(DataGrid1.PageCount -1))
DataGrid1.CurrentPageIndex ++;
break;
case ("pagepre"):
if(DataGrid1.CurrentPageIndex>0)
DataGrid1.CurrentPageIndex --;
break;
case ("pagelast"):
DataGrid1.CurrentPageIndex=DataGrid1.PageCount-1;
break;
}
DataGrid1.DataSource=new YGDZ.WKR_T01_01_1Service().GetAll();
DataGrid1.DataBind();
LBPageCount.Text="第"+((Int32) DataGrid1.CurrentPageIndex +1)+"页"+"/共"+DataGrid1.PageCount +"页";
}
private void BTXianSearch_Click(object sender, System.EventArgs e)
{
if(TBXianName.Text.Trim()!="")
{
DataGrid1.DataSource=new YGDZ.WKR_T01_01_1Service().GetbySQL("select * from wkr_t01_01_1 where B010102 like '%"+TBXianName.Text.Trim()+"%'");
DataGrid1.DataBind();
LBPageCount.Text="第"+((Int32) DataGrid1.CurrentPageIndex +1)+"页"+"/共"+DataGrid1.PageCount +"页";
}
else
{
DataGrid1.DataSource=new YGDZ.WKR_T01_01_1Service().GetAll();
DataGrid1.DataBind();
}
}
private void BTXianDelete_Click(object sender, System.EventArgs e)
{
foreach(DataGridItem item in DataGrid1.Items )
{
CheckBox selection;
selection = (CheckBox)item.FindControl("chk");
if (selection.Checked)
{
string sXianCode=item.Cells[1].Text;
YGDZ.WKR_T01_01_1Service objService2=new YGDZ.WKR_T01_01_1Service();
YGDZ.WKR_T01_01_1Set dset= objService2.GetbySQL("delete WKR_T01_01_1 where B010101="+sXianCode);
}
}
//
DataGrid1.DataSource=new YGDZ.WKR_T01_01_1Service().GetAll();
DataGrid1.DataBind();
LBPageCount.Text ="第"+((Int32) DataGrid1.CurrentPageIndex +1)+"页"+"/共"+DataGrid1.PageCount +"页";
}
}
}