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 index : System.Web.UI.Page
{
    public string imgurl_list;
    public string imgurl;
    public string imgtitle_list;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
            return;

        #region 首页轮播效果
        DataTable dt_Advertising = FrontFunc.GetAdvertising();

        int i = 0;
        foreach (DataRow dr in dt_Advertising.Rows)
        {
            imgurl_list += dr["FilePath"] + "|";
            imgurl += dr["WebPath"] + "|";
            imgtitle_list += dr["Title"] + "|";
        }
        imgurl_list = imgurl_list.Substring(0, imgurl_list.Length - 1);
        imgurl = imgurl.Substring(0, imgurl.Length - 1);
        imgtitle_list = imgtitle_list.Substring(0, imgtitle_list.Length - 1);
        #endregion

        #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='news_show.aspx?nid=" + dr["ID"] + "' title='" + dr["Title"] + "'>" + FrontFunc.Cutstring(dr["Title"].ToString(), 13) + "</a></li>";
        }
        #endregion

        #region 成果展示
        //DataTable dt_cgzs = FrontFunc.GetDataByClassID("8", "345,349,352,358", "");
        DataTable dt_cgzs = FrontFunc.GetDataByClassID("8", "349", "");
        foreach (DataRow dr in dt_cgzs.Rows) {
            lit_cgzs.Text += "<a href='show.aspx?nid=" + dr["ID"] + "'><img src='" + dr["TitlePicture"] + "'/></a>";
        }
        #endregion

        #region 精品课程导航
        DataTable dt_jpkc = FrontFunc.GetDataByClassID("6", "321", "");
        foreach (DataRow dr in dt_jpkc.Rows)
        {
            lit_jpkc.Text += "<li><span class='new_icon1'></span><a href='show.aspx?nid=" + 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 新闻公告
        DataTable dt_news = FrontFunc.GetDataByClassID("9", "286", "");
        foreach (DataRow dr in dt_news.Rows)
        {
            lit_news.Text += "<li><span class='right green'>" + DateTimeFunc.dateFormat(DateTime.Parse(dr["AddTime"].ToString()), 3, "-") + "</span><span class='new_icon2'></span>";
            lit_news.Text += "<a href='news_show.aspx?nid=" + dr["ID"] + "' title='" + dr["Title"] + "'>" + FrontFunc.Cutstring(dr["Title"].ToString(), 22) + "</a></li>";
        }
        #endregion

        #region 学习资料
        DataTable dt_download = FrontFunc.GetDataByClassID("9", "322,323", "");
        foreach (DataRow dr in dt_download.Rows)
        {
            lit_xxzl.Text += "<li><span class='right green'>" + DateTimeFunc.dateFormat(DateTime.Parse(dr["AddTime"].ToString()), 3, "-") + "</span><span class='new_icon2'></span>";
            lit_xxzl.Text += "<a href='xxzl_show.aspx?nid=" + dr["ID"] + "' title='" + dr["Title"] + "'>" + FrontFunc.Cutstring(dr["Title"].ToString(), 22) + "</a></li>";
        }
        #endregion

        #region 实验室列表
        DataTable dt_syslb = FrontFunc.GetClassInfoById("299,300,301,302,303,304");
        foreach (DataRow dr in dt_syslb.Rows)
        {
            lit_syslb.Text += "<dl class='clear'><dt><a href='sysq_show.aspx?nid=" + dr["ID"] + "'><img src='" + dr["ClassPicture"] + "' /></a></dt><dd>";
            lit_syslb.Text += "<h5 class='f14 bold blacks'><span class='new_icon3'></span><a href='sysq_show.aspx?nid=" + dr["ID"] + "'>" + FrontFunc.Cutstring(dr["ClassName"].ToString(), 13) + "</a></h5>";
            lit_syslb.Text += "<p class='green'>" + FrontFunc.Cutstring(dr["PageDescription"].ToString(), 90) + "<span class='more-o'><a href='sysq_show.aspx?nid=" + dr["ID"] + "'>详情>></a></span></p></dd></dl>";
        }
        #endregion

        #region 实验设备
        DataTable dt_sysb = FrontFunc.GetDataByClassID("10", "309", "");
        foreach (DataRow dr in dt_sysb.Rows)
        {
            lit_sysb.Text += "<li><a target='_blank' href='sysb_show.aspx?nid=" + dr["ID"] + "' title='" + dr["Title"] + "'><img width='135' height='87' alt='' src='" + dr["TitlePicture"] + "'></a>";
            lit_sysb.Text += "<p><a target='_blank' href='sysb_show.aspx?nid=" + dr["ID"] + "'>" + FrontFunc.Cutstring(dr["Title"].ToString(), 10) + "</a></p></li>";
        }
        #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, "用户名和密码不正确");
            }
        }
    }

}
