コード例 #1
0
        public JsonResult UpdateDone(ImpContractViewModel info)
        {
            MD_IMPORTCONTRACT contractdetail = info.GetContractDetail();

            contractdetail.UPDATEDUSER = LoginUser.Current.USERNAME;
            var resultupdatedone = APIHelper.CallAPI <JsonResultData>("importcontract/updatedone", new
            {
                data = contractdetail
            });

            return(Json(resultupdatedone, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public JsonResult Update(ImpContractViewModel info)
        {
            List <MD_IMPORTITEMDETAIL> detail = info.GetDetailList();
            string lstList = "";

            foreach (var item in detail)
            {
                lstList += item.ID + ";";
            }
            lstList = lstList.Substring(0, lstList.Length - 1);
            var resultDeleteNotInList = APIHelper.CallAPI <JsonResultData>("importitemdetail/deletenotinlist", new
            {
                lstListId  = lstList,
                ItemListId = info.ID
            });

            if (!resultDeleteNotInList.IsOk)
            {
                return(Json(resultDeleteNotInList, JsonRequestBehavior.AllowGet));
            }
            foreach (var item in detail)
            {
                if (item.ID != 0)
                {
                    var resultDetailList = APIHelper.CallAPI <JsonResultData>("importitemdetail/update", new
                    {
                        data = item
                    });
                    if (!resultDetailList.IsOk)
                    {
                        return(Json(new JsonResultData
                        {
                            IsOk = false,
                            Msg = "item detail Update - " + resultDetailList.Msg,
                        }, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    var resultDetailList = APIHelper.CallAPI <JsonResultData>("importitemdetail/insert", new
                    {
                        data = item
                    });
                    if (resultDetailList.IsOk)
                    {
                        info.ItemIDDetail.Add(Convert.ToInt64(resultDetailList.dataObj));
                    }
                    else
                    {
                        return(Json(new JsonResultData
                        {
                            IsOk = false,
                            Msg = "item detail Insert - " + resultDetailList.Msg,
                        }, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            MD_IMPORTCONTRACT contractdetail = info.GetContractDetail();

            if (contractdetail.ID != 0)
            {
                var result = APIHelper.CallAPI <JsonResultData>("importcontract/update", new
                {
                    data = contractdetail
                });
                return(Json(new JsonResultData
                {
                    IsOk = result.IsOk,
                    dataErr = null,
                    dataObj = null,
                    Msg = "contractdetail Update - " + result.Msg,
                    totalrows = 0
                }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new JsonResultData
                {
                    IsOk = false,
                    dataErr = null,
                    dataObj = null,
                    Msg = "ID CAN NOT BE NULL IN UPDATE FUNCTION",
                    totalrows = 0
                }, JsonRequestBehavior.AllowGet));
            }
        }