El cuadro de texto de la página HTML se puede editar y desactivar

Haga clic en el número de material para ingresar a la interfaz, y la columna de comentarios y la ubicación de almacenamiento deben ser editables, y otros campos no se pueden editar
Inserte la descripción de la imagen aquí
Inserte la descripción de la imagen aquí

<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>

Código editable

 <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>

Código no editable

 <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>

Realizar la función de almacenamiento

<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>

Modificación lógica del valor almacenado

 [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();

        }

Supongo que te gusta

Origin blog.csdn.net/caoguanghui0804/article/details/114651214
Recomendado
Clasificación