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

public partial class BackCenter_Lab_LabEdit : System.Web.UI.Page
{
    public DataRow dr;
    public string typeid;
    public string typebig;
    public string typesmall;
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 过期和权限

        PageFunc.IfLogin(this.Page);

        #endregion
        //if (IsPostBack)
        //    return;
        if (Request["lid"] != null && Request["lid"].ToString() != "")
        {
            string sql = "select l.*,m.Account,m.Name,d.Title,d.Address  from NT_Lab l,NT_Member m,NT_Data d where l.MemberId=m.ID and l.DataId=d.ID and l.ID=" + Request["lid"].ToString();
            dr = DbHelperOleDb.ExecuteDataSet(CommandType.Text, sql, null).Tables[0].Rows[0];

            if (dr["Type"].ToString() == "5")
            {
                typeid = "5";
                typebig = "参观";
            }
            else
            {
                DataRow dr2 = DbHelperOleDb.ExecuteDataSet(CommandType.Text, "select l1.ID as IdBig,l2.ID as IdSmall, l1.TypeName as TypeBig,l2.TypeName as TypeSmall from NT_LabType l1,NT_LabType l2 where l1.ID=l2.ParentId and l2.ID=" + dr["Type"], null).Tables[0].Rows[0];
                typeid = dr2["IdBig"].ToString();
                typebig = dr2["TypeBig"].ToString();
                typesmall = dr2["TypeSmall"].ToString();

            }
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (Request["lid"] != null && Request["lid"] != "")
        {
            #region 操作数据库


            StringBuilder strSql = new StringBuilder();
            strSql.Append("update NT_Lab set ");
            strSql.Append("Audit=@Audit,");
            strSql.Append("Mark2=@Mark2");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters = {
					new OleDbParameter("@Audit", OleDbType.Integer,4),
                    new OleDbParameter("@Mark2", OleDbType.VarChar),
					new OleDbParameter("@ID", OleDbType.Integer,4)};
            parameters[0].Value = int.Parse(ddl_Audit.SelectedValue);
            parameters[1].Value = txt_Mark2.Text.Trim();
            parameters[2].Value = Request["lid"];
            //执行语句
            DbHelperOleDb.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters);


            #endregion

            JavaScriptFunc.AlertAndRedirect(this.Page, "审核完成", "LabIndex.aspx");
        }
    }
}
