<%@ 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"><%=GetString("D0087") %></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"><%=GetString("D0088") %></label>
                        <div class="col-md-8">
                            <input type="password" name="edtUserOldPwd"  class="form-control" placeholder=<%=GetQuoteString("D0088") %>/>
                        </div>
                    </div>
                    <div class="row" style="padding:10px;">
                        <label class="control-label col-md-2"><%=GetString("D0089") %></label>
                        <div class="col-md-8">
                           <input type="password" name="edtUserPwd1" class="form-control" placeholder=<%=GetQuoteString("D0089") %>/>
                        </div>
                    </div>
                       <div class="row" style="padding:10px;">
                        <label class="control-label col-md-2"><%=GetString("D0090") %></label>
                        <div class="col-md-8">
                           <input type="password" name="edtUserPwd2"  class="form-control" placeholder=<%=GetQuoteString("D0089") %>/>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><%=GetString("B0025") %></button>
                    <button type="button" id="btn_changepwdsave" class="btn btn-primary"><%=GetString("B0026") %></button>

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

   	<div class="row-fluid">
		<div class="span12">
			<div class="page-header">
				<h1>
					<%=GetString("D0002") %>: <small><%=UserName %></small>
				</h1>

                <h1>
					 <button type="button" id="btn_changepwd" class="w-100 btn btn-lg btn-secondary"><%=GetString("B0045") %></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(<%=GetQuoteString("D0091") %>);
                return;
            }

            if (userpwd1.length<5){
                toastr.error(<%=GetQuoteString("D0092") %>);
                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(<%=GetQuoteString("D0093") %>);
                        }
                        else {
                            toastr.error(<%=GetQuoteString("D0094") %>);
                        }
                    }
                },
                error: function () {
                    toastr.error(<%=GetQuoteString("D0094") %>);
                },
                complete: function () {

                }

            });

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

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