using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data.OleDb;
using System.Data;

public partial class sysb : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
            return;

        #region 实验室管理制度
        DataTable dt_gzzd = FrontFunc.GetDataByClassID("4", "307", "");
        foreach (DataRow dr in dt_gzzd.Rows)
        {
            lit_sysglzd.Text += "<li><span class='new_icon1'></span><a href='sysglzd_show.aspx?gid=" + dr["ID"] + "' title='" + dr["Title"] + "'>" + FrontFunc.Cutstring(dr["Title"].ToString(), 13) + "</a></li>";
        }
        #endregion

        #region 校外实习基地  友情链接
        DataTable dt_link1 = FrontFunc.GetLinks("5", "校外实习基地");
        DataTable dt_link2 = FrontFunc.GetLinks("6", "友情链接");

        foreach (DataRow dr in dt_link1.Rows)
        {
            lit_xwsxjd.Text += "<li><a href='" + dr["LinkPath"] + "' title='" + dr["Title"] + "'>" + FrontFunc.Cutstring(dr["Title"].ToString(), 10) + "</a></li>";
        }

        foreach (DataRow dr in dt_link2.Rows)
        {
            lit_link2.Text += "<li><span class='new_icon1'></span><a href='" + dr["LinkPath"] + "' title='" + dr["Title"] + "'>" + FrontFunc.Cutstring(dr["Title"].ToString(), 10) + "</a></li>";
        }
        #endregion

        #region 实验室列表
        string strtemp = "";
        string sql = "select * from NT_Class where CreateClassId=298 order by ID asc";
        DataTable dt = DbHelperOleDb.ExecuteDataSet(CommandType.Text, sql, null).Tables[0];
        foreach (DataRow dr in dt.Rows)
        {
            strtemp += "<dl class='yqsb clear'><dt><img src='" + dr["ClassPicture"] + "' /></dt>";
            strtemp += "<dd><div class='top f14 bold'>" + dr["ClassName"] + "</div>";
            strtemp += "<div class='cen blacks'><div class='clear'>";

            string strsql1 = "select * from NT_ClassType where ClassId=" + dr["ID"].ToString();
            DataTable dt1 = DbHelperOleDb.ExecuteDataSet(CommandType.Text, strsql1, null).Tables[0];
            if (dt1 != null && dt1.Rows.Count > 0)
            {
                string strsql = "select top 14 * from NT_Data where ClassId=309 and TypeName = '" + dt1.Rows[0]["Id"].ToString() + "'";
                DataTable dt_syslb = DbHelperOleDb.ExecuteDataSet(CommandType.Text, strsql, null).Tables[0];
                foreach (DataRow drr in dt_syslb.Rows)
                {
                    strtemp += "<a href='syslb_show.aspx?nid=" + drr["ID"] + "'>" + drr["Title"] + "</a>";
                }
                strtemp += "</div></div><p class='right'><input class='more_input1' onclick=\"window.location.href='sysb_list.aspx?nid=" + dt1.Rows[0]["Id"].ToString() + "'\" type='button' name='button' id='button' value='更多设备'></p></dd></dl>";
            }
        }
        lit_sysb.Text = strtemp;


        //<dl class='yqsb clear'>
        //        <dt><img src='img/photo1.jpg' /></dt>
        //        <dd>
        //            <div class='top f14 bold'>纺织纤维工程实验室</div>
        //            <div class='cen blacks'>
        //                <div class='clear'>
        //                    <a href='#'>自动开袋机</a><a href='#'>FAST织物风格仪</a><a href='#'>气囊式接触压测量系统</a><a href='#'>红外线在线测温系统</a><a href='#'>车缝电脑自动悬吊系统</a><a href='#'>三维人体测量系统</a><a href='#'>表面摩擦性能测试机微型计算机</a><a href='#'>自动开袋机</a><a href='#'>FAST织物风格仪</a><a href='#'>气囊式接触压测量系统</a><a href='#'>红外线在线测温系统</a><a href='#'>车缝电脑自动悬吊系统</a><a href='#'>三维人体测量系统</a><a href='#'>表面摩擦性能测试机微型计算机</a>
        //                </div>
        //            </div>
        //            <p class='right'><input class='more_input1' type='submit' name='button' id='button' value='更多设备'></p>
        //        </dd>
        //    </dl>

        #endregion
    }

    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (this.txt_Account.Text.Trim() == "" || this.txt_Pwd.Text.Trim() == "")
        {
            JavaScriptFunc.Alert(this.Page, "用户名和密码不能为空");
        }
        else
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("select * from NT_Member ");
            sb.Append(" where Account=@Account and Password=@Password");
            OleDbParameter[] parameters = { new OleDbParameter("@Account", OleDbType.VarChar), new OleDbParameter("@Password", OleDbType.VarChar) };
            parameters[0].Value = StringFunc.DataFilter(txt_Account.Text.Trim());
            parameters[1].Value = StringFunc.DataFilter(PageFunc.GetMd5(txt_Pwd.Text.Trim()));

            OleDbDataReader odr = DbHelperOleDb.ExecuteDataReader(CommandType.Text, sb.ToString(), parameters);

            if (odr.HasRows)
            {
                while (odr.Read())
                {
                    Session["Account1"] = odr["Account"];
                    Session["Name1"] = odr["Name"];
                    Session["ID1"] = odr["ID"];
                }
            }
            else
            {
                JavaScriptFunc.Alert(this.Page, "用户名和密码不正确");
            }
        }
    }

}
