public ActionResult Detail(string id = "")
        {
            MD_SUBMATERIAL model = new MD_SUBMATERIAL();

            if (!string.IsNullOrEmpty(id))
            {
                var result = APIHelper.CallAPI <JsonResultObject <List <MD_SUBMATERIAL> > >("submaterial/getdetail", new
                {
                    id = id
                });
                if (result.IsOk)
                {
                    model = result.dataObj.FirstOrDefault();
                }
            }
            return(View(model));
        }
 public JsonResult Save(MD_SUBMATERIAL info)
 {
     if (info.ID != 0)
     {
         if (string.IsNullOrEmpty(info.NAME))
         {
             return(Json(new JsonResultData
             {
                 IsOk = false,
                 dataErr = null,
                 dataObj = null,
                 Msg = "NAME can not be null",
                 totalrows = 0
             }, JsonRequestBehavior.AllowGet));
         }
         //if (string.IsNullOrEmpty(info.SHORTNAME))
         //{
         //    return Json(new JsonResultData
         //    {
         //        IsOk = false,
         //        dataErr = null,
         //        dataObj = null,
         //        Msg = "SHORTNAME can not be null",
         //        totalrows = 0
         //    }, JsonRequestBehavior.AllowGet);
         //}
         //update
         return(Json(APIHelper.CallAPI <JsonResultData>("submaterial/update", new
         {
             info.ID,
             info.NAME,
             info.MATERIALID,
             info.SHORTNAME,
             info.VALUE
         }), JsonRequestBehavior.AllowGet));
     }
     else
     {
         if (string.IsNullOrEmpty(info.NAME))
         {
             return(Json(new JsonResultData
             {
                 IsOk = false,
                 dataErr = null,
                 dataObj = null,
                 Msg = "NAME can not be null",
                 totalrows = 0
             }, JsonRequestBehavior.AllowGet));
         }
         //if (string.IsNullOrEmpty(info.SHORTNAME))
         //{
         //    return Json(new JsonResultData
         //    {
         //        IsOk = false,
         //        dataErr = null,
         //        dataObj = null,
         //        Msg = "SHORTNAME can not be null",
         //        totalrows = 0
         //    }, JsonRequestBehavior.AllowGet);
         //}
         //insert
         return(Json(APIHelper.CallAPI <JsonResultData>("submaterial/insert", new
         {
             info.ID,
             info.MATERIALID,
             info.NAME,
             info.SHORTNAME,
             info.VALUE
         }), JsonRequestBehavior.AllowGet));
     }
 }