示例#1
0
文件: Comm.cs 项目: sxb920815/ParkSys
        /// <summary>
        /// 判断字段是否完整
        /// </summary>
        /// <param name="coll">请求的参数</param>
        /// <param name="fields">索要匹配的</param>
        /// <param name="msg">返回的错误消息</param>
        /// <returns>字段是否完整</returns>
        public static bool ExistField(NameValueCollection coll, string[] fields, ref ResultMsg msg)
        {
            if (coll == null || coll.Count < 1)
            {
                msg.SetValue("ReturnMsg", "请求参数为空");
                return(false);
            }

            foreach (var field in fields)
            {
                var flag = false;
                foreach (var key in coll.AllKeys)
                {
                    if (field == key)
                    {
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    msg.SetValue("ReturnMsg", field + "不存在");
                    return(false);
                }
            }

            return(true);
        }
示例#2
0
文件: Comm.cs 项目: sxb920815/ParkSys
        /// <summary>
        /// 字段空值
        /// </summary>
        /// <param name="coll"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static bool IsNotEmpty(NameValueCollection coll, ref ResultMsg msg)
        {
            foreach (var field in coll.AllKeys)
            {
                if (string.IsNullOrEmpty(field))
                {
                    msg.SetValue("ReturnMsg", field + "参数错误");
                    return(false);
                }
            }

            return(true);
        }