
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);
    //调用getuser()
        getuser(id);
}

//AJAX读取信息
function getuser(id) {
    var1 = "beduajax.aspx?ACT=02622C23C3AFA01FDFD0F3DFB5987774&id=" + id;
    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("|");
            $("#fvhpmc").val(arr[0]);
            $("#fihpid").val(arr[1]);
            $("#ftyxrq").val(arr[2]);
            $("#fvrkbm").val(arr[3]);
            $("#fikcsl").val(arr[4]);
            $("#fdkcjz").val(arr[5]);
            $("#ficksl").val(arr[4]);
            $('#zje').html('金额：￥' + $('#ficksl').val() * $('#fdkcjz').val() + "元");
        }
    });
}

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


function checkSubmit() {
    var sysl;
    if ($("#act").val() == "") {
        layer.msg("页面错误！", {
            icon: 2, btn: ['确定']
        }, function () {
        });
        return false;
    }
    else if ($("#id").val() == "") {
        layer.msg("页面错误id！", {
            icon: 2, btn: ['确定']
        }, function () {
        });
        return false;
    }
    else if ($("#fvhpmc").val() == "") {
        layer.msg("请选择货品名称", {
            icon: 2, btn: ['确定']
        }, function () {
            $("#fvhpmc").focus();
        });
        return false;
    }
    else if ($("#fvrkbm").val() == "") {
        layer.msg("请选择货品名称", {
            icon: 2, btn: ['确定']
        }, function () {
            $("#fvrkbm").focus();
        });
        return false;
    }
    else if (parseInt($("#ficksl").val()) > parseInt($("#fikcsl").val())) {
        layer.msg("出库数量不能大于库存量", {
            icon: 2, btn: ['确定']
        }, function () {
            $("#ficksl").select();
            $("#ficksl").focus();
        });
        return false;
    }
      else if (!(/(^[1-9]\d*$)/.test($("#ficksl").val()))) {
        layer.msg("出库数量必为正整数", {
            icon: 2, btn: ['确定']
        }, function () {
            $("#ficksl").select();
            $("#ficksl").focus();
        });
        return false;
    }
      else if ((!(/^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/.test($("#fdkcjz").val())))) {
        layer.msg("价格必为货币型", {
            icon: 2, btn: ['确定']
        }, function () {
            $("#fdkcjz").select();
            $("#fdkcjz").focus();
        });
        return false;
    }
    else if ($("#fvbzsm").val() == "") {
        layer.msg("备注说明不能为空（可写无）", {
            icon: 2, btn: ['确定']
        }, function () {
            $("#fvbzsm").select();
            $("#fvbzsm").focus();
        });
        return false;
    }
      else
       sysl = parseInt($("#fikcsl").val()) - parseInt($("#ficksl").val());  //应该剩余数量
       var1 = "beduajax.aspx?act=" + $("#act").val() + "&id=" + $("#id").val() + "&fihpid=" + $("#fihpid").val() + "&fizrst=" + $("#fizrst").val() + "&fvhpmc=" + $("#fvhpmc").val() + "&fvrkbm=" + $("#fvrkbm").val() + "&sysl=" + sysl + "&fikcsl=" + $("#fikcsl").val() + "&ficksl=" + $("#ficksl").val() + "&fdkcjz=" + $("#fdkcjz").val() + "&ftyxrq=" + $("#ftyxrq").val() + "&fvbzsm=" + $("#fvbzsm").val();
     XSENDAJAX(var1);
}

//发送AJAX
function Zsend(var1) {
    temptext = var1;
    layer.msg(temptext, { icon: 1, btn: ['确定'] }, function () {
        if (temptext.indexOf("成功") > -1) {
            window.location.reload();
        }
        return true;
    });
}

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

function ZJLCX()
{// 条件查询
    var fvrkbm1 = "";
    var fvrkbm2 = "";
    var fvcode = "";
    var fvhplb = "";
    var fvghsm = "";
    var fvscsm = "";
    var firkid = "";
    var ftyxrq = "";
    if ($("#fvcode2").val() != "")
    { fvcode = $("#fvcode2").val(); }
    if ($("#firkid2").val() != "")
    { firkid = $("#firkid2").val(); }
    if ($("#fvhplb2").val() != "")
    { fvhplb = $("#fvhplb2").val(); }
    if ($("#fvghsm2").val() != "")
    { fvghsm = $("#fvghsm2").val(); }
    if ($("#fvscsm2").val() != "")
    { fvscsm = $("#fvscsm2").val(); }
    if ($("#fvscsm2").val() != "")
    { fvscsm = $("#fvscsm2").val(); }
    if ($("#fvrkbm1").val() != "")
   { fvrkbm1 = FormatDate($("#fvrkbm1").val()); }
    if ($("#fvrkbm2").val() != "")
    { fvrkbm2 = FormatDate($("#fvrkbm2").val()); }
    if ($("#ftyxrq2").val() != "")
    { ftyxrq = FormatDate($("#ftyxrq2").val()); }
window.location.href = "ekcck.aspx?fvcode=" + fvcode + "&fvhplb=" + fvhplb + "&fvghsm=" + fvghsm + "&firkid=" + firkid + "&fvscsm=" + fvscsm + "&ftyxrq=" + ftyxrq + "&fvrkbm1=" + fvrkbm1 + "&fvrkbm2=" + fvrkbm2;
}



