Пример #1
0
        /// <summary>
        /// 增加操作员,如果操作员编号已被使用,抛出InvalidOperationException
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public CommandResult Insert(OperatorInfo info)
        {
            List <OperatorInfo> allOpt = GetAllOperators().QueryObjects;

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

            return(ret);
        }