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

namespace NScontract.User
{
    /// <summary>
    /// Stat 的摘要说明。
    /// </summary>
    public partial class Stat : System.Web.UI.Page
    {
        SqlConnection NSconn;


        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (Session["NSNickName"] != null)
            {
                //获得数据库连接字符串
                string NSconnection = ConfigurationSettings.AppSettings["strconnection"];
                //创建数据库连接
                NSconn = new SqlConnection(NSconnection);
                if (!IsPostBack)
                {
                    //自定义NS_DgBind()方法，加载自己连锁店的信息
                    BindGrid();
                }
            }
            else
            {
                Response.Redirect("../Index.aspx");
            }
        }

        public void BindGrid()
        {
            NSconn.Open();
            string NSstrsql = "select NSDep.* from NSDep,NSUser where NSDep.NSDepID = NSUser.NSDepID";
            SqlCommand NScmd = new SqlCommand(NSstrsql, NSconn);
            SqlDataReader NSsdr = NScmd.ExecuteReader();
            while (NSsdr.Read())
            {
                Session["NSDepID"] = NSsdr["NSDepID"];
                NSDepID.Text = Session["NSDepID"].ToString();

                Session["NSDepName"] = NSsdr["NSDepName"];
                NSDepName.Text = Session["NSDepName"].ToString();

                Session["NSDepMaster"] = NSsdr["NSDepMaster"];
                NSDepMaster.Text = Session["NSDepMaster"].ToString();

                Session["NSDepAdd"] = NSsdr["NSDepAdd"];
                NSDepAdd.Text = Session["NSDepAdd"].ToString();
            }




        }




        #region Web 窗体设计器生成的代码
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
            //
            InitializeComponent();
            base.OnInit(e);
        }

        /// <summary>
        /// 设计器支持所需的方法 - 不要使用代码编辑器修改
        /// 此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {

        }
        #endregion
    }
}
