using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using SysCore.Model;
using SysCore.DAL;

public partial class System_GiveAuthority_GiveAuthority_Box : System.Web.UI.Page
{
    public Hashtable xview = new Hashtable();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Init_Page();
        }
    }
    void Init_Page()
    {
        int id = Convert.ToInt32(Request["id"]);
        string module = Request.QueryString["category"];
        string type = Request.QueryString["type"];
        if (module.Equals("")) return;
        string s = "";
        AuthDAL dal = new AuthDAL();
        DataTable dt = dal.GetList(module);
        foreach (DataRow dr in dt.Rows)
        {
            string auth_code = dr["auth_code"].ToString();
            string auth_name = dr["auth_name"].ToString();
            bool has_auth;
            if (type.Equals("Member"))
            {
                has_auth = dal.CheckMemberHasAuth(id, auth_code);
            }
            else
            {
                has_auth = dal.CheckRoleHasAuth(id, auth_code);
            }
            string html_checked = "";
            if (has_auth)
            {
                html_checked = " checked='checked' ";
            }

            s += "<div><input type='checkbox' name='chk' value='" + auth_code + "' " + html_checked + "/>" + auth_name + "</div>";

        }
        xview.Add("auth_box", s);
    }
}