コード例 #1
0
ファイル: BA04Business.cs プロジェクト: WuYen/VN_PURSYS
        /// <summary> 驗證資料 </summary>
        /// <param name="model"></param>
        /// <param name="modelState"></param>
        /// <param name="isBefore">是否在BeforeSave前面 - 前面驗證 [資料刪除/Metadata/邏輯] / 後面驗證 [DDM]  </param>
        /// <returns></returns>
        public static List <string> Validation(BA04AModel model, ModelStateDictionary modelState)
        {
            List <string> errMsgList = new List <string>();
            Dictionary <string, string> masterErrDic = new Dictionary <string, string>();

            #region [ 驗證資料是否已被刪除 ]
            //不是新增的時候要去驗證是否有被異動過
            if (model.BA04A_ID > 0)
            {
                BA04Service _Service = new BA04Service();
                var         count    = _Service.GetA(x => x.BA04A_ID == model.BA04A_ID).Count();
                if (count == 0)
                {
                    errMsgList.Add("資料已被其他使用者刪除");
                }
            }
            #endregion

            #region [ master - 邏輯]
            //if (masterErrDic.Where(x => x.Key == "CUS_ID").Count() == 0 && new BA04Service().GetA(x => x.BA04A_ID != model.BA04A_ID && x.CUS_ID == model.CUS_ID).Count() > 0)
            //{
            //    masterErrDic.Add("CUS_ID", string.Format(CommonHelper.GetCodeName("W021"), DDMHelper.GetColName("BA04A", "CUS_ID")));
            //}
            #endregion [ master - 邏輯]

            VallidationResult(modelState, errMsgList, masterErrDic);

            return(errMsgList);
        }
コード例 #2
0
ファイル: BA04Business.cs プロジェクト: WuYen/VN_PURSYS
        public static BA04A BeforSave(BA04AModel data)
        {
            var BA04A = new BA04A();

            if (data.BA04A_ID == 0)//Adding New
            {
                data.CREATE_USER = UserInfo.Id;
                data.CREATE_DATE = DateTime.Now;
            }
            else//Update
            {
                var _Service = new BA04Service();
                BA04A            = _Service.GetA(x => x.BA04A_ID == data.BA04A_ID).First();
                data.CREATE_USER = BA04A.CREATE_USER;
                data.CREATE_DATE = BA04A.CREATE_DATE;
                data.UPDATE_USER = UserInfo.Id;
                data.UPDATE_DATE = DateTime.Now;
            }

            return(ToEntity(data));
        }