예제 #1
0
        /// <summary>
        /// 修改操作员,如果操作员编号已被使用,抛出InvalidOperationException
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public CommandResult Update(OperatorInfo info)
        {
            List <OperatorInfo> allOpt = GetAllOperators().QueryObjects;

            if (allOpt.Exists(opt => opt.OperatorID != info.OperatorID && opt.OperatorName == info.OperatorName))
            {
                throw new InvalidOperationException(string.Format(Resource1.OperatorBll_NamebeUsed, info.OperatorName));
            }
            if (info.OperatorNum > 0 && allOpt.Exists(opt => opt.OperatorID != info.OperatorID && opt.OperatorNum == info.OperatorNum))
            {
                throw new InvalidOperationException(string.Format(Resource1.OperatorBll_NumbeUsed, info.OperatorNum));
            }

            OperatorInfo original = GetByID(info.OperatorID).QueryObject;

            if (original != null)
            {
                return(provider.Update(info, original));
            }
            else
            {
                return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord)));
            }
        }