<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MyMsg.aspx.cs" Inherits="SmartLogonServer.MyMsg" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
<script src="Content/jquery-1.9.1.min.js"></script>
<link href="Bootstrap/css/bootstrap.min.css" rel="stylesheet"/> 
    <link href="Content/toastr/toastr.min.css"  rel="stylesheet" />
<script src="Bootstrap/js/bootstrap.min.js"></script>
       <script src="Content/toastr/toastr.min.js"></script>
        <script src="Content/sweetalert/sweetalert.min.js"></script>
</head>
<body>

    <div class="modal fade" id="myModalChangepwd" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLiveLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="staticBackdropLiveLabel">修改密码</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
                    <div class="row" style="padding:10px;">
                        <label class="control-label col-md-2">原密码</label>
                        <div class="col-md-8">
                            <input type="password" name="edtUserOldPwd"  class="form-control" placeholder="旧密码"/>
                        </div>
                    </div>
                    <div class="row" style="padding:10px;">
                        <label class="control-label col-md-2">新密码</label>
                        <div class="col-md-8">
                           <input type="password" name="edtUserPwd1" class="form-control" placeholder="新密码"/>
                        </div>
                    </div>
                       <div class="row" style="padding:10px;">
                        <label class="control-label col-md-2">重复新密码</label>
                        <div class="col-md-8">
                           <input type="password" name="edtUserPwd2"  class="form-control" placeholder="新密码"/>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
                    <button type="button" id="btn_changepwdsave" class="btn btn-primary">确认</button>

                </div>
                
            </div>
        </div>
    </div>  

   	<div class="row-fluid">
		<div class="span12">
			<div class="page-header">
				<h1>
					用&nbsp;户&nbsp;名: <small><%=UserName %></small>
				</h1>
				<h1>
					邮&nbsp;&nbsp;&nbsp;&nbsp;&nbsp 箱: <small><%=UserMail %></small>
				</h1>
				<h1>
					电&nbsp;&nbsp;&nbsp;&nbsp;&nbsp 话: <small><%=UserPhone %></small>
				</h1>
				<h1>
					组&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 号: <small><%=GroupName %></small>
				</h1>
				<h1>
					注册日期: <small><%=RegDate %></small>
				</h1>
				<h1>
					有效日期: <small><%=ValidDate %></small>
				</h1>
                <h1>
					 <button type="button" id="btn_changepwd" class="w-100 btn btn-lg btn-secondary">修改密码</button>
				</h1>
			</div>
		</div>
	</div>

    <script type="text/javascript">
        $("#btn_changepwd").on('click', function () {
            //弹出模态框
            $("#myModalChangepwd").modal('show');
            //给弹出框里面的各个文本框赋值
            $("#myModalChangepwd input").val("");

        });

        $("#btn_changepwdsave").on('click', function () {
            //弹出模态框
            $("#myModalChangepwd").modal('hide');

            var useroldpwd = $("#myModalChangepwd input[name='edtUserOldPwd']").val().trim();
            var userpwd1 = $("#myModalChangepwd input[name='edtUserPwd1']").val().trim();
            var userpwd2 = $("#myModalChangepwd input[name='edtUserPwd2']").val().trim();


            if ((userpwd1 != userpwd2) || (userpwd1 == "")) {
                toastr.error("两次密码必须相同并且不为空!");
                return;
            }

            if (userpwd1.length<5){
                toastr.error("密码必须5到13位!");
                return;
            }

            $.ajax({
                type: "post",
                url: "changeuserpwd.ashx",
                data: {
                    useroldpwd: useroldpwd,
                    userpwd1: userpwd1

                },
                dataType: 'JSON',
                success: function (data, status) {

                    if (status == "success") {
                        if (data.result == true) {
                            toastr.success('修改密码成功');
                        }
                        else {
                            toastr.error('修改密码失败');
                        }
                    }
                },
                error: function () {
                    toastr.error('修改密码失败');
                },
                complete: function () {

                }

            });

            //给弹出框里面的各个文本框赋值
            $("#myModalRegister input").val("");

        });
        toastr.options.positionClass = 'toast-top-center';
    </script>
</body>
</html>
