public ActionResult Edit(int id) { json_batch tempData = ob_json_batchservice.GetEntityById(json_batch => json_batch.ID == id && json_batch.IsDelete == false); ViewBag.json_batch = tempData; if (tempData == null) { return(View()); } else { json_batchViewModel json_batchviewmodel = new json_batchViewModel(); json_batchviewmodel.ID = tempData.ID; json_batchviewmodel.DELIVERY_NUMBER = tempData.DELIVERY_NUMBER; json_batchviewmodel.PACKAGE_NUMBER = tempData.PACKAGE_NUMBER; json_batchviewmodel.PURCHASE_ORDER = tempData.PURCHASE_ORDER; json_batchviewmodel.MATERIAL_NUMBER = tempData.MATERIAL_NUMBER; json_batchviewmodel.BATCH_NUMBER = tempData.BATCH_NUMBER; json_batchviewmodel.DELIVERY_QTY = tempData.DELIVERY_QTY; json_batchviewmodel.UOM = tempData.UOM; json_batchviewmodel.EXP_DATE = tempData.EXP_DATE; json_batchviewmodel.SN_FLAG = tempData.SN_FLAG; json_batchviewmodel.DOM_DATE = tempData.DOM_DATE; json_batchviewmodel.DESCRIPTION_SC = tempData.DESCRIPTION_SC; json_batchviewmodel.MANUFACTURER_NAME = tempData.MANUFACTURER_NAME; json_batchviewmodel.PRODUCT_LABEL_NAME = tempData.PRODUCT_LABEL_NAME; json_batchviewmodel.LICENSE_NO = tempData.LICENSE_NO; json_batchviewmodel.OTHER_CONDITION = tempData.OTHER_CONDITION; json_batchviewmodel.Col1 = tempData.Col1; json_batchviewmodel.MakeDate = tempData.MakeDate; json_batchviewmodel.MakeMan = tempData.MakeMan; return(View(json_batchviewmodel)); } }
public ActionResult Update() { string id = Request["id"] ?? ""; string delivery_number = Request["delivery_number"] ?? ""; string package_number = Request["package_number"] ?? ""; string purchase_order = Request["purchase_order"] ?? ""; string material_number = Request["material_number"] ?? ""; string batch_number = Request["batch_number"] ?? ""; string delivery_qty = Request["delivery_qty"] ?? ""; string uom = Request["uom"] ?? ""; string exp_date = Request["exp_date"] ?? ""; string sn_flag = Request["sn_flag"] ?? ""; string dom_date = Request["dom_date"] ?? ""; string description_sc = Request["description_sc"] ?? ""; string manufacturer_name = Request["manufacturer_name"] ?? ""; string product_label_name = Request["product_label_name"] ?? ""; string license_no = Request["license_no"] ?? ""; string other_condition = Request["other_condition"] ?? ""; string col1 = Request["col1"] ?? ""; string makedate = Request["makedate"] ?? ""; string makeman = Request["makeman"] ?? ""; int uid = int.Parse(id); try { json_batch p = ob_json_batchservice.GetEntityById(json_batch => json_batch.ID == uid); p.DELIVERY_NUMBER = delivery_number.Trim(); p.PACKAGE_NUMBER = package_number.Trim(); p.PURCHASE_ORDER = purchase_order.Trim(); p.MATERIAL_NUMBER = material_number.Trim(); p.BATCH_NUMBER = batch_number.Trim(); p.DELIVERY_QTY = delivery_qty == "" ? 0 : int.Parse(delivery_qty); p.UOM = uom.Trim(); p.EXP_DATE = exp_date == "" ? DateTime.Now : DateTime.Parse(exp_date); p.SN_FLAG = sn_flag == "" ? 0 : int.Parse(sn_flag); p.DOM_DATE = dom_date == "" ? DateTime.Now : DateTime.Parse(dom_date); p.DESCRIPTION_SC = description_sc.Trim(); p.MANUFACTURER_NAME = manufacturer_name.Trim(); p.PRODUCT_LABEL_NAME = product_label_name.Trim(); p.LICENSE_NO = license_no.Trim(); p.OTHER_CONDITION = other_condition.Trim(); p.Col1 = col1.Trim(); p.MakeDate = makedate == "" ? DateTime.Now : DateTime.Parse(makedate); p.MakeMan = makeman == "" ? 0 : int.Parse(makeman); ob_json_batchservice.UpdateEntity(p); ViewBag.saveok = ViewAddTag.ModifyOk; } catch (Exception ex) { Console.WriteLine(ex.Message); ViewBag.saveok = ViewAddTag.ModifyNo; } return(RedirectToAction("Edit", new { id = uid })); }