Example #1
0
        public JsonResult CancelApply(SpecifiedTimeTreasuryCancelViewModel CancelModel)
        {
            MSGReturnModel <List <SpecifiedTimeTreasurySearchDetailViewModel> > result = new MSGReturnModel <List <SpecifiedTimeTreasurySearchDetailViewModel> >();

            result.RETURN_FLAG = false;
            result.DESCRIPTION = Ref.MessageType.update_Fail.GetDescription();
            var searchData = (SpecifiedTimeTreasurySearchViewModel)Cache.Get(CacheList.SpecifiedTimeTreasurySearchData);

            result = SpecifiedTimeTreasury.CancelApplyData(CancelModel, AccountController.CurrentUserId, searchData);
            if (result.RETURN_FLAG)
            {
                Cache.Invalidate(CacheList.SpecifiedTimeTreasurySearchDetailViewData);
                Cache.Set(CacheList.SpecifiedTimeTreasurySearchDetailViewData, result.Datas);
            }
            return(Json(result));
        }
Example #2
0
        public MSGReturnModel <List <SpecifiedTimeTreasurySearchDetailViewModel> > CancelApplyData(SpecifiedTimeTreasuryCancelViewModel data, string currentUserId, SpecifiedTimeTreasurySearchViewModel searchData)
        {
            var result = new MSGReturnModel <List <SpecifiedTimeTreasurySearchDetailViewModel> >();

            result.RETURN_FLAG = false;
            result.DESCRIPTION = Ref.MessageType.update_Fail.GetDescription();
            string logStr = string.Empty; //log

            //bool 登入者與申請者為同一人
            if (data.vCREATE_UID == currentUserId)
            {
                if (data.vAPLY_STATUS_ID == ((int)Ref.ApplyStatus._1).ToString() || data.vAPLY_STATUS_ID == ((int)Ref.ApplyStatus._3).ToString())
                {
                    using (TreasuryDBEntities db = new TreasuryDBEntities())
                    {
                        var _data = db.TREA_OPEN_REC.FirstOrDefault(x => x.TREA_REGISTER_ID == data.vTREA_REGISTER_ID);
                        //統一取系統時間
                        DateTime dt = DateTime.Now;
                        if (_data != null)
                        {
                            if (_data.APPR_UID == null)
                            {
                                db.TREA_OPEN_REC.Remove(_data);
                            }
                            else
                            {
                                _data.APPR_STATUS     = "4";
                                _data.LAST_UPDATE_UID = currentUserId;
                                _data.LAST_UPDATE_DT  = dt;
                            }

                            logStr += _data.modelToString(logStr);

                            var validateMessage = db.GetValidationErrors().getValidateString();
                            if (validateMessage.Any())
                            {
                                result.DESCRIPTION = validateMessage;
                            }
                            else
                            {
                                try
                                {
                                    db.SaveChanges();

                                    if (data.vAPPR_UID == null)
                                    {
                                        result.DESCRIPTION = Ref.MessageType.delete_Success.GetDescription();
                                        #region LOG
                                        //新增LOG
                                        Log log = new Log();
                                        log.CFUNCTION = "取消覆核(作廢)";
                                        log.CACTION   = "D";
                                        log.CCONTENT  = logStr;
                                        LogDao.Insert(log, currentUserId);
                                        #endregion
                                    }
                                    else
                                    {
                                        result.DESCRIPTION = Ref.MessageType.update_Success.GetDescription();;
                                        #region LOG
                                        //新增LOG
                                        Log log = new Log();
                                        log.CFUNCTION = "取消覆核";
                                        log.CACTION   = "U";
                                        log.CCONTENT  = logStr;
                                        LogDao.Insert(log, currentUserId);
                                        #endregion
                                    }

                                    result.RETURN_FLAG = true;
                                }
                                catch (DbUpdateException ex)
                                {
                                    result.DESCRIPTION = ex.exceptionMessage();
                                }
                            }
                        }
                        else
                        {
                            result.DESCRIPTION = Ref.MessageType.not_Find_Audit_Data.GetDescription();
                        }
                    }
                }
                else
                {
                    result.DESCRIPTION = Ref.MessageType.parameter_Error.GetDescription();
                }
            }
            if (result.RETURN_FLAG)
            {
                result.Datas = GetSearchDetail(searchData);
            }
            return(result);
        }