@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<style>
    #ISO {
        width: 10px;
    }
</style>
<link href="~/Content/js/select2/select2.min.css" rel="stylesheet" />
<script src="~/Content/js/select2/select2.min.js"></script>
<script>
    var ID = '';

    $(function () {
        ID = $.request("ID");
        debugger;
        if (ID != '') {
            GetTextValues();
        } 


    });



    

    function GetTextValues() {
        $.ajax({
            url: "/WMS/BasicSettings/GetInputValue?ID=" + ID,
            type:"post",
            dataType: "json",
            async: false,
            success: function (data) {
                $("#InvCode").val(data.rows[0].InvCode);
                $("#InvName").val(data.rows[0].InvName);
                $("#InvDesc").val(data.rows[0].InvDesc);
                $("#InvStd").val(data.rows[0].InvStd);
                $("#InvUnit").val(data.rows[0].InvUnit);
                $("#AmountUnit").val(data.rows[0].AmountUnit);
                $("#ClassName").val(data.rows[0].ClassName);
                $("#ClassCode").val(data.rows[0].ClassCode);
                $("#InvRate").val(data.rows[0].InvRate);
                $("#InvVersion").val(data.rows[0].InvVersion);
                $("#InvBrand").val(data.rows[0].InvBrand);
                $("#EffectiveDays").val(data.rows[0].EffectiveDays);
                $("#WHUser").val(data.rows[0].WHUser);
                //是否IQC检验
                if (data.rows[0].InvIQC == '1') {
                    $("#InvIQCYes").prop("checked", true);
                } else {

                    $("#InvIQCNo").prop("checked", true);
                }
                //是否FQC检验
                if (data.rows[0].InvFQC == '1') {
                    $("#InvFQCYes").prop("checked", true);
                } else {

                    $("#InvFQCNo").prop("checked", true);
                }
                //是否启用有效期
                if (data.rows[0].EffectiveEnable == '1') {
                    $("#EffectiveEnableYes").prop("checked", true);
                } else {

                    $("#EffectiveEnableNo").prop("checked", true);
                }
                //是否启用批次
                if (data.rows[0].BatchEnable == '1') {
                    $("#BatchEnableYes").prop("checked", true);
                } else {

                    $("#BatchEnableNo").prop("checked", true);
                }
                //是否自动分批
                if (data.rows[0].LotEnable == '1') {
                    $("#LotEnableYes").prop("checked", true);
                } else {

                    $("#LotEnableNo").prop("checked", true);
                }
                //是否自动打印
                if (data.rows[0].PrintEnable == '1') {
                    $("#PrintEnableYes").prop("checked", true);
                } else {

                    $("#PrintEnableNo").prop("checked", true);
                }

            }
        });


    }

    function submitForm() {
        var InvCode = $("#InvCode").val();//物料代码必填
        var InvName = $("#InvName").val();//物料名称必填
        var InvDesc = $("#InvDesc").val();
        var ColName = $("#ColName").val();
        var InvStd = $("#InvStd").val();
        var InvUnit = $("#InvUnit").val();//主计量单位必填
        var AmountUnit = $("#AmountUnit").val();
        var ClassCode = $("#ClassCode").val();//大类编码必填
        var ClassName = $("#ClassName").val();//大类名称必填
        var InvRate = $("#InvRate").val();//固定换算率必填
        var InvVersion = $("#InvVersion").val();
        var InvBrand = $("#InvBrand").val();
        var EffectiveDays = $("#EffectiveDays").val();//必填
        var WHUser = $("#WHUser").val();
        var InvIQC = $('input[name="InvIQC"]:checked').val();//是否IQC检验
        var InvFQC = $('input[name="InvFQC"]:checked').val();//是否FQC检验
        var EffectiveEnable = $('input[name="EffectiveEnable"]:checked').val();//是否启用有效期
        var BatchEnable = $('input[name="BatchEnable"]:checked').val();//是否启用批次
        var LotEnable = $('input[name="LotEnable"]:checked').val();//是否自动分批
        var PrintEnable = $('input[name="PrintEnable"]:checked').val();//是否自动打印
        if (InvIQC == "" || InvIQC == undefined) {
            $.modalAlertNew("WMS00027");
            return;
        }
        if (InvFQC == "" || InvFQC == undefined) {
            $.modalAlertNew("WMS00028");
            return;
        }
        if (EffectiveEnable == "" || EffectiveEnable == undefined) {
            $.modalAlertNew("WMS00029");
            return;
        }
        if (BatchEnable == "" || BatchEnable == undefined) {
            $.modalAlertNew("WMS00030");
            return;
        }
        if (LotEnable == "" || LotEnable == undefined) {
            $.modalAlertNew("WMS00031");
            return;
        }
        if (PrintEnable == "" || PrintEnable == undefined) {
            $.modalAlertNew("WMS00032");
            return;
        }
        if (!$('#form1').formValid()) {
            return false;
        }

        var objArr = {
            ID: ID,
            InvCode: InvCode,
            InvName: InvName,
            InvDesc: InvDesc,
            ColName: ColName,
            InvStd: InvStd,
            InvUnit: InvUnit,
            InvDesc: InvDesc,
            AmountUnit: AmountUnit,
            ClassCode: ClassCode,
            ClassName: ClassName,
            InvRate: InvRate,
            InvVersion: InvVersion,
            InvBrand: InvBrand,
            EffectiveDays: EffectiveDays,
            WHUser: WHUser,
            InvIQC: InvIQC,
            InvFQC: InvFQC,
            EffectiveEnable: EffectiveEnable,
            BatchEnable: BatchEnable,
            LotEnable: LotEnable,
            PrintEnable: PrintEnable
        }
        debugger;
        if (ID!="") {
            $.submitForm({
                url: "/WMS/BasicSettings/UpdateICSInventory" + "?" + Math.random(),
                param: { keyValue: JSON.stringify(objArr) },
                success: function () {
                    $.currentWindow().$("#gridList").trigger("reloadGrid");
                }
            })
        } else {
            $.submitForm({
                url: "/WMS/BasicSettings/InsertICSInventory" + "?" + Math.random(),
                param: { keyValue: JSON.stringify(objArr) },
                success: function () {
                    $.currentWindow().$("#gridList").trigger("reloadGrid");
                }
            })
        }
    }



</script>

<form id="form1">
    <div style="padding-top: 20px; margin-right: 20px;">
        <table class="form">
            <tr>
                <th class="formTitle">料品编码:</th>
                <td class="formValue">
                    @*<select id="sel_InvCode" name="sel_InvCode" class="form-control select2" onchange="TxTValue()" style="width: 230px" placeholder="请选择物料代码..."></select>*@
                    <input id="InvCode" name="InvCode" type="text" class="form-control required" style="width: 200px;" maxlength="10" placeholder="料品编码" />
                    <input type="hidden" id="hidetext" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">物料描述:</th>
                <td class="formValue">
                    <input id="InvName" name="InvName" type="text" class="form-control required" style="width: 200px;" maxlength="10"   placeholder="物料描述" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">辅助描述:</th>
                <td class="formValue">
                    <input id="InvDesc" name="InvDesc" type="text" class="form-control " style="width: 200px;" maxlength="10"   placeholder="辅助描述" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">规格型号:</th>
                <td class="formValue">
                    <input id="InvStd" name="InvStd" type="text" class="form-control " style="width: 200px;" maxlength="10"   placeholder="规格型号" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">主计量单位:</th>
                <td class="formValue">
                    <input id="InvUnit" name="InvUnit" type="text" class="form-control required" style="width: 200px;" maxlength="10"   placeholder="主计量单位" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">辅计量单位:</th>
                <td class="formValue">
                    <input id="AmountUnit" name="AmountUnit" type="text" class="form-control" style="width: 200px;" maxlength="10"   placeholder="辅计量单位" />
                </td>
            <tr>
                <th class="formTitle">大类编码:</th>
                <td class="formValue">
                    <input id="ClassCode" name="ClassCode" type="text" class="form-control required" style="width: 200px;" maxlength="10"   placeholder="大类编码" />
                </td>
            <tr>
                <th class="formTitle">大类名称:</th>
                <td class="formValue">
                    <input id="ClassName" name="ClassName" type="text" class="form-control required" style="width: 200px;" maxlength="10"   placeholder="大类名称" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">固定换算率:</th>
                <td class="formValue">
                    <input id="InvRate" name="InvRate" type="text" class="form-control required" style="width: 200px;" maxlength="10"   placeholder="固定换算率" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">版本:</th>
                <td class="formValue">
                    <input id="InvVersion" name="InvVersion" type="text" class="form-control " style="width: 200px;" maxlength="10"   placeholder="版本" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">厂牌:</th>
                <td class="formValue">
                    <input id="InvBrand" name="InvBrand" type="text" class="form-control" style="width: 200px;" maxlength="10"   placeholder="厂牌" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">有效期天数:</th>
                <td class="formValue">
                    <input id="EffectiveDays" name="EffectiveDays" type="text" class="form-control required" style="width: 200px;" maxlength="10"   placeholder="有效期天数" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">仓管员:</th>
                <td class="formValue">
                    <input id="WHUser" name="WHUser" type="text" class="form-control " style="width: 200px;" maxlength="10"   placeholder="仓管员" />
                </td>
            </tr>

            <tr>
                <th class="formTitle">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;是否IQC检验:</th>
                <td class="formValue">
                    <div class="input-group" id="InvIQCchaeckbox">
                        <input type="radio" name="InvIQC" value="1" id="InvIQCYes" style="width:60px" /><label for="cb-NoQuotedPrice">是</label>
                        <input type="radio" name="InvIQC" value="0" id="InvIQCNo" style="width:60px" /><label for="cb-QuotedPrice">否</label>
                    </div>

                </td>
            </tr>

            <tr>
                <th class="formTitle">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;是否FQC检验:</th>
                <td class="formValue">
                    <div class="input-group" id="InvFQCchaeckbox">
                        <input type="radio" name="InvFQC" value="1" id="InvFQCYes" style="width:60px" /><label for="cb-NoQuotedPrice">是</label>
                        <input type="radio" name="InvFQC" value="0" id="InvFQCNo" style="width:60px" /><label for="cb-QuotedPrice">否</label>
                    </div>

                </td>
              
            </tr>

            <tr>
                <th class="formTitle">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;是否启用有效期:</th>
                <td class="formValue">
                    <div class="input-group" id="EffectiveEnablechaeckbox">
                        <input type="radio" name="EffectiveEnable" value="1" id="EffectiveEnableYes" style="width:60px" /><label for="cb-NoQuotedPrice">是</label>
                        <input type="radio" name="EffectiveEnable" value="0" id="EffectiveEnableNo" style="width:60px" /><label for="cb-QuotedPrice">否</label>
                    </div>

                </td>
            </tr>

            <tr>
                <th class="formTitle">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;是否启用批次:</th>
                <td class="formValue">
                    <div class="input-group" id="BatchEnablechaeckbox">
                        <input type="radio" name="BatchEnable" value="1" id="BatchEnableYes" style="width:60px" /><label for="cb-NoQuotedPrice">是</label>
                        <input type="radio" name="BatchEnable" value="0" id="BatchEnableNo" style="width:60px" /><label for="cb-QuotedPrice">否</label>
                    </div>

                </td>
            </tr>
            <tr>
                <th class="formTitle">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;是否自动分批:</th>
                <td class="formValue">
                    <div class="input-group" id="LotEnablechaeckbox">
                        <input type="radio" name="LotEnable" value="1" id="LotEnableYes" style="width:60px" /><label for="cb-NoQuotedPrice">是</label>
                        <input type="radio" name="LotEnable" value="0" id="LotEnableNo" style="width:60px" /><label for="cb-QuotedPrice">否</label>
                    </div>

                </td>
            </tr>
            <tr >
                <th class="formTitle">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;是否自动打印:</th>
                <td class="formValue">
                    <div class="input-group" id="PrintEnablechaeckbox">
                        <input type="radio" name="PrintEnable" value="1" id="PrintEnableYes" style="width:60px" /><label for="cb-NoQuotedPrice">是</label>
                        <input type="radio" name="PrintEnable" value="0" id="PrintEnableNo" style="width:60px" /><label for="cb-QuotedPrice">否</label>
                    </div>

                </td>
            </tr>


        </table>
    </div>
</form>