<%@ Page Title="" Language="C#" MasterPageFile="~/Styles/MasterPage/MasterPage_Edit.master" AutoEventWireup="true" CodeFile="Member_Edit.aspx.cs" Inherits="System_Member_Member_Edit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <script type="text/javascript">
        function save() {
            
            var uid = $("#uid").val();
            var username = $("#username").val();
            if (username == "") {
                parent.AlertNO('请输入用户名!');
                return;
            }
            var nickname = $("#nickname").val();
            var password = $("#password").val();
            var status = $("#status").val();
            var is_admin = $("#is_admin").val();
            var action = '<%=xview["action"]%>';

            var str = "";
            var arrChk = document.getElementsByName("roles");
            for (var i = 0; i < arrChk.length; i++) {
                if (arrChk[i].checked) {
                    str += arrChk[i].value + ",";
                }
            }
            str = str.substr(0, str.length - 1);

            parent.ShowLoadingMask(); //显示遮罩
            
            $.ajax({
                type: "POST",
                contentType: "application/json",
                url: 'Member_Service.asmx/<%=xview["action"]%>',
                data: "{uid:'" + uid + "',username:'" + username + "',nickname:'" + nickname
                    + "',password:'" + password + "',status:'" + status + "',is_admin:'" + is_admin + "',role_ids:'" + str + "'}",
                dataType: 'json',
                success: function (result) {
                    parent.HideLoadingMask(); //关闭遮罩
                    var r = result.d;
                    if (r == "success") {
                        parent.AlertOK('保存成功!');
                        parent.search_grid();
                        CloseDivWin(); //关闭窗口
                    } else {
                        parent.AlertNO(r);
                    }
                }
            });
        }

        //弹出窗口_选择上级主管
        function Boss_SearchDialog() {
            var keyid = $("#boss_nickname").val();
            var url = "../../CommonControl/SearchDialog/Member_List.aspx"
            var win_style = "center:yes;resizable:no;status:no;dialogHeight:530px;dialogWidth:600px";
            var m_recipientsText = ""
            var r = window.showModalDialog(url, m_recipientsText, win_style);
            if (r != null) {
                var uid = r[0][0];
                Boss_SearchService(uid);
            }
            //Boss_SearchService(keyid);
        }
        //通过主键_获取上级主管
        function Boss_SearchService(uid) {
            $.ajax({
                type: "POST",
                contentType: "application/json",
                url: '../MemberCanDesign/Member_Service.asmx/GetMember',
                data: "{uid:'" + uid + "'}",
                dataType: 'json',
                success: function (result) {
                    $("#boss_username").attr("value",result.d.username)
                    $("#boss_nickname").attr("value", result.d.nickname)
                }
            });
        }
    </script>

    <div style="width:350px;height:350px;overflow:auto;">
	    <table style="margin:auto;">
            <tr>
                <td style="text-align:right">用户ID:</td>
                <td><input type="text" class="edit_text_box" id="uid" disabled="disabled" value="<%=xview["uid"]%>"/></td>
            </tr>
            <tr>
                <td style="text-align:right">用户名:</td>
                <td><input type="text" class="edit_text_box" id="username" value="<%=xview["username"]%>"/></td>
            </tr>
            <tr>
                <td style="text-align:right">姓名:</td>
                <td><input type="text" class="edit_text_box" id="nickname" value="<%=xview["nickname"]%>"/></td>
            </tr>
            <tr>
                <td style="text-align:right">密码:</td>
                <td><input type="text" class="edit_text_box" id="password"/></td>
            </tr>
            <tr>
                <td style="text-align:right">状态:</td>
                <td>
                    <select id="status" class='N_select'>
                        <option value="1">启用</option>
                        <option value="0">停用</option>
                    </select>
                    <script type="text/javascript">
                        if ('<%=xview["status"]%>' != '') 
                        {
                            document.getElementById("status").value = '<%=xview["status"]%>';
                        }
                    </script>
                </td>
            </tr>
            <tr>
                <td style="text-align:right">是否管理员:</td>
                <td>
                    <select id="is_admin" class='N_select'>
                        <option value="0">否</option>
                        <option value="1">是</option>
                    </select>
                    <script type="text/javascript">
                        if ('<%=xview["is_admin"]%>' != '') {
                            document.getElementById("is_admin").value = '<%=xview["is_admin"]%>';
                        }
                    </script>
                </td>
            </tr>
            <tr>
                <td style="text-align:right">所属角色:</td>
                <td>
                    <div style='border:solid 1px gray;width:200px;height:140px;overflow:auto'>
                    <%=xview["role_html"] %>
                    </div>
                </td>
            </tr>
	    </table>
        <div style="text-align:center;margin-top:20px">
            <input type="button" class='SiteButton' value="保存" onclick="save()" style='<%=auth.AuthView("System_Member_Edit")%>'/>
        </div>
    </div>
</asp:Content>

