Example #1
0
        //删除前的数据校验
        public ERROR_CODE Delete_Valid(long id, long user_id, out string returnvalue)
        {
            returnvalue = string.Empty;
            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            var data = _dal.FindById(id);

            if (data == null)
            {
                return(ERROR_CODE.ERROR);
            }
            if (data.is_system > 0)
            {
                return(ERROR_CODE.SYSTEM);
            }
            //d_general、ivt_product、crm_installed_product
            //有n个产品种类、n个产品、n个配置项
            int installed_product = new crm_installed_product_dal().ExecuteSQL($"select * from crm_installed_product where cate_id={id} and delete_time=0");
            int product           = new ivt_product_dal().ExecuteSQL($"select * from ivt_product where installed_product_cate_id={id} and delete_time=0");
            int product_cate      = _dal.ExecuteSQL($"select * from d_general where ext1='{id.ToString()}' and delete_time=0");

            if (installed_product > 0 || product > 0 || product_cate > 0)
            {
                returnvalue = @"有" + product_cate + "个产品种类、" + product + "个产品、" + installed_product + "个配置项关联此配置项类型。如果删除,则相关产品种类、产品、配置项上的配置项类型信息将会被清空,并且配置项上将会显示全部相关自定义字段。是否继续";
                return(ERROR_CODE.EXIST);
            }
            return(ERROR_CODE.SUCCESS);
        }