Esempio n. 1
0
        public JsonResult UpdateTempData(ItemChargeUnitInsertViewModel model)
        {
            MSGReturnModel <string> result = new MSGReturnModel <string>();

            result.RETURN_FLAG = false;
            result.DESCRIPTION = Ref.MessageType.login_Time_Out.GetDescription();
            if (Cache.IsSet(CacheList.ItemChargeUnitSearchDetailViewData))
            {
                var tempData       = (List <ItemChargeUnitSearchDetailViewModel>)Cache.Get(CacheList.ItemChargeUnitSearchDetailViewData);
                var updateTempData = tempData.FirstOrDefault(x => x.vCHARGE_UNIT_ID == model.vCHARGE_UNIT_ID);
                if (updateTempData != null)
                {
                    var _EMPS           = new Service.Actual.Common().GetEmps();
                    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_MAIL_DEPT_MGR  = model.vIS_MAIL_DEPT_MGR;
                    updateTempData.vIS_MAIL_SECT_MGR  = model.vIS_MAIL_SECT_MGR;
                    updateTempData.vIS_DISABLED       = model.vIs_Disabled;

                    Cache.Invalidate(CacheList.ItemChargeUnitSearchDetailViewData);
                    Cache.Set(CacheList.ItemChargeUnitSearchDetailViewData, 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));
        }
Esempio n. 2
0
        public JsonResult DeleteTempData(ItemChargeUnitInsertViewModel model)
        {
            MSGReturnModel <bool> result = new MSGReturnModel <bool>();

            result.RETURN_FLAG = false;
            result.DESCRIPTION = Ref.MessageType.login_Time_Out.GetDescription();
            if (Cache.IsSet(CacheList.ItemChargeUnitSearchDetailViewData))
            {
                var tempData       = (List <ItemChargeUnitSearchDetailViewModel>)Cache.Get(CacheList.ItemChargeUnitSearchDetailViewData);
                var deleteTempData = tempData.FirstOrDefault(x => x.vCHARGE_UNIT_ID == model.vCHARGE_UNIT_ID);
                if (deleteTempData != null)
                {
                    //判斷是否新增資料
                    if (deleteTempData.vEXEC_ACTION == "A")
                    {
                        tempData.Remove(deleteTempData);
                    }
                    else
                    {
                        deleteTempData.vEXEC_ACTION       = "D";
                        deleteTempData.vEXEC_ACTION_VALUE = "刪除";
                    }
                    Cache.Invalidate(CacheList.ItemChargeUnitSearchDetailViewData);
                    Cache.Set(CacheList.ItemChargeUnitSearchDetailViewData, tempData);
                    result.RETURN_FLAG = true;
                    result.DESCRIPTION = Ref.MessageType.delete_Success.GetDescription();
                    result.Datas       = tempData.Where(x => x.vEXEC_ACTION != null).Any();
                }
            }
            return(Json(result));
        }
Esempio n. 3
0
        public JsonResult InsertTempData(ItemChargeUnitInsertViewModel model)
        {
            MSGReturnModel <string> result = new MSGReturnModel <string>();

            //List<ItemChargeUnitSearchDetailViewModel> tempData = new List<ItemChargeUnitSearchDetailViewModel>();
            result.RETURN_FLAG = false;
            result.DESCRIPTION = Ref.MessageType.login_Time_Out.GetDescription();

            var HasSameName = ItemChargeUnit.CheckName(model);

            //var HasSameData = tempData.FirstOrDefault(x => x.vTREA_ITEM_NAME == model.vTREA_ITEM_NAME && x.vCHARGE_UID == model.vCHARGE_UID);

            if (HasSameName)
            {
                result.DESCRIPTION = string.Format("此經辦已經是資料庫名稱 {0} 的經辦", model.vTREA_ITEM_NAME_VALUE);
                result.RETURN_FLAG = false;
                return(Json(result));
            }
            if (Cache.IsSet(CacheList.ItemChargeUnitSearchDetailViewData))
            {
                var tempData = (List <ItemChargeUnitSearchDetailViewModel>)Cache.Get(CacheList.ItemChargeUnitSearchDetailViewData);

                var _TREA_ITEM_NAME = new Service.Actual.Common().GetSysCode("TREA_ITEM_NAME");
                var _DATA_STATUS    = new Service.Actual.Common().GetSysCode("DATA_STATUS");
                var _EMPS           = new Service.Actual.Common().GetEmps();
                var _DEPTS          = new Service.Actual.Common().GetDepts();
                var cUserId         = AccountController.CurrentUserId;
                var _ItemChargeUnitSearchDetailVM = new ItemChargeUnitSearchDetailViewModel()
                {
                    vCHARGE_UNIT_ID       = model.vCHARGE_UNIT_ID,
                    vTREA_ITEM_NAME       = model.vTREA_ITEM_NAME,
                    vTREA_ITEM_NAME_VALUE = model.vTREA_ITEM_NAME_VALUE,
                    vCHARGE_DEPT          = model.vCHARGE_DEPT,
                    vCHARGE_DEPT_VALUE    = !model.vCHARGE_DEPT.IsNullOrWhiteSpace() ? _EMPS.FirstOrDefault(y => y.DPT_CD != null && y.DPT_CD.Trim() == model.vCHARGE_DEPT)?.DPT_NAME?.Trim() : null,
                    vCHARGE_SECT          = !model.vCHARGE_SECT.IsNullOrWhiteSpace() ? model.vCHARGE_SECT : "",
                    vCHARGE_SECT_VALUE    = !model.vCHARGE_SECT.IsNullOrWhiteSpace() ? _EMPS.FirstOrDefault(y => y.DPT_CD != null && y.DPT_CD.Trim() == model.vCHARGE_SECT)?.DPT_NAME?.Trim() : null,
                    vIS_MAIL_DEPT_MGR     = model.vIS_MAIL_DEPT_MGR,
                    vIS_MAIL_SECT_MGR     = model.vIS_MAIL_SECT_MGR,
                    vCHARGE_UID           = model.vCHARGE_UID,
                    vCHARGE_NAME          = !model.vCHARGE_UID.IsNullOrWhiteSpace() ? _EMPS.FirstOrDefault(y => y.USR_ID == model.vCHARGE_UID)?.EMP_NAME?.Trim() : null,
                    vDATA_STATUS          = "1",
                    vDATA_STATUS_VALUE    = _DATA_STATUS.FirstOrDefault(x => x.Value == "1")?.Text?.Trim(),
                    vEXEC_ACTION          = "A",
                    vEXEC_ACTION_VALUE    = "新增",
                    vIS_DISABLED          = model.vIs_Disabled
                };
                tempData.Add(_ItemChargeUnitSearchDetailVM);
                Cache.Invalidate(CacheList.ItemChargeUnitSearchDetailViewData);
                Cache.Set(CacheList.ItemChargeUnitSearchDetailViewData, tempData);
                result.RETURN_FLAG = true;
                result.DESCRIPTION = Ref.MessageType.insert_Success.GetDescription();
            }
            return(Json(result));
        }