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;
using Base;
using AdminRights;

public partial class admin_Rights_ManagerLogList : BasePage
{ 
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckRights("system", "B1");
        if (!IsPostBack)
        {
            Bind();
        }
    }
    private void Bind()
    {
        string strWhere="1=1";
        string strURl = Request.RawUrl;
        strURl = strURl.Substring(0, strURl.IndexOf(".aspx")) + ".aspx";
        PageNo1.Strurl = strURl;
        if (Request.QueryString["page"] != null)
        {
            PageNo1.Pageindex = Convert.ToInt32(Request.QueryString["page"].ToString());
            PageNo1.PageSize = 12;
            if (Session["strWhere"] != null)
            {
                PageNo1.Where = Session["strWhere"].ToString();
            }
            else
            {
                PageNo1.Where = "1=1";
            }
            PageNo1.Table = "W_ManagerCount";
            PageNo1.FldName = "LastDate";
            PageNo1.StrGetFields = "*";
            DataTable table = PageNo1.BindViewDesc();
            grdManagerLog.DataSource = table.DefaultView;
            grdManagerLog.DataBind();
        }
        else
        {
            PageNo1.Pageindex = 1;
            PageNo1.PageSize = 12; 
            PageNo1.Where = "1=1";
            PageNo1.Table = "W_ManagerCount";
            PageNo1.FldName = "LastDate";
            PageNo1.StrGetFields = "*";
            DataTable table = PageNo1.BindViewDesc();
            grdManagerLog.DataSource = table.DefaultView;
            grdManagerLog.DataBind();
        }
    }
    
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        for (int i = 0; i <= grdManagerLog.Rows.Count - 1; i++)
        {

            CheckBox cbox = (CheckBox)grdManagerLog.Rows[i].FindControl("CheckBox1");
            if (cbox.Checked == true)
            {
                int id = Convert.ToInt32(grdManagerLog.DataKeys[i].Value);
                IManagerCount RMan = new RManagerCount();
                int m = RMan.Delete(id);
            }
        }
        Bind();
    }
    protected void grdManagerLog_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onMouseOver", "SetNewColor(this);");
            e.Row.Attributes.Add("onMouseOut", "SetOldColor(this)");
        }
    }
}
