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 xabaraCOM;

public partial class webXabara_study_Default : System.Web.UI.Page
{
    sqlServer sql = new sqlServer();
    classify c = new classify();
    webPublic wp = new webPublic();
    admin a = new admin();
    fileDocument f = new fileDocument();
    javasrcipt js = new javasrcipt();
    email mail = new email();

    protected void Page_Load(object sender, EventArgs e)
    {
        a.check("|study|");

        long pidTemp = xabara.isNum(Request.QueryString["pid"]);   //省份
        long cityIDTemp = xabara.isNum(Request.QueryString["cityID"]);   //市级
        long aIDTemp = xabara.isNum(Request.QueryString["aID"]);   //县区级
        /*if (pidTemp < 1)
        {
            string pathFlie = HttpContext.Current.Server.MapPath("/xabara.config");
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(pathFlie);

            pidTemp = xabara.isNum(xmlDoc.DocumentElement.SelectSingleNode("//add[@key='province']").Attributes["value"].Value);
            cityIDTemp = xabara.isNum(xmlDoc.DocumentElement.SelectSingleNode("//add[@key='city']").Attributes["value"].Value);
            aIDTemp = xabara.isNum(xmlDoc.DocumentElement.SelectSingleNode("//add[@key='area']").Attributes["value"].Value);
            xmlDoc = null;

            if (pidTemp < 1)  //省市县cookies检查
            {
                if (Request.Cookies["xabaraWhere"] != null)
                {
                    pidTemp = xabara.isNum(Request.Cookies["xabaraWhere"]["p"].ToString().Trim());
                    cityIDTemp = xabara.isNum(Request.Cookies["xabaraWhere"]["c"].ToString().Trim());
                    aIDTemp = xabara.isNum(Request.Cookies["xabaraWhere"]["a"].ToString().Trim());
                }
            }
        }*/
        long c1IDTemp = xabara.isNum(Request.QueryString["c1ID"]);   //课程一级分类
        long cidTemp = xabara.isNum(Request.QueryString["cid"]);   //课程二级分类
        string sexTemp = xabara.safeSql(Server.UrlDecode(Request["sexID"])); //性别判断
        long teachTypeIDTemp = xabara.isNum(Request.QueryString["teachTypeID"]); //教员身份
        long teachStudyIDTemp = xabara.isNum(Request.QueryString["teachStudyID"]); //教员授课方式
        string keyWords = xabara.safeSql(Server.UrlDecode(Request.QueryString["keyWord"])); //搜索关键字
        string ifStr = string.Empty;
        string idALLStr = string.Empty;

        if (!IsPostBack)
        {
            DataTable dt = sql.getDataTable("select * from selectProvince order by id");
            this.ProvinceList.Items.Clear();
            this.ProvinceList.Items.Add(new ListItem("== 省份 ==", string.Empty));
            for (int p = 0; p < dt.Rows.Count; p++)
            {
                this.ProvinceList.Items.Add(new ListItem(dt.Rows[p]["provinceTxt"].ToString().Trim(), dt.Rows[p]["provinceID"].ToString().Trim()));
            }
            this.ProvinceList.DataBind();

            dt = sql.getDataTable("select * from NewsTree where TreeType='study' and TreeID=0 order by ListID ASC,Tid ASC");
            this.subject01.Items.Clear();
            this.subject01.Items.Add(new ListItem("== 家教类型 ==", string.Empty));
            for (int p = 0; p < dt.Rows.Count; p++)
            {
                this.subject01.Items.Add(new ListItem(dt.Rows[p]["TreeName"].ToString().Trim(), dt.Rows[p]["Tid"].ToString().Trim()));
            }
            this.subject01.DataBind();

            dt = sql.getDataTable("select * from NewsTree where TreeType='teachertype' order by ListID ASC,Tid ASC");
            this.teacherType.Items.Clear();
            this.teacherType.Items.Add(new ListItem("== 请选择 ==", string.Empty));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                this.teacherType.Items.Add(new ListItem(dt.Rows[i]["TreeName"].ToString().Trim(), dt.Rows[i]["Tid"].ToString().Trim()));
            }
            this.teacherType.DataBind();

            dt = sql.getDataTable("select * from NewsTree where TreeType='teacherstudy' order by ListID ASC,Tid ASC");
            this.teachStudy.Items.Clear();
            this.teachStudy.Items.Add(new ListItem("== 请选择 ==", string.Empty));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                this.teachStudy.Items.Add(new ListItem(dt.Rows[i]["TreeName"].ToString().Trim(), dt.Rows[i]["Tid"].ToString().Trim()));
            }
            this.teachStudy.DataBind();

            //===================判断开始
            if (c1IDTemp > 0)    //判断一级分类选择，二级分类没被选择
            {
                dt = sql.getDataTable("select * from NewsTree where TreeType='study' and TreeID=" + c1IDTemp.ToString() + " order by ListID ASC,Tid ASC");
                this.subject02.Items.Clear();
                this.subject02.Items.Add(new ListItem("== 家教课程 ==", string.Empty));
                for (int p = 0; p < dt.Rows.Count; p++)
                {
                    this.subject02.Items.Add(new ListItem(dt.Rows[p]["TreeName"].ToString().Trim(), dt.Rows[p]["Tid"].ToString().Trim()));
                }
                this.subject02.DataBind();

                idALLStr += "&c1ID=" + c1IDTemp.ToString();  //参数跟踪
                this.subject01.Items.FindByValue(c1IDTemp.ToString()).Selected = true;
                if (cidTemp > 0)    //子分类判断
                {
                    this.subject02.Items.FindByValue(cidTemp.ToString()).Selected = true;
                    idALLStr += "&cid=" + cidTemp.ToString();   //参数跟踪
                }
                else
                {
                    idALLStr += "&cid=0";   //参数跟踪
                }
            }

            if (c1IDTemp > 0 && cidTemp < 1)    //1级2级分类判断
            {
                cidTemp = c1IDTemp;
            }

            if (cidTemp > 0)
            {
                string cidStr = c.ReadAllClassID("study", cidTemp); //得到所有ID
                if (cidStr.IndexOf(",") > 0)
                {
                    string[] ids = cidStr.Split(new char[] { ',' });
                    for (int i = 0; i <= ids.GetUpperBound(0); i++)
                    {
                        ifStr += "teacherInfo.teachTypeID like '%|" + ids[i].ToString().Trim() + "|%' or ";
                    }
                    ifStr = " and (" + ifStr.Substring(0, ifStr.Length - 3) + ")";
                }
                else
                {
                    ifStr += " and teacherInfo.teachTypeID like '%|" + cidTemp.ToString().Trim() + "|%' ";
                }
            }

            if (pidTemp > 0)
            {
                ifStr += " and teacherInfo.provinceID=" + pidTemp.ToString();
                idALLStr += "&pID=" + pidTemp.ToString();  //参数跟踪
                this.ProvinceList.Items.FindByValue(pidTemp.ToString()).Selected = true;

                dt = sql.getDataTable("select * from selectCity where cFather=" + pidTemp.ToString() + " order by id");
                this.CityList.Items.Clear();
                this.CityList.Items.Add(new ListItem("== 地级市 ==", ""));
                for (int p = 0; p < dt.Rows.Count; p++)
                {
                    this.CityList.Items.Add(new ListItem(dt.Rows[p]["cityTxt"].ToString().Trim(), dt.Rows[p]["cityID"].ToString().Trim()));
                }
                this.CityList.DataBind();
                this.areaList.Items.Clear();
                this.areaList.Items.Add(new ListItem("== 县级市 ==", ""));
            }

            if (cityIDTemp > 0)
            {
                ifStr += " and teacherInfo.cityID=" + cityIDTemp.ToString();
                idALLStr += "&cityID=" + cityIDTemp.ToString();  //参数跟踪
                this.CityList.Items.FindByValue(cityIDTemp.ToString()).Selected = true;

                dt = sql.getDataTable("select * from selectArea where aFather=" + cityIDTemp.ToString() + " order by id");
                //this.areaList.Items.Clear();
                if (dt.Rows.Count > 0)
                {
                    for (int p = 0; p < dt.Rows.Count; p++)
                    {
                        this.areaList.Items.Add(new ListItem(dt.Rows[p]["areaTxt"].ToString().Trim(), dt.Rows[p]["areaID"].ToString().Trim()));
                    }
                }
                else
                {
                    this.areaList.Items.Add(new ListItem("== 暂无 ==", ""));
                }
                this.areaList.DataBind();
            }

            if (aIDTemp > 0)
            {
                ifStr += " and teacherInfo.areaID=" + aIDTemp.ToString();
                idALLStr += "&aID=" + aIDTemp.ToString();  //参数跟踪
                this.areaList.Items.FindByValue(aIDTemp.ToString()).Selected = true;
            }

            if (!string.IsNullOrEmpty(sexTemp as string))
            {
                ifStr += " and xabaraUser.userSex='" + sexTemp + "'";
                idALLStr += "&sexID=" + Server.UrlEncode(sexTemp.ToString());  //参数跟踪
                this.sexList.Items.FindByValue(sexTemp.ToString()).Selected = true;
            }

            if (teachTypeIDTemp > 0)
            {
                ifStr += " and teacherInfo.nowWork=" + teachTypeIDTemp;
                idALLStr += "&teachTypeID=" + teachTypeIDTemp.ToString();  //参数跟踪
                this.teacherType.Items.FindByValue(teachTypeIDTemp.ToString()).Selected = true;
            }

            if (teachStudyIDTemp > 0)
            {
                ifStr += " and teacherInfo.teachStudyIDs like '%|" + teachStudyIDTemp + "|%'";
                idALLStr += "&teachStudyID=" + teachStudyIDTemp.ToString();  //参数跟踪
                this.teachStudy.Items.FindByValue(teachStudyIDTemp.ToString()).Selected = true;
            }

            if (!string.IsNullOrEmpty(keyWords as string))
            {
                ifStr += " and (xabarauser.Uid=" + wp.returnNums("t", keyWords) + " or xabarauser.userName='" + keyWords + "' or xabarauser.userTel='" + keyWords + "' or xabarauser.userMobile='" + keyWords + "')";

                searchStr.Text = keyWords;
            }

            long flagID = xabara.isNum(Request.QueryString["flagID"]);    //不通过信息
            string flagIDStr = "teacherInfo.workFlag > -1";
            if (flagID < 0)
            {
                flagIDStr = "teacherInfo.workFlag = -1";
            }
            idALLStr += "&flagID=" + flagID.ToString();   //参数跟踪
            //================判断结束

            string orderBy = " order by teacherInfo.workFlag ASC,teacherInfo.tID DESC"; //列表方式

            string strSql = "select *,XabaraUser.Uid as id,teacherInfo.postDate as p from teacherInfo left join XabaraUser on XabaraUser.userCardID = teacherInfo.uID where " + flagIDStr + ifStr + orderBy;
            //Response.Write(strSql);

            lblCurrentPage.Text = sql.RepeaterDB(sList, strSql, idALLStr, 5, "page", "center", true);
            if (this.sList.Items.Count < 1)
            {
                errInfo.Text = "目前暂没有任何信息！";
                errDiv.Visible = true;
                checkDiv.Visible = false;
            }
            else
            {
                errDiv.Visible = false;
                checkDiv.Visible = true;
            }
            dt.Dispose();

            //导出excel文档
            if (!string.IsNullOrEmpty(Request.QueryString["excel"] as string))
            {
                strSql = "select xabaraUser.userName,xabaraUser.userEmail,xabaraUser.userTel,xabaraUser.userMobile,xabaraUser.userQQ from teacherInfo left join XabaraUser on XabaraUser.userCardID = teacherInfo.uID where " + flagIDStr + ifStr + orderBy;
                //Response.Write(strSql);
                dt = sql.getDataTable(strSql);
                f.ToExecl(dt, Page, "teacher");
                dt.Dispose();
            }
        }
    }

    public string getTreeName(string str)
    {
        return c.readClassName_Link(xabara.isNum(str), string.Empty, string.Empty);
    }

    public string getPCA(string p, string cc, string a)  //得到省市区镇
    {
        return c.cityName(p, cc, a);
    }

    public string cutWords(string str, int len)
    {
        return CHAR.left(str, len);
    }

    public string cNums(string sOrt, string id)  //编号
    {
        return wp.createNums(sOrt, id);
    }

    public string getStudentInfo(string id)
    {
        return wp.infoTeachFlag(id);
    }

    public string idsName(string str)
    {
        return wp.IDsTreeName(str, ", ");
    }

    public string pay(string m, string bit)
    {
        return wp.payRead(m, bit);
    }

    public string faceImg(string str)
    {
        return f.picDisplay(str);
    }

    public string studyIDSWeek(string str)
    {
        return wp.studyIDSWeek(str);
    }

    protected void ProvinceList_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.CityList.Items.Clear();
        this.CityList.Items.Add(new ListItem("== 地级市 ==", ""));
        if (!string.IsNullOrEmpty(ProvinceList.Text as string))
        {
            DataTable dt;
            dt = sql.getDataTable("select * from selectCity where cFather=" + ProvinceList.Text.Trim() + " order by id");
            for (int p = 0; p < dt.Rows.Count; p++)
            {
                this.CityList.Items.Add(new ListItem(dt.Rows[p]["cityTxt"].ToString().Trim(), dt.Rows[p]["cityID"].ToString().Trim()));
            }
            this.CityList.DataBind();
            dt.Dispose();
        }
        this.areaList.Items.Clear();
        this.areaList.Items.Add(new ListItem("== 县级市 ==", ""));
    }

    protected void cityList_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.areaList.Items.Clear();
        this.areaList.Items.Add(new ListItem("== 县级市 ==", ""));
        if (!string.IsNullOrEmpty(CityList.Text as string))
        {
            DataTable dt;
            dt = sql.getDataTable("select * from selectArea where aFather=" + CityList.Text.Trim() + " order by id");
            if (dt.Rows.Count > 0)
            {
                for (int p = 0; p < dt.Rows.Count; p++)
                {
                    this.areaList.Items.Add(new ListItem(dt.Rows[p]["areaTxt"].ToString().Trim(), dt.Rows[p]["areaID"].ToString().Trim()));
                }
            }
            else
            {
                this.areaList.Items.Add(new ListItem("== 暂无 ==", ""));
            }
            this.areaList.DataBind();
            dt.Dispose();
        }
    }

    protected void subject01_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(subject01.Text as string))
        {
            DataTable dt;
            dt = sql.getDataTable("select * from NewsTree where TreeType='study' and TreeID=" + subject01.Text + " order by ListID ASC,Tid ASC");
            this.subject02.Items.Clear();
            this.subject02.Items.Add(new ListItem("== 家教课程 ==", string.Empty));
            for (int p = 0; p < dt.Rows.Count; p++)
            {
                this.subject02.Items.Add(new ListItem(dt.Rows[p]["TreeName"].ToString().Trim(), dt.Rows[p]["Tid"].ToString().Trim()));
            }
            this.subject02.DataBind();
            dt.Dispose();
        }
    }

    protected void batDelete_Click(object sender, EventArgs e)
    {
        string requestID = xabara.safeSql(Request["batDel"]);
        if (string.IsNullOrEmpty(requestID as string))
        {
            js.div(false, "", "text", "请选择选项后再点击不通过按钮！", 0, 0, "", "");
        }
        else
        {
            string webTitle = xml.read("xabara.config", "webName", 180);
            DataTable dt;
            string[] strValue = new string[1];
            string[] ids = requestID.Split(new char[] { ',' });
            for (int i = 0; i <= ids.GetUpperBound(0); i++)
            {
                dt = sql.getDataTable("select XabaraUser.userCardID,XabaraUser.userName,XabaraUser.userEmail from teacherInfo left join XabaraUser on teacherInfo.uID=XabaraUser.userCardID where teacherInfo.tID=" + ids[i]);
                if (dt.Rows.Count > 0)
                {
                    strValue[0] = "-1"; //不通过

                    string txt = CHAR.htmSafe(txtInfo.Text.Trim());
                    if (!string.IsNullOrEmpty(txt as string))
                    {
                        txt = "<br />　　原因如下：" + txt;
                    }

                    string bodyHtml = @"
<table width='100%' border='0' cellpadding='3' cellspacing='3'>
  <tr>
    <td>亲爱的 <strong>" + dt.Rows[0]["userName"].ToString().Trim() + @"</strong> ：您好！</td>
  </tr>
  <tr>
    <td>　　很遗憾，您在" + webTitle + @"的家教信息没被审核通过，同时感谢您对" + webTitle + @"的关注与支持并欢迎您使用" + webTitle + @"的产品与服务。请进入管理平台重新修改并点击 " + @"<a href='http://" + Request.Url.Host + "/member/teacher/?id=" + ids[i] + @"' target='_blank'>http://" + Request.Url.Host + "/member/teacher/?id=" + ids[i] + @"</a>，修改时填写个人真实的信息，不要包含任何特殊字符、敏感词语、网址以及联系电话等宣传性的内容！" + @txt + @"</td>
  </tr>  
</table>
";
                    mail.add(dt.Rows[0]["userCardID"].ToString().Trim(), "user", 2, dt.Rows[0]["userEmail"].ToString().Trim(), "审核通知", "您的教员信息没被审核通过！", bodyHtml, true);

                    sql.update("teacherInfo", "@workFlag", strValue, "tID=" + ids[i]);
                    sql.log(a.uid, "admin", ids[i] + " 教员审核");
                }
                dt.Dispose();
            }

            Response.Redirect("default.aspx?page=" + xabara.isNum(Request["Page"]).ToString(), true);
        }
    }

    protected void batOK_Click(object sender, EventArgs e)
    {
        string requestID = xabara.safeSql(Request["batDel"]);
        if (string.IsNullOrEmpty(requestID as string))
        {
            js.div(false, "", "text", "请选择选项后再点击不通过按钮！", 350, 150, "", "");
        }
        else
        {
            string webTitle = xml.read("xabara.config", "webName", 180);
            DataTable dt;
            string[] strValue = new string[1];
            string[] ids = requestID.Split(new char[] { ',' });
            for (int i = 0; i <= ids.GetUpperBound(0); i++)
            {
                dt = sql.getDataTable("select XabaraUser.userCardID,XabaraUser.userName,XabaraUser.userEmail from teacherInfo left join XabaraUser on teacherInfo.uID=XabaraUser.userCardID where teacherInfo.tID=" + ids[i]);
                if (dt.Rows.Count > 0)
                {
                    strValue[0] = "1";  //通过

                    string bodyHtml = @"
<table width='100%' border='0' cellpadding='3' cellspacing='3'> 
  <tr>
    <td>亲爱的 <strong>" + dt.Rows[0]["userName"].ToString().Trim() + @"</strong> ：您好！</td>
  </tr>
  <tr>
    <td>　　恭喜您在" + webTitle + @"的家教信息被审核通过，同时感谢您对" + webTitle + @"的关注与支持并欢迎您使用" + webTitle + @"的产品与服务。<br />　　您被审核通过的信息请点击 " + @"<a href='http://" + Request.Url.Host + "/teacher/view/" + ids[i] + @".htm' target='_blank'>http://" + Request.Url.Host + "/teacher/view/" + ids[i] + @".htm</a>" + @"</td>
  </tr>  
</table>
";
                    mail.add(dt.Rows[0]["userCardID"].ToString().Trim(), "user", 2, dt.Rows[0]["userEmail"].ToString().Trim(), "审核通知", "您的家教信息已被审核通过！", bodyHtml, true);

                    sql.update("teacherInfo", "@workFlag", strValue, "tID=" + ids[i]);
                    sql.log(a.uid, "admin", ids[i] + " 教员审核");
                }
                dt.Dispose();
            }

            Response.Redirect("default.aspx?page=" + xabara.isNum(Request["Page"]).ToString(), true);
        }
    }

    protected void batOrder_Click(object sender, EventArgs e)
    {
        string requestID = xabara.safeSql(Request["batDel"]);
        if (string.IsNullOrEmpty(requestID as string))
        {
            js.div(false, "", "text", "请选择选项后再点击双方沟通按钮！", 0, 0, "", "");
        }
        else
        {
            DataTable dt;
            string[] strValue = new string[1];
            string[] ids = requestID.Split(new char[] { ',' });
            for (int i = 0; i <= ids.GetUpperBound(0); i++)
            {
                dt = sql.getDataTable("select XabaraUser.userName,XabaraUser.userEmail from teacherInfo left join XabaraUser on teacherInfo.uID=XabaraUser.userCardID where teacherInfo.tID=" + ids[i]);
                if (dt.Rows.Count > 0)
                {
                    strValue[0] = "2";  //预约或沟通                   
                    sql.update("teacherInfo", "@workFlag", strValue, "tID=" + ids[i]);
                    sql.log(a.uid, "admin", ids[i] + " 教员沟通期");
                }
                dt.Dispose();
            }

            Response.Redirect("default.aspx?page=" + xabara.isNum(Request["Page"]).ToString(), true);
        }
    }

    protected void okOrder_Click(object sender, EventArgs e)
    {
        string requestID = xabara.safeSql(Request["batDel"]);
        if (string.IsNullOrEmpty(requestID as string))
        {
            js.div(false, "", "text", "请选择选项后再点击 已预约 按钮！", 350, 150, "", "");
        }
        else
        {
            DataTable dt;
            string[] strValue = new string[1];
            string[] ids = requestID.Split(new char[] { ',' });
            for (int i = 0; i <= ids.GetUpperBound(0); i++)
            {
                dt = sql.getDataTable("select XabaraUser.userName,XabaraUser.userEmail from teacherInfo left join XabaraUser on teacherInfo.uID=XabaraUser.userCardID where teacherInfo.tID=" + ids[i]);
                if (dt.Rows.Count > 0)
                {
                    strValue[0] = "3";  //已预约                  
                    sql.update("teacherInfo", "@workFlag", strValue, "tID=" + ids[i]);
                    sql.log(a.uid, "admin", ids[i] + " 教员被预约");
                }
                dt.Dispose();
            }

            Response.Redirect("default.aspx?page=" + xabara.isNum(Request["Page"]).ToString(), true);
        }
    }

    protected void searchButton_Click(object sender, EventArgs e)
    {
        Response.Redirect("?pID=" + ProvinceList.Text + "&cityID=" + CityList.Text + "&aID=" + areaList.Text + "&c1ID=" + subject01.Text + "&cID=" + subject02.Text + "&sexID=" + Server.UrlEncode(sexList.Text) + "&teachTypeID=" + teacherType.Text + "&teachStudyID=" + teachStudy.Text + "&keyWord=" + Server.UrlEncode(searchStr.Text.Trim()), true);
    }

    protected void setTop_Click(object sender, EventArgs e)
    {
        string requestID = xabara.safeSql(Request["batDel"]);
        if (string.IsNullOrEmpty(requestID as string))
        {
            js.div(false, "", "text", "请选择选项后再点击推荐教员按钮！", 350, 150, "", "");
        }
        else
        {
            DataTable dt;
            string[] strValue = new string[1];
            string[] ids = requestID.Split(new char[] { ',' });
            for (int i = 0; i <= ids.GetUpperBound(0); i++)
            {
                dt = sql.getDataTable("select XabaraUser.userName,XabaraUser.userEmail from teacherInfo left join XabaraUser on teacherInfo.uID=XabaraUser.userCardID where teacherInfo.tID=" + ids[i]);
                if (dt.Rows.Count > 0)
                {
                    strValue[0] = DateTime.Now.AddYears(1).ToString("yyyy-MM-dd HH:mm:ss");  //推荐时间为当前时间              
                    sql.update("teacherInfo", "@adBeginDate", strValue, "tID=" + ids[i]);
                    sql.log(a.uid, "admin", "推荐教员：" + ids[i]);
                }
                dt.Dispose();
            }

            Response.Redirect("default.aspx?page=" + xabara.isNum(Request["Page"]).ToString(), true);
        }
    }

    protected void cancelTop_Click(object sender, EventArgs e)
    {
        string requestID = xabara.safeSql(Request["batDel"]);
        if (string.IsNullOrEmpty(requestID as string))
        {
            js.div(false, "", "text", "请选择选项后再点击推荐教员按钮！", 350, 150, "", "");
        }
        else
        {
            DataTable dt;
            string[] strValue = new string[1];
            string[] ids = requestID.Split(new char[] { ',' });
            for (int i = 0; i <= ids.GetUpperBound(0); i++)
            {
                dt = sql.getDataTable("select XabaraUser.userName,XabaraUser.userEmail from teacherInfo left join XabaraUser on teacherInfo.uID=XabaraUser.userCardID where teacherInfo.tID=" + ids[i]);
                if (dt.Rows.Count > 0)
                {
                    strValue[0] = DateTime.Now.AddYears(-1).ToString("yyyy-MM-dd HH:mm:ss");  //推荐时间为当前时间              
                    sql.update("teacherInfo", "@adBeginDate", strValue, "tID=" + ids[i]);
                    sql.log(a.uid, "admin", "取消推荐教员：" + ids[i]);
                }
                dt.Dispose();
            }

            Response.Redirect("default.aspx?page=" + xabara.isNum(Request["Page"]).ToString(), true);
        }
    }

    protected void excel_Click(object sender, EventArgs e)
    {
        Response.Redirect("?excel=ok&pID=" + ProvinceList.Text + "&cityID=" + CityList.Text + "&aID=" + areaList.Text + "&c1ID=" + subject01.Text + "&cID=" + subject02.Text + "&sexID=" + Server.UrlEncode(sexList.Text) + "&teachTypeID=" + teacherType.Text + "&teachStudyID=" + teachStudy.Text + "&keyWord=" + Server.UrlEncode(searchStr.Text.Trim()), true);
    }

    public string age(string birthday)
    {
        string age = "0";

        int y = 0;
        try
        {
            y = Convert.ToDateTime(birthday).Year;
        }
        catch { }

        age = (DateTime.Now.Year - y).ToString();

        return age;
    }
}