Exemple #1
0
        /// <summary>
        /// add 验证表单数据
        /// </summary>
        /// <returns></returns>
        private static bool FormCheck(AssetM data)
        {
            if (AssetItemCode(data) == false)
            {
                data.ErrorMsg = $"{data.Title}的itemCode获取失败.";
                return(false);
            }
            string verrmsg = Validate.CheckEntity <AssetM>(data);

            if (verrmsg != null)
            {
                data.ErrorMsg = verrmsg;
                return(false);
            }
            foreach (string item in new string[] { data.Action, data.ExcOrg, data.Kind })
            {
                if (KeyValBll.CheckByCode(item) == false)
                {
                    data.ErrorMsg = $"{item}无效.";
                    return(false);
                }
            }
            //
            return(true);
        }
Exemple #2
0
        /// <summary>
        /// 查询记录,并且按kvcategory分组,返回以组名为键的字典.
        /// 查询出错,组名无效,返回null
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        public static Dictionary <string, List <KeyvalM> > AllByCategory(KeyvalM para)
        {
            if (string.IsNullOrWhiteSpace(para.Categorys))
            {
                para.ErrorMsg = "无效的分组参数";
                return(null);
            }
            Dictionary <string, List <KeyvalM> > datadict = new Dictionary <string, List <KeyvalM> >();

            string[] categorys = para.Categorys.Split(',');
            for (int i = 0; i < categorys.Length; i++)
            {
                if (int.TryParse(categorys[i], out para.Category) == false)
                {
                    para.ErrorMsg = $"无效的分组: {categorys[i]}";
                    return(null);
                }
                var data = KeyValBll.All(para);
                datadict.Add(categorys[i], data);
            }
            return(datadict);
        }