/// <summary>
        /// 验证名称是否存在
        /// </summary>
        /// <param name="id">ID</param>
        /// <param name="name">名称</param>
        /// <param name="mobileType">手机类型</param>
        /// <returns></returns>
        public bool NameExists(string name, int id, int mobileType)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(true);
            }
            var args = new List <object> {
                new { Name = name, Id = id, MobileType = mobileType }
            };
            var sbWhere = new StringBuilder("SELECT COUNT(*) FROM VersionManagement ");

            sbWhere.AppendFormat(" Where RowStatus = 1 ");
            sbWhere.AppendFormat(" and Name = @Name ");
            sbWhere.AppendFormat(" and MobileType = @MobileType ");
            if (id > 0)
            {
                sbWhere.Append(" and Id <> @Id ");
            }
            WriteDatabase.Comment = new StringExtension.SqlComment
            {
                Author   = "",
                FileName = "ComVersionManagementDal.cs",
                ForUse   = "查询",
                FunName  = "NameExists"
            };
            return(WriteDatabase.ExecuteScalar <int>(sbWhere.ToString(), args.ToArray()) > 0);
        }
Beispiel #2
0
        /// <summary>
        /// 验证帐号ID是否存在
        /// </summary>
        /// <param name="id">ID</param>
        /// <param name="accountId">帐号ID</param>
        /// <returns></returns>
        public bool AccountIdExists(string accountId, int id)
        {
            if (string.IsNullOrEmpty(accountId))
            {
                return(true);
            }
            var args = new List <object> {
                new { p1 = accountId, p2 = id }
            };
            var sbWhere = new StringBuilder("SELECT COUNT(*) FROM ComApiAccount ");

            sbWhere.Append(Database.GetFormatSql <ComApiAccountEntity>("Where {0}=1 ", t => t.ROWSTATUS));
            sbWhere.Append(Database.GetFormatSql <ComApiAccountEntity>(" and {0} = @p1 ", t => t.ACCOUNTID));
            if (id > 0)
            {
                sbWhere.Append(Database.GetFormatSql <ComApiAccountEntity>(" and {0} <> @p2 ", t => t.ID));
            }
            WriteDatabase.Comment = new StringExtension.SqlComment
            {
                Author   = "",
                FileName = "ComApiAccountDal.cs",
                ForUse   = "验证帐号ID是否存在",
                FunName  = "AccountIdExists"
            };
            return(WriteDatabase.ExecuteScalar <int>(sbWhere.ToString(), args.ToArray()) > 0);
        }
        /// <summary>
        /// 验证文件版本号
        /// </summary>
        /// <param name="fileVersionNo">验证的文件版本号</param>
        /// <param name="mobileType">手机类型</param>
        /// <returns></returns>
        public bool FileVersionExists(string fileVersionNo, int mobileType)
        {
            var args = new List <object> {
                new { FileVersion = fileVersionNo, MobileType = mobileType }
            };
            var sbWhere = new StringBuilder("SELECT COUNT(*) FROM ComVersionManagement ");

            sbWhere.AppendFormat(" Where RowStatus=1 ");
            sbWhere.AppendFormat(" and FileVersion = @FileVersion ");
            sbWhere.AppendFormat(" and MobileType = @MobileType ");
            WriteDatabase.Comment = new StringExtension.SqlComment
            {
                Author   = "",
                FileName = "ComVersionManagementDal.cs",
                ForUse   = "验证文件版本号",
                FunName  = "FileVersionExists"
            };
            return(WriteDatabase.ExecuteScalar <int>(sbWhere.ToString(), args.ToArray()) > 0);
        }