HTML page text box can be edited and disabled

Click the material number to enter the interface, and the remarks column and storage location must be editable, and other fields cannot be edited
Insert picture description here
Insert picture description here

<tr>
                    @*库位*@
                    <td class="table-label">@Html.LabelFor(m => m.STORE_CODE)</td>
                    <td colspan="1" class="table-dataCol">
                        @Html.Kendo().DropDownListFor(m => m.STORE_CODE).HtmlAttributes(new { @disabled = "",style = "margin: unset; width: 80%;" }).BindTo(Model.StoreList).Filter("contains")
                        @Html.ValidationMessageFor(m => m.STORE_CODE)
                    </td>
                    @*储位*@
                    <td class="table-label">@Html.LabelFor(m => m.STORE_LOCATION)</td>
                    <td colspan="1" class="table-dataCol">
                        @Html.Kendo().TextBoxFor(x => x.STORE_LOCATION).HtmlAttributes(new {  style = "margin: unset; width: 80%;" })
                    </td>
                </tr>
                <tr>
                    @*数量*@
                    <td class="table-label">@Html.LabelFor(m => m.QTY, new { @readonly = false })</td>
                    <td colspan="1" class="table-dataCol">
                        @Html.Kendo().TextBoxFor(x => x.QTY).HtmlAttributes(new { @disabled = "", style = "margin: unset; width: 80%;", oninput = "inputData()" })
                    </td>
                    @*单位*@
                    <td class="table-label">@Html.LabelFor(m => m.UNIT)</td>
                    <td>@Html.Kendo().TextBoxFor(x => x.UNIT).HtmlAttributes(new { @disabled = "" })</td>
                </tr>
                <tr>
                    @*成本中心*@
                    <td class="table-label">@Html.LabelFor(m => m.COST_CENTER)</td>
                    <td>
                        @(Html.Kendo().DropDownListFor(m => m.COST_CENTER)
                                                    .DataTextField("Text")
                                                    .DataValueField("Value")
                                                    .BindTo(Model.COST_CENTER_List)
                                                    .HtmlAttributes(new { @disabled = "",style = "width: 80%;" })
                                                    .Filter("contains")
                        )
                    </td>
                    @*备注*@
                    <td class="table-label">@Html.LabelFor(m => m.REMARK)</td>
                    <td colspan="3" class="table-dataCol">
                        @Html.Kendo().TextBoxFor(x => x.REMARK).HtmlAttributes(new { style = "margin: unset; width: 80%;" })
                    </td>
                </tr>

Editable code

 <td class="table-label">@Html.LabelFor(m => m.STORE_LOCATION)</td>
 <td colspan="1" class="table-dataCol">
  @Html.Kendo().TextBoxFor(x => x.STORE_LOCATION).HtmlAttributes(new {  style = "margin: unset; width: 80%;" })
 </td>

Non-editable code

 <td class="table-label">@Html.LabelFor(m => m.QTY, new { @readonly = false })</td>
 <td colspan="1" class="table-dataCol">
 @Html.Kendo().TextBoxFor(x => x.QTY).HtmlAttributes(new { @disabled = "", style = "margin: unset; width: 80%;", oninput = "inputData()" })
 </td>

Realize storage function

<script>
    function submitFunc(status) {
        var slcode = $("#Part_NO").val().trim(); 
        //var sPart_DESC = $("#Part_DESC").val().trim();
        //if (slcode.length == 0 && sPart_DESC.length == 0) {
        //    alert("料号、料号描述不能同时为空,请检查!");
        //    return;
        //}
        var qty = $("#QTY").val().trim();
        if (qty.length == 0) {
            alert("数量为空,请检查!");
            return;
        }
        if (window.location.pathname == "/G_SUP_STORE/Create") {
            //debugger;
            $('form').submit();
        }
        else {
            $('form').submit();
        }
    }

</script>

Logical modification of stored value

 [HttpPost]
        [UserAuthorize(FuncID.耗材清单查询_Edit)]
        public ActionResult Edit(G_SUP_STORE model)
        {
            using (var handler = new G_SUP_STOREHandler())
            {
                var bat_tooling_in_store = handler.GetG_SUP_STORE(model.ID);
                if (bat_tooling_in_store != null)
                {
                    //Preload(model, handler);
                    handler.UpdateG_SUP_STORE(model);
                }
                return RedirectToAction("Index");
            }
        }
  //获取耗材信息 
        public G_SUP_STORE GetG_SUP_STORE(decimal id)
        {
            var model = (from x in db.G_SUP_STORE
                         where x.ID == id && x.ENABLED == "Y"
                         orderby x.UPDATE_TIME descending
                         select new G_SUP_STORE
                         {
                             ID = x.ID,
                             Part_ID = db.SYS_PART.Where(a => a.ID == x.PART_ID).Select(a => a.ID).FirstOrDefault(),
                             Part_NO = db.SYS_PART.Where(a => a.ID == x.PART_ID).Select(a => a.PART_NO).FirstOrDefault(),
                             Part_DESC = db.SYS_PART.Where(a => a.ID == x.PART_ID).Select(a => a.PART_DESC).FirstOrDefault(),
                             COST_ATTRIBUTES = x.COST_ATTRIBUTES,
                             STORE_CODE = x.STORE_CODE,
                             STORE_LOCATION = x.STORE_LOCATION,
                             COST_CENTER = x.COST_CENTER_NAME,
                             DEPTEMP = db.SYS_DEPT.Where(d => d.DEPTCODE == x.COST_CENTER_NAME).Select(d => d.DEPTEMP).FirstOrDefault(),
                             QTY = x.QUANTITY,
                             UNIT=x.UNIT,
                             REMARK = x.REMARK,
                         }).SingleOrDefault();
            return model;
        }

        //修改数据 
        public void UpdateG_SUP_STORE(G_SUP_STORE model)
        {
            var data = db.G_SUP_STORE.Where(x => x.ID == model.ID && x.ENABLED == "Y").SingleOrDefault();
            if (data == null)
                return;
            if (model.Part_ID != null)
            {
                data.PART_ID = model.Part_ID;
                data.PART_DESC = null;
            }
            else
            {
                data.PART_ID = null;
                data.PART_DESC = model.Part_DESC;
            }
            //data.COST_ATTRIBUTES = model.COST_ATTRIBUTES;
            //data.COST_CENTER_NAME = model.COST_CENTER;
            //data.STORE_CODE = model.STORE_CODE;
            data.STORE_LOCATION = model.STORE_LOCATION;
            //data.QUANTITY = model.QTY;
            //data.UNIT = model.UNIT;
            data.REMARK = model.REMARK;
            data.UPDATE_TIME = DateTime.Now;
            data.UPDATE_ID = UserSession.Account.Id;
            db.SaveChanges();

        }

Guess you like

Origin blog.csdn.net/caoguanghui0804/article/details/114651214
Recommended