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 System.Data.SqlClient;



public partial class SysManage_top : System.Web.UI.Page
{
    
    protected void Page_Load(object sender, EventArgs e)
    {   
      

        string where1 = "";     
        string strall = "";
        if (Session["WtoRightName"] == null)
        {
            Response.Redirect("~/SYSADMIN/main/error.aspx?err=非法登陆!或系统超时，请刷新后重新登录");
        }


        

        SqlConnection conn = CDatabase.wtoconn();
        conn.Open();
        SqlCommand smd;
        SqlDataReader sdr;  
        if (Session["WtoRightLX"].ToString() == "2")
        {
             smd = new SqlCommand("select bigid from  DataMasterAdditionalControl where zt='y' order by sort", conn);
             sdr = smd.ExecuteReader();
             string dd = "";
             while (sdr.Read())
             {
               strall+=Convert.ToString(sdr.GetInt32(0))+"$";
             }
             sdr.Close();
        }
        else
        {
        smd = new SqlCommand("select gnid from UserAdmin where id=" + Session["WtoRightid"], conn);
        string sqltt1 = Convert.ToString(smd.ExecuteScalar());
        string[] sqltt2 = sqltt1.Split('$');
        string[] sqltt3;

        for (int i = 0; i < sqltt2.Length - 1; i++)
        {
            sqltt3 = sqltt2[i].Split('|');
            where1 +=sqltt3[2]+"$";
        }
           strall = where1;
        }
        string[] strdd = strall.Split('$');
        string db = "";
        string strgo = "";
        for (int b = 0; b < strdd.Length - 1; b++)
        {
            db = strdd[b].ToString()+"$";
            strall= strall.Replace(db,"");
            strall += db;
        }

        if (strall != "")
        {
            SqlCommand smdT;
            TableCell tc;
            TableRow tr;
            HyperLink hy1;
            string[] str = strall.Split('$');
            tr = new TableRow();
            SqlDataReader sdrr;
            for (int i = 0; i < str.Length - 1; i++)
            {
                tc = new TableCell();
                smdT = new SqlCommand("select bigname from DataMasterAdditionalControl where bigid=" + str[i], conn);
                hy1 = new HyperLink();
                hy1.ID = "m" + (i + 1);
                hy1.Text = Convert.ToString(smdT.ExecuteScalar());
                smdT = new SqlCommand("select bigtaghref,bigid from DataMasterAdditionalControl where bigid=" + str[i], conn);
                sdrr=smdT.ExecuteReader();
                sdrr.Read();
                hy1.NavigateUrl =sdrr.GetString(0)+"?id="+sdrr.GetInt32(1);
                sdrr.Close();
                hy1.Target = "left";
                if (i == 0)
                hy1.CssClass = "current";
                hy1.Attributes.Add("onclick", "show_menu(this)");
                tc.Controls.Add(hy1);
                tr.Controls.Add(tc);
            }

            #region 系统信息
            tc = new TableCell();
            hy1 = new HyperLink();
            hy1.ID = "m" + (str.Length);
            hy1.Text ="系统支持";
            hy1.NavigateUrl = "left.aspx?type=系统支持";
            
            hy1.Target = "left";
            hy1.Attributes.Add("onclick", "show_menu(this)");
            tc.Controls.Add(hy1);
            tr.Controls.Add(tc);
            #endregion
            TOP.Controls.Add(tr);
        }

        conn.Close();

        //标式
        GlobalEBTLogo.AlternateText = "wanCome 商城后台管理";
        Response.Write("<script language=javascript>window.parent.main.location.href='http://www.31key.com/wincart/default.aspx'</script>");
        //Response.Write("<script language=javascript>main.location.href='http://www.31key.com/SysAdminDefault.aspx'</script>");
    }

    protected void Page_SaveStateComplete(object sender, EventArgs e)
    {
        
    }
    
}
