<%@ Control Language="C#" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.BLL" %>
<%@ Import Namespace="Kesion.Config" %>
<%@ Import Namespace="Kesion.Components" %>
<%@ Import Namespace="Kesion.HtmlTags" %>
<%@ Import Namespace="Kesion.UCenter" %>
<%@ Import Namespace="Kesion.XML" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Xml" %>
<script runat="server" type="text/C#">

    dynamic __user = HttpContext.Current.Items["user"];                //初始化用户信息
    bool isLoadPage = true;  //定义页面是否加载

    protected void Page_Load(object sender, EventArgs e)
    {
        if (KSCMS.S("action") == "dosave")
        {
            isLoadPage = false;
            DoSave();
            return;
        }
    }

    private void DoSave()
    {
        #region 保存


        string ValidateCode =KSCMS.S("VerifyCode");
		
		if (!Utils.IsValidVerifyCode(ValidateCode))
         {
            Msg.Alert("验证码错误！");
            return;
         }
		
        string question = Utils.RemoveXss(KSCMS.S("question"));
        string answer = Utils.RemoveXss(KSCMS.S("answer"));
        if (string.IsNullOrEmpty(question))
        {
            Msg.Alert("请输入问题！");
            return;

        }
        if (string.IsNullOrEmpty(answer))
        {
            Msg.Alert("请输入问题答案！");
            return;

        }
         string salt = __user.Salt;
        string password = string.Empty;
        if (!string.IsNullOrEmpty(salt))
        {
            password = Utils.MD5(KSCMS.S("PassWord")+salt, 32);
        }else
        {
            password =Utils.MD5(KSCMS.S("PassWord"), 16);
        }


        if (DataFactoryUser.Exists("KS_User","userid="+__user.UserID + " and password='" + password + "'")==false)
        {
            Msg.Alert("输入的登录密码不正确！");
            return;
        }
        else
        {
            UserManage.UpdateSafe(__user.UserName, question, answer);
            UserManage.CleanUserCache(__user.UserID);
            Msg.Alert("恭喜，修改成功！", KSCMS.GetComeUrl());
        }
        #endregion
    }
</script>

<%
    if (!isLoadPage) return;
%>

<script>
    function checkform() {
        if ($("#PassWord").val() == '') {
            KesionJS.Alert('请输入您的登录密码！', "$('#PassWord').focus()");
            return false;
        }
        if ($("#Question").val() == '') {
            KesionJS.Alert('请输入您的提示问题！', "$('#Question').focus()");
            return false;
        }
        if ($("#Answer").val() == '') {
            KesionJS.Alert('请输入您的问题答案！', "$('#Answer').focus()");
            return false;
        }
        if ($("#VerifyCode").val() == '') {
            KesionJS.Alert('请输入验证码！', "$('#VerifyCode').focus()");
            return false;
        }
        return true;
    }
</script>
<div class="t_tybox nomar">
    <div class="r_title tytitle pd0">
        <h4 class="float-none">修改找回密码设置</h4>
        <div class="tabs">	
              <ul class="clearfix">
                    <%if (__user.GroupID==4) { %>
                    <li><a href="<%=BasicField.GetUserUrl("teacher/teacher") %>">我的资料</a></li>
                    <%}
                      else if (__user.GroupID == 3){ %>
                    <li><a href="<%=BasicField.GetUserUrl("School/UserEnterprise") %>">基本资料</a></li>
                    <%}else { %>
                     <li><a href="<%=BasicField.GetUserUrl("basic/editinfo") %>">修改我的资料</a></li>
                     <%} %>
                    <li><a href="<%=BasicField.GetUserUrl("basic/userface") %>">上传头像</a></li>
                    <li><a href="<%=BasicField.GetUserUrl("basic/editpass") %>">修改密码</a></li>
                    <% if (__user.GroupID==3) {%>
                    <li ><a href="<%=BasicField.GetUserUrl("school/userepintroduce") %>">机构介绍</a></li>
                    <li ><a href="<%=BasicField.GetUserUrl("school/userepbank") %>">银行账户</a></li>
                    <% } 
                    %>
                    <li class='puton'><a href="<%=BasicField.GetUserUrl("basic/editquestion") %>">修改安全问题</a></li>
                    <li><a href="<%=BasicField.GetUserUrl("basic/mobilebind") %>">第三方绑定</a></li>
                    <li><a href="<%=BasicField.GetUserUrl("Shop/MyAddress") %>">收货人地址</a></li>
                   
              </ul>
        </div>
    </div>
      <iframe src="about:blank" name="hidframe" style="display:none;width:0px;height:0px"></iframe>
      <form name="myform" action="{$GetCurrUrl}" method="post" id="myform" target="hidframe">
      <input type="hidden" name="action" value="dosave"/>
        <table  cellspacing="0" cellpadding="0" class="border" width="100%" align="center" border="0">

                              <tr class="tdbg">
                                <td class="lefttd w120">登录密码：</td>
                                <td style="text-align:left"><input type="password" class="textbox" name="PassWord" id="PassWord" maxlength="50"> <span style="color: red">*</span><span class="tips">
                                    您的登录密码，必须正确填写。</span></td>
                              </tr>
                              <tr class="tdbg">
                                <td class="lefttd w120">提示问题：</td>
                                <td style="text-align:left"><input type="text" class="textbox" name="Question" id="Question" value="<%=__user.Question %>" maxlength="150"> <span style="color: red">*</span><span class="tips">
                                    当密码忘记时，取回密码的提示问题。</span>
                               </td>
                              </tr>
                              <tr class="tdbg">
                                <td class="lefttd w120">问题答案：</td>
                                <td style="text-align:left"><input type="text" class="textbox" name="Answer" id="Answer" value="<%=__user.Answer %>" maxlength="150"> <span style="color: red">*</span><span class="tips"> 当密码忘记时，取回密码提示问题的答案。</span>
                                </td>
                              </tr>
                              <tr class="tdbg">
                                <td class="lefttd w120">验 证 码：</td>
                                <td style="text-align:left">
                                  	<input type="text" class="textbox" name="VerifyCode" id="VerifyCode" maxlength="50">
                              		<span style="color: red">*  </span>
                                    <img src="/plus/ValidateCode.aspx" onclick="this.src=this.src+'?'+Math.random()" style="vertical-align: middle;"/>
    
                                </td>
                              </tr>                               
                </table>
         
        
        <div class="cz_btn ">
            <div class="d-inline-block">
                <span><input type="submit" onclick="return(checkform());" ID="Button1" class="green-bt bt-w-auto button"  value="OK!确定修改" /></span>
                <span><input type="reset" class="grey-bt button" value=" 重 置 " /></span>
            </div>
        </div>
          </form>
        <div class="clear"></div>
  </div>  