using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class etwuser_loginerror : System.Web.UI.Page
{
    public int page = 1;
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie GetCookie = Request.Cookies["cook_admin"];
        if (Request.Cookies["cook_admin"] == null)
        {
            Response.Redirect("index.aspx");
        }
        DataSet ds = DbHelperSQL.Query("select ip from etw_IP where allow=1");
        if (ds.Tables[0].Rows.Count > 0)
        {
            if (!IsPostBack)
            {
                ipaddress.Text = ds.Tables[0].Rows[0]["ip"].ToString();
            }
        }
        if (!IsPostBack)
        {
            int totalOrders = (int)DbHelperSQL.GetSingle("select count(id) from etw_error");
            Cache["totalproduct"] = totalOrders;
            Pager1.RecordCount = totalOrders;
            Pager2.RecordCount = totalOrders;
        }
        DataUser();
    }
    protected void Pager1_PageChanging1(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {
        Pager1.CurrentPageIndex = e.NewPageIndex;
        page = Pager1.CurrentPageIndex;
        DataUser();
    }
    protected void Pager2_PageChanging1(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {
        Pager2.CurrentPageIndex = e.NewPageIndex;
        page = Pager2.CurrentPageIndex;
        DataUser();
    }
    public void DataUser()
    {
        int i = 1;
        if (Request.QueryString["page"] != null)
        {
            i = Convert.ToInt32(Request.QueryString["page"].ToString());
        }
        int mun = (i - 1) * 20;
        DataSet ds = DbHelperSQL.Query("select top 20 username,company,ER.ip,ER.id,ER.allow from etw_error ER,etw_user US where US.userid=ER.usernameid and ER.id not in(select top " + mun + " id from etw_error order by id desc) order by ER.id desc");
        if (ds.Tables[0].Rows.Count > 0)
        {
            Repeater1.DataSource = ds.Tables[0].DefaultView;
            Repeater1.DataBind();
        }
    }
    public string Cutallow(string idstr,string allowstr)
    {
        string str = string.Empty;
        if (allowstr == "1")
        {
            str = "<a onClick=\"return confirm('真的要屏蔽码？');\" href=\"allowdel.aspx?page=" + page + "&errid=" + idstr + "\">屏蔽登陆</a>";
        }
        else
        {
            str = "<a onClick=\"return confirm('真的要允许登陆码？');\" href=\"allow.aspx?page=" + page + "&errid=" + idstr + "\">允许登陆</a>";
        }
        return str;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        DbHelperSQL.ExecuteSql("update etw_IP set ip='" + ipaddress.Text.Trim() + "' where allow=1");
    }
}
