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 xxzl_show : System.Web.UI.Page
{
    public DataRow dr;

    protected void Page_Load(object sender, EventArgs e)
    {
        #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

        if (Request.QueryString["nid"] != null && Request.QueryString["nid"].ToString() != "")
        {
            dr = FrontFunc.GetDataByID(Request.QueryString["nid"].ToString());

            
            #region 上一篇
            DataTable dt_new = FrontFunc.GetPreID(Request.QueryString["nid"].ToString());
            if (dt_new != null && dt_new.Rows.Count > 0)
            {
                foreach (DataRow dr1 in dt_new.Rows)
                {
                    lit_news.Text += "上一条：<a href='xxzl_show?nid=" + dr1["ID"] + "'>" + dr1["Title"] + "</a><br/>";
                }
            }
            else
            {
                lit_news.Text += "上一条：没有了<br/>";
            }
            #endregion

            #region 下一篇
            DataTable dt_new2 = FrontFunc.GetNextID(Request.QueryString["nid"].ToString());
            if (dt_new2 != null && dt_new2.Rows.Count > 0)
            {
                foreach (DataRow dr2 in dt_new2.Rows)
                {
                    lit_news.Text += "下一条：<a href='xxzl_show?nid=" + dr2["ID"] + "'>" + dr2["Title"] + "</a><br/>";
                }
            }
            else
            {
                lit_news.Text += "下一条：没有了<br/>";
            }

            #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, "用户名和密码不正确");
            }
        }
    }

}
