📄 admin_ip.aspx.cs
字号:
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 BLL;
using Socut.Data;
namespace Websystem.admin
{
/// <summary>
/// admin_ip 的摘要说明。
/// </summary>
public class admin_ip : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid MyDataGrid;
protected System.Web.UI.WebControls.Label lblPageCount;
protected System.Web.UI.WebControls.Label lblCurrentIndex;
protected System.Web.UI.WebControls.LinkButton btnFirst1;
protected System.Web.UI.WebControls.LinkButton btnPrev1;
protected System.Web.UI.WebControls.LinkButton btnNext1;
protected System.Web.UI.WebControls.LinkButton btnLast1;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.TextBox i1;
protected System.Web.UI.WebControls.TextBox i2;
protected System.Web.UI.WebControls.TextBox i3;
protected System.Web.UI.WebControls.TextBox i4;
protected System.Web.UI.WebControls.DropDownList ips;
protected System.Web.UI.WebControls.TextBox ipc;
protected CData myData=new CData();
protected other ot=new other();
private void Page_Load(object sender, System.EventArgs e)
{
ot.chk_user();
btnFirst1.Text = "最首页";
btnPrev1.Text = "前一页";
btnNext1.Text = "下一页";
btnLast1.Text = "最后页";
if(!this.IsPostBack)
BindGrid();
this.i1.Attributes.Add("onblur","checkvalue(this);");
this.i2.Attributes.Add("onblur","checkvalue(this);");
this.i3.Attributes.Add("onblur","checkvalue(this);");
this.i4.Attributes.Add("onblur","checkvalue(this);");
if(ot.isDefined("delid"))
{
string[] rowid=Request.Form["delid"].ToString().Split(new char[]{','});
for(int i=0;i<rowid.Length;i++)
{
delrow(Convert.ToInt32(rowid[i]));
}
Response.Redirect("admin_ip.aspx",true);
}
}
//删除记录
protected void delrow(int id)
{
string sql="delete from IpLock where ID="+id;
myData.GetExecuteNonQuery(sql);
}
protected void BindGrid()
{
DataSet ds=new DataSet();
string sql = "";
sql = "select * from IpLock order by id desc";
ds = myData.GetDataSet(sql, 0, 0, "Document");
this.MyDataGrid.DataSource = ds.Tables["Document"].DefaultView;
MyDataGrid.DataBind();
ShowStats();
}
private void ShowStats()
{
lblCurrentIndex.Text = "第 " + (MyDataGrid.CurrentPageIndex + 1).ToString() + " 页";
lblPageCount.Text = "总共 " + MyDataGrid.PageCount.ToString() + " 页";
}
public void PagerButtonClick(object sender, EventArgs e)
{
string arg = ((LinkButton)sender).CommandArgument.ToString();
switch(arg)
{
case "next":
if (MyDataGrid.CurrentPageIndex < (MyDataGrid.PageCount - 1))
{
MyDataGrid.CurrentPageIndex += 1;
}
break;
case "prev":
if (MyDataGrid.CurrentPageIndex > 0)
{
MyDataGrid.CurrentPageIndex -= 1;
}
break;
case "last":
MyDataGrid.CurrentPageIndex = (MyDataGrid.PageCount - 1);
break;
default:
MyDataGrid.CurrentPageIndex = System.Convert.ToInt32(arg);
break;
}
BindGrid();
ShowStats();
}
public void MyDataGrid_Page(object sender, DataGridPageChangedEventArgs e)
{
int startIndex ;
startIndex = MyDataGrid.CurrentPageIndex * MyDataGrid.PageSize;
MyDataGrid.CurrentPageIndex = e.NewPageIndex;
BindGrid();
ShowStats();
}
private void MyDataGrid_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
public string iplook(string input)
{
int id2=Convert.ToInt32(input);
string sql = "select * from IpLock where id="+id2;
string ip="";
DataSet ds=new DataSet();
ds=myData.GetDataSet(sql,0,0,"ds");
if(ds.Tables["ds"].Rows.Count>0)
{
int i=Convert.ToInt32(ds.Tables["ds"].Rows[0]["ipsame"].ToString());
int a=1;
while(i-a+1>0){ip+=ds.Tables["ds"].Rows[0]["ip"+Convert.ToString(a)].ToString()+".";a++;}
while((4-i)>0){ip+="*"+".";i++;}
ip=ip.Substring(0,ip.Length-1);
}
return ip;
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
private void Button1_Click(object sender, System.EventArgs e)
{
int ip1=Convert.ToInt32(this.i1.Text.ToString().Trim());
int ip2=Convert.ToInt32(this.i2.Text.ToString().Trim());
int ip3=Convert.ToInt32(this.i3.Text.ToString().Trim());
int ip4=Convert.ToInt32(this.i4.Text.ToString().Trim());
int ipsame=Convert.ToInt32(this.ips.SelectedValue.ToString().Trim());
string iplock=this.ipc.Text.ToString().Replace("'","");
string sql="insert into IpLock (ip1,ip2,ip3,ip4,ipsame,iplock) values ("+ip1+","+ip2+","+ip3+","+ip4+","+ipsame+",'"+iplock+"')";
myData.GetExecuteNonQuery(sql);
Response.Redirect("admin_ip.aspx");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -