示例#1
0
        protected virtual string CheckData(string columnName)
        {
            string errorInfo = null;

            if (columnName == "Code")
            {
                if (Code.IsNullEmpty())
                {
                    errorInfo = "不能为空";
                }
                else if (Code.Length < 6)
                {
                    errorInfo = "至少为6位";
                }
                else if (ID == 0)//新增
                {
                    if (_linqOP.Any <VIPCard>(e => e.Code == Code))
                    {
                        errorInfo = "该编号已经被使用";
                    }
                }
                else//编辑
                {
                    if (_linqOP.Any <VIPCard>(e => e.ID != ID && e.Code == Code))
                    {
                        errorInfo = "该编号已经被使用";
                    }
                }
            }
            else if (columnName == "OrganizationID")
            {
                if (OrganizationID == default(int))
                {
                    errorInfo = "不能为空";
                }
            }
            else if (columnName == "CustomerName")
            {
                if (CustomerName.IsNullEmpty())
                {
                    errorInfo = "不能为空";
                }
            }
            else if (columnName == "MobilePhone")
            {
                if (!MobilePhone.IsNullEmpty())
                {
                    if (!MobilePhone.IsMobile())
                    {
                        errorInfo = "格式不正确";
                    }
                    else if (ID == 0)//新增
                    {
                        if (_linqOP.Any <VIPCard>(e => e.MobilePhone == MobilePhone))
                        {
                            errorInfo = "该手机号码已经被使用";
                        }
                    }
                    else//编辑
                    {
                        if (_linqOP.Any <VIPCard>(e => e.ID != ID && e.MobilePhone == MobilePhone))
                        {
                            errorInfo = "该手机号码已经被使用";
                        }
                    }
                }
            }

            return(errorInfo);
        }