Пример #1
0
        public JsonResult UpdateTempData(ItemMaintainInsertViewModel model)
        {
            MSGReturnModel <string> result = new MSGReturnModel <string>();

            result.RETURN_FLAG = false;
            result.DESCRIPTION = Ref.MessageType.login_Time_Out.GetDescription();
            if (Cache.IsSet(CacheList.ItemMaintainSearchDetailViewData))
            {
                var tempData       = (List <ItemMaintainSearchDetailViewModel>)Cache.Get(CacheList.ItemMaintainSearchDetailViewData);
                var updateTempData = tempData.FirstOrDefault(x => x.vITEM_ID == model.vTrea_Item_Id);
                if (updateTempData != null)
                {
                    var _TREA_ITEM_TYPE = new Service.Actual.Common().GetSysCode("TREA_ITEM_TYPE");
                    var _TREA_ITEM_NAME = new Service.Actual.Common().GetSysCode("TREA_ITEM_NAME");

                    updateTempData.vEXEC_ACTION          = updateTempData.vEXEC_ACTION == "A" ? "A" : "U";
                    updateTempData.vEXEC_ACTION_VALUE    = updateTempData.vEXEC_ACTION_VALUE == "A" ? "新增" : "修改";
                    updateTempData.vIS_TREA_ITEM         = model.vIs_Item;
                    updateTempData.vTREA_ITEM_TYPE       = model.vType;
                    updateTempData.vTREA_ITEM_TYPE_VALUE = !model.vType.IsNullOrWhiteSpace() ? _TREA_ITEM_TYPE.FirstOrDefault(x => x.Value == model.vType)?.Text?.Trim() : null;
                    updateTempData.vTREA_ITEM_NAME       = model.vName;
                    updateTempData.vTREA_ITEM_NAME_VALUE = !model.vName.IsNullOrWhiteSpace() ? _TREA_ITEM_TYPE.FirstOrDefault(x => x.Value == model.vName)?.Text?.Trim() : null;
                    updateTempData.vISDO_PERDAY          = model.vIsDo_Perday;
                    updateTempData.vIS_DISABLED          = model.vIs_Disabled;
                    updateTempData.vMEMO = model.vMemo;

                    Cache.Invalidate(CacheList.ItemMaintainSearchDetailViewData);
                    Cache.Set(CacheList.ItemMaintainSearchDetailViewData, tempData);
                    result.RETURN_FLAG = true;
                    result.DESCRIPTION = Ref.MessageType.update_Success.GetDescription();
                }
                else
                {
                    result.RETURN_FLAG = false;
                    result.DESCRIPTION = Ref.MessageType.update_Fail.GetDescription();
                }
            }
            return(Json(result));
        }
Пример #2
0
        public JsonResult InsertTempData(ItemMaintainInsertViewModel model)
        {
            MSGReturnModel <string> result = new MSGReturnModel <string>();

            result.RETURN_FLAG = false;
            result.DESCRIPTION = Ref.MessageType.login_Time_Out.GetDescription();
            if (Cache.IsSet(CacheList.ItemMaintainSearchDetailViewData))
            {
                var tempData                    = (List <ItemMaintainSearchDetailViewModel>)Cache.Get(CacheList.ItemMaintainSearchDetailViewData);
                var _DATA_STATUS                = new Service.Actual.Common().GetSysCode("DATA_STATUS");
                var _TREA_ITEM_TYPE             = new Service.Actual.Common().GetSysCode("TREA_ITEM_TYPE");
                var _TREA_ITEM_NAME             = new Service.Actual.Common().GetSysCode("TREA_ITEM_NAME");
                var _ItemMaintainSearchDetailVM = new ItemMaintainSearchDetailViewModel()
                {
                    vITEM_ID              = model.vTrea_Item_Id,
                    vITEM_OP_TYPE         = model.vOp_Type,
                    vITEM_DESC            = model.vItem_Desc,
                    vIS_TREA_ITEM         = model.vIs_Item,
                    vTREA_ITEM_TYPE       = model.vType,
                    vTREA_ITEM_TYPE_VALUE = !model.vType.IsNullOrWhiteSpace() ? _TREA_ITEM_TYPE.FirstOrDefault(x => x.Value == model.vType)?.Text?.Trim() : null,
                    vTREA_ITEM_NAME       = model.vName,
                    vTREA_ITEM_NAME_VALUE = !model.vName.IsNullOrWhiteSpace() ? _TREA_ITEM_NAME.FirstOrDefault(x => x.Value == model.vName)?.Text?.Trim() : null,
                    vISDO_PERDAY          = model.vIsDo_Perday,
                    vIS_DISABLED          = model.vIs_Disabled,
                    vMEMO              = model.vMemo,
                    vDATA_STATUS       = "1",
                    vDATA_STATUS_VALUE = _DATA_STATUS.FirstOrDefault(x => x.Value == "1")?.Text?.Trim(),
                    vEXEC_ACTION       = "A",
                    vEXEC_ACTION_VALUE = "新增"
                };
                tempData.Add(_ItemMaintainSearchDetailVM);
                Cache.Invalidate(CacheList.ItemMaintainSearchDetailViewData);
                Cache.Set(CacheList.ItemMaintainSearchDetailViewData, tempData);
                result.RETURN_FLAG = true;
                result.DESCRIPTION = Ref.MessageType.insert_Success.GetDescription();
            }
            return(Json(result));
        }
Пример #3
0
        /// <summary>
        /// 刪除金庫存取項目明細資料
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonResult DeleteTempData(ItemMaintainInsertViewModel model)
        {
            MSGReturnModel <bool> result = new MSGReturnModel <bool>();

            result.RETURN_FLAG = false;
            result.DESCRIPTION = Ref.MessageType.login_Time_Out.GetDescription();
            if (Cache.IsSet(CacheList.ItemMaintainSearchDetailViewData))
            {
                var tempData       = (List <ItemMaintainSearchDetailViewModel>)Cache.Get(CacheList.ItemMaintainSearchDetailViewData);
                var deleteTempData = tempData.FirstOrDefault(x => x.vITEM_ID == model.vTrea_Item_Id);
                if (deleteTempData != null)
                {
                    //判斷是否新增資料
                    if (deleteTempData.vEXEC_ACTION == "A")
                    {
                        tempData.Remove(deleteTempData);
                    }
                    //else
                    //{
                    //    deleteTempData.vEXEC_ACTION = "D";
                    //    deleteTempData.vEXEC_ACTION_VALUE = "刪除";
                    //}
                    Cache.Invalidate(CacheList.ItemMaintainSearchDetailViewData);
                    Cache.Set(CacheList.ItemMaintainSearchDetailViewData, tempData);
                    result.RETURN_FLAG = true;
                    result.DESCRIPTION = Ref.MessageType.delete_Success.GetDescription();
                    result.Datas       = tempData.Where(x => x.vEXEC_ACTION != null).Any();
                }
                else
                {
                    result.RETURN_FLAG = false;
                    result.DESCRIPTION = Ref.MessageType.delete_Fail.GetDescription();
                }
            }
            return(Json(result));
        }