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 zxcg : System.Web.UI.Page
{
    public string strTitle = "中心成果";

    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 1=1 ";
        if (Request.QueryString["nid"] != null && Request.QueryString["nid"].ToString() != "")
        {
            sql += " and CreateClassId=" + Request.QueryString["nid"].ToString();
        }
        else
        {
            sql += "and CreateClassId=345";
        }
        sql += " order by ID asc";

        DataTable dt = DbHelperOleDb.ExecuteDataSet(CommandType.Text, sql, null).Tables[0];
        foreach (DataRow dr in dt.Rows)
        {
            strTitle = dr["ClassName"].ToString();
            strtemp += "<dl class='sys clear'>";
            strtemp += "<dd><div class='f16 bold'>" + dr["ClassName"] + "</div>";

            if (Request.QueryString["nid"].ToString() == "347")
            {
                if (dr["ClassName"].ToString() == "科研论文")
                {
                    if (dr["FilePath"].ToString() != "" && dr["FilePath"] != null)
                    {
                        strtemp += "<p>" + FrontFunc.Cutstring(dr["PageDescription"].ToString(), 170) + "<input class='more_input' onclick=\"window.location.href='" + dr["FilePath"] + "'\" type='button' name='button' id='button' value='查看详情'></p>";
                    }
                    else
                    {
                        strtemp += "<p>" + FrontFunc.Cutstring(dr["PageDescription"].ToString(), 170) + "<input class='more_input' onclick=\"window.location.href='sysq_show.aspx?nid=" + dr["ID"] + "'\" type='button' name='button' id='button' value='查看详情'></p>";
                    }
                }
                else
                {
                    strtemp += "<p>" + FrontFunc.Cutstring(dr["PageDescription"].ToString(), 170) + "<input class='more_input' onclick=\"window.location.href='sysq_show.aspx?nid=" + dr["ID"] + "'\" type='button' name='button' id='button' value='查看详情'></p>";

                    string sql1 = "select * from NT_Class where CreateClassId=" + dr["ID"];
                    DataTable dt1 = DbHelperOleDb.ExecuteDataSet(CommandType.Text, sql1, null).Tables[0];
                    if (dt1 != null && dt1.Rows.Count > 0)
                    {
                        foreach (DataRow dr1 in dt1.Rows)
                        {
                            strtemp += "<div class='sysfl'><h5 class='sysfl-top'>" + dr1["ClassName"] + "<span style='float:right'><a href='zxcg_list.aspx?nid=" + dr1["ID"] + "'>更多</a></span></h5><div class='cen blacks'><div class='clear'>";

                            if (Request.QueryString["nid"].ToString() == "347")
                            {
                                if (dr1["ClassName"].ToString() == "科研论文")
                                {
                                    if (dr1["FilePath"].ToString() != "" && dr1["FilePath"] != null)
                                    {
                                        strtemp += "<a href='" + dr1["FilePath"] + "'>" + dr1["Title"] + "</a>";
                                    }
                                    else
                                    {
                                        strtemp += "<a href='zxcg_show.aspx?nid=" + dr1["ID"] + "'>" + dr1["Title"] + "</a>";
                                    }
                                }
                                else
                                {
                                    DataTable dt_syslb = FrontFunc.GetDataByClassID("6", dr1["ID"].ToString(), "");
                                    foreach (DataRow drr in dt_syslb.Rows)
                                    {
                                        if (drr["IsTop"].ToString() == "是")
                                        {
                                            strtemp += "<a href='" + drr["FilePath"] + "'>" + drr["Title"] + "</a>";
                                        }
                                        else
                                        {
                                            strtemp += "<a href='zxcg_show.aspx?nid=" + drr["ID"] + "'>" + drr["Title"] + "</a>";
                                        }
                                    }
                                }
                            }
                            else
                            {
                                DataTable dt_syslb = FrontFunc.GetDataByClassID("6", dr1["ID"].ToString(), "");
                                foreach (DataRow drr in dt_syslb.Rows)
                                {
                                    if (drr["IsTop"].ToString() == "是")
                                    {
                                        strtemp += "<a href='" + drr["FilePath"] + "'>" + drr["Title"] + "</a>";
                                    }
                                    else
                                    {
                                        strtemp += "<a href='zxcg_show.aspx?nid=" + drr["ID"] + "'>" + drr["Title"] + "</a>";
                                    }
                                }
                            }
                            strtemp += "</div></div></div>";
                        }
                    }
                    else
                    {
                        strtemp += "<div class='sysfl'><h5 class='sysfl-top'>" + dr["ClassName"] + "<span style='float:right'><a href='zxcg_list.aspx?nid=" + dr["ID"] + "'>更多</a></span></h5><div class='cen blacks'><div class='clear'>";
                        if (Request.QueryString["nid"].ToString() == "347")
                        {
                            if (dr["ClassName"].ToString() == "科研论文")
                            {
                                if (dr["FilePath"].ToString() != "" && dr["FilePath"] != null)
                                {
                                    strtemp += "<a href='" + dr["FilePath"] + "'>" + dr["Title"] + "</a>";
                                }
                                else
                                {
                                    strtemp += "<a href='zxcg_show.aspx?nid=" + dr["ID"] + "'>" + dr["Title"] + "</a>";
                                }
                            }
                            else
                            {
                                DataTable dt_syslb = FrontFunc.GetDataByClassID("6", dr["ID"].ToString(), "");
                                foreach (DataRow drr in dt_syslb.Rows)
                                {

                                    if (drr["IsTop"].ToString() == "是")
                                    {
                                        strtemp += "<a href='" + drr["FilePath"] + "'>" + drr["Title"] + "</a>";
                                    }
                                    else
                                    {
                                        strtemp += "<a href='zxcg_show.aspx?nid=" + drr["ID"] + "'>" + drr["Title"] + "</a>";
                                    }
                                }
                            }
                        }
                        else
                        {
                            DataTable dt_syslb = FrontFunc.GetDataByClassID("6", dr["ID"].ToString(), "");
                            foreach (DataRow drr in dt_syslb.Rows)
                            {

                                if (drr["IsTop"].ToString() == "是")
                                {
                                    strtemp += "<a href='" + drr["FilePath"] + "'>" + drr["Title"] + "</a>";
                                }
                                else
                                {
                                    strtemp += "<a href='zxcg_show.aspx?nid=" + drr["ID"] + "'>" + drr["Title"] + "</a>";
                                }
                            }
                        }
                        strtemp += "</div></div></div>";
                    }
                }
            }
            else
            {
                strtemp += "<p>" + FrontFunc.Cutstring(dr["PageDescription"].ToString(), 170) + "<input class='more_input' onclick=\"window.location.href='sysq_show.aspx?nid=" + dr["ID"] + "'\" type='button' name='button' id='button' value='查看详情'></p>";

                string sql1 = "select * from NT_Class where CreateClassId=" + dr["ID"];
                DataTable dt1 = DbHelperOleDb.ExecuteDataSet(CommandType.Text, sql1, null).Tables[0];
                if (dt1 != null && dt1.Rows.Count > 0)
                {
                    foreach (DataRow dr1 in dt1.Rows)
                    {
                        strtemp += "<div class='sysfl'><h5 class='sysfl-top'>" + dr1["ClassName"] + "<span style='float:right'><a href='zxcg_list.aspx?nid=" + dr1["ID"] + "'>更多</a></span></h5><div class='cen blacks'><div class='clear'>";

                        if (Request.QueryString["nid"].ToString() == "347")
                        {
                            if (dr1["ClassName"].ToString() == "科研论文")
                            {
                                if (dr1["FilePath"].ToString() != "" && dr1["FilePath"] != null)
                                {
                                    strtemp += "<a href='" + dr1["FilePath"] + "'>" + dr1["Title"] + "</a>";
                                }
                                else
                                {
                                    strtemp += "<a href='zxcg_show.aspx?nid=" + dr1["ID"] + "'>" + dr1["Title"] + "</a>";
                                }
                            }
                            else
                            {
                                DataTable dt_syslb = FrontFunc.GetDataByClassID("6", dr1["ID"].ToString(), "");
                                foreach (DataRow drr in dt_syslb.Rows)
                                {
                                    if (drr["IsTop"].ToString() == "是")
                                    {
                                        strtemp += "<a href='" + drr["FilePath"] + "'>" + drr["Title"] + "</a>";
                                    }
                                    else
                                    {
                                        strtemp += "<a href='zxcg_show.aspx?nid=" + drr["ID"] + "'>" + drr["Title"] + "</a>";
                                    }
                                }
                            }
                        }
                        else
                        {
                            DataTable dt_syslb = FrontFunc.GetDataByClassID("6", dr1["ID"].ToString(), "");
                            foreach (DataRow drr in dt_syslb.Rows)
                            {
                                if (drr["IsTop"].ToString() == "是")
                                {
                                    strtemp += "<a href='" + drr["FilePath"] + "'>" + drr["Title"] + "</a>";
                                }
                                else
                                {
                                    strtemp += "<a href='zxcg_show.aspx?nid=" + drr["ID"] + "'>" + drr["Title"] + "</a>";
                                }
                            }
                        }
                        strtemp += "</div></div></div>";
                    }
                }
                else
                {
                    strtemp += "<div class='sysfl'><h5 class='sysfl-top'>" + dr["ClassName"] + "<span style='float:right'><a href='zxcg_list.aspx?nid=" + dr["ID"] + "'>更多</a></span></h5><div class='cen blacks'><div class='clear'>";
                    if (Request.QueryString["nid"].ToString() == "347")
                    {
                        if (dr["ClassName"].ToString() == "科研论文")
                        {
                            if (dr["FilePath"].ToString() != "" && dr["FilePath"] != null)
                            {
                                strtemp += "<a href='" + dr["FilePath"] + "'>" + dr["Title"] + "</a>";
                            }
                            else
                            {
                                strtemp += "<a href='zxcg_show.aspx?nid=" + dr["ID"] + "'>" + dr["Title"] + "</a>";
                            }
                        }
                        else
                        {
                            DataTable dt_syslb = FrontFunc.GetDataByClassID("6", dr["ID"].ToString(), "");
                            foreach (DataRow drr in dt_syslb.Rows)
                            {

                                if (drr["IsTop"].ToString() == "是")
                                {
                                    strtemp += "<a href='" + drr["FilePath"] + "'>" + drr["Title"] + "</a>";
                                }
                                else
                                {
                                    strtemp += "<a href='zxcg_show.aspx?nid=" + drr["ID"] + "'>" + drr["Title"] + "</a>";
                                }
                            }
                        }
                    }
                    else
                    {
                        DataTable dt_syslb = FrontFunc.GetDataByClassID("6", dr["ID"].ToString(), "");
                        foreach (DataRow drr in dt_syslb.Rows)
                        {

                            if (drr["IsTop"].ToString() == "是")
                            {
                                strtemp += "<a href='" + drr["FilePath"] + "'>" + drr["Title"] + "</a>";
                            }
                            else
                            {
                                strtemp += "<a href='zxcg_show.aspx?nid=" + drr["ID"] + "'>" + drr["Title"] + "</a>";
                            }
                        }
                    }
                    strtemp += "</div></div></div>";
                }
            }

            strtemp += "</dd></dl>";
        }
        lit_syslb.Text = strtemp;

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

}
