var layer_index;
function addUser(title, id) {
    $("#jswintitle").html(title);
    layer_index = layer.open({
        type: 1,
        title: false,
        closeBtn: 0,
        shift: false,
        content: $("#jsAddUser"),
    });
    $("#id").val(id);
    //如果是新增
    if (id == "0")
    {
        $("#fvyhsm").val("无");
        $("[name='fbsfky']").attr("checked", true);

    }
    else
    {//是修改，调用getuser()
        getuser(id);
    }
}
//AJAX读取USER信息
function getuser(id) {

    var1 = "beduajax.aspx?ACT=55ACFBE72BAABCB92CDF29626CECF8A3&id=" + id;
   // var temptext = "";
    var1 = encodeURI((var1));
    $.ajax({
        type: "Post",
        url: var1,
        data: { data1: '13D17C93EDB', },
        cache: false,
        contentType: "application/x-www-form-urlencoded; charset=UTF-8",
        success: function (temptext) {
            var arr = new Array();
            
            arr = temptext.split("|");
            $("#fvyhgh").val(arr[0]);
            $("#fvyhxm").val(arr[1]);
            $("#fiyhlx").val(arr[2]);
            $("#fvyhdh").val(arr[3]);
            $("#fvyhyx").val(arr[4]);
          
            if (arr[5] == "0" || arr[5] == 0) {
                $("[name='fbsfky']").attr("checked", false);
            }
            else {
                $("[name='fbsfky']").attr("checked", true);
            }

            $("#fvyhsm").val(arr[6]);
        }
    });

   
}

//自动写邮箱
function Writefvyhyx() {
    //if ($("#fvyhyx").val() == "")
    { $("#fvyhyx").val($("#fvyhgh").val() + "@hevttc.edu.cn"); }
}

//关闭弹出
function cansleAdd() {
    layer.close(layer_index);
    clearWin();
}
//清除窗体中内容
function clearWin() {
    $("#jsAddUser").find("input").each(function () {
        $(this).val("");
    });
}

//发送AJAX
function Zsend(var1) {

    temptext = var1;

    layer.msg(temptext, { icon: 1, btn: ['确定'] }, function () {
        if (temptext.indexOf("成功") > -1) {
            window.location.reload();
        }
        if (temptext.indexOf("相同工号") > -1) {
            $("input[name='fvyhgh']").get(index).select();
            $("input[name='fvyhgh']").get(index).focus();

        }
        return true;
    });
}

function ZALLRZ()
{// 全部记录
window.location.href="dyhgl.aspx";
}

function ZJLCX()
{// 条件查询
var fvyhgh="";
var fvyhxm="";

if (document.getElementById("fvyhgh1").value!="")
{fvyhgh=  document.getElementById("fvyhgh1").value;}

if (document.getElementById("fvyhxm1").value!="")
{fvyhxm=  document.getElementById("fvyhxm1").value;}


window.location.href = "dyhgl.aspx?fvyhgh=" + fvyhgh + "&fvyhxm=" + fvyhxm ;
}

function FYHGLCSMM(id) {

    layer.confirm('确认要初始密码吗？', {
        icon: 3, btn: ['确定', '取消'] //按钮
    }, function () {
        //
        var1 = "beduajax.aspx?ACT=B8955F16BF3534B5DF9086A3948140BF&id=" + id;
        var temptext = "";
        var1 = encodeURI((var1));
        $.ajax({
            type: "Post",
            url: var1,
            data: { data1: '13D17C93EDB', },
            cache: false,
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            success: function (temptext) {
                layer.msg(temptext, { icon: 1, btn: ['确定'] }, function () {
                              return true;
                });
            }
        });

      
    });


}


function  ZDELESELE(id)
{
layer.confirm('确认要删除吗？', {
    icon: 3, btn: ['确定', '取消'] //按钮
}, function () {
    temp = ZQDdele(id);
});
}

function  ZQDdele(id)
{//删除选择
    var1 = "beduajax.aspx?ACT=BACB0F436393212333A5E407C69BD9ED&id=" + id;
var temptext = "";
var1 = encodeURI((var1));
$.ajax({
    type: "Post",
    url: var1,
    data: { data1: '13D17C93EDB', },
    cache: false,
    contentType: "application/x-www-form-urlencoded; charset=UTF-8",
    success: function (temptext) {
        layer.msg(temptext, { icon: 1, btn: ['确定'] }, function () {
            if (temptext.indexOf("成功删除用户") > -1) {
                window.location.reload();
            }
            return true;
        });
    }
});

}


