Esempio n. 1
0
 /// <summary>
 ///  检查并锁定邀请码
 /// </summary>
 /// <param name="code">邀请代码</param>
 /// <returns>如果邀请码可用返回true</returns>
 internal static bool LockCode(string code, string sid)
 {
     return(DBH.GetBoolean(QA.DBCS_MAIN, CommandType.Text,
                           "SELECT COUNT(*) FROM inviteinfo WHERE code=@code AND used=0;UPDATE inviteinfo SET used=1,invited=getdate() WHERE code=@code;",
                           new SqlParameter("@code", code),
                           new SqlParameter("@id", sid)));
 }
Esempio n. 2
0
 public static bool ExistUploadInfo(int uid, int referid, int type)
 {
     return(DBH.GetBoolean(QA.DBCS_MAIN, CommandType.Text, "SELECT COUNT(*) FROM attachment WHERE uid=@uid AND referid=@referid AND type=@type",
                           new SqlParameter("@uid", uid),
                           new SqlParameter("@referid", referid),
                           new SqlParameter("@type", type)));
 }
Esempio n. 3
0
        public static int UpdateUserCategory(string tableName, int id, int pid, int uid, string name, string pinyin = null, string pinyinabbr = null, string ename = null)
        {
            if (pinyin == null)
            {
                pinyin = HZ.ToPinYin(name, true);
            }
            if (pinyinabbr == null)
            {
                pinyinabbr = PinYin.GetInitial(name);
            }
            if (ename == null)
            {
                ename = pinyin;
            }

            //check pid & uid
            if (pid != 0 && !DBH.GetBoolean(QA.DBCS_CMS, CommandType.Text, "SELECT COUNT(id) FROM " + tableName + " WHERE pid=@pid AND uid=@uid", new SqlParameter("@pid", pid), new SqlParameter("@uid", uid)))
            {
                return(-1);
            }

            return(EB <UserCategoryEntity> .Update(QA.DBCS_CMS, new UserCategoryEntity()
            {
                id = id,
                uid = uid,
                pid = pid,
                name = name,
                pinyin = pinyin,
                pinyinabbr = pinyinabbr,
                ename = ename
            }, tableName));
        }
Esempio n. 4
0
        internal static bool CanApplyFriend(int uid, int tid)
        {
            if (IsFriend(uid, tid))
            {
                return(false);                 //已经是朋友了
            }
            int eid = DBH.GetInt32(QA.DBCS_MAIN, CommandType.Text, "SELECT id FROM event WHERE uid=@uid AND touid=@tid AND tmplname='apply_friend'", new SqlParameter("@uid", uid), new SqlParameter("@tid", tid));

            if (eid > 0) //发送过邀请
            {
                bool hasEventIndex = DBH.GetBoolean(QA.DBCS_MAIN, CommandType.Text, "SELECT COUNT(*) event_index WHERE uid=@tid AND eid=@eid", new SqlParameter("@tid", tid), new SqlParameter("@eid", eid));
                if (hasEventIndex)
                {
                    return(false);           //对方还没处理
                }
            }

            return(true);
        }
Esempio n. 5
0
 internal static bool ExistWWW(string www)
 {
     return(DBH.GetBoolean(QA.DBCS_MAIN, CommandType.Text, "SELECT COUNT(id) FROM user_account WHERE www=@www", new SqlParameter("@www", www)));
 }
Esempio n. 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="code"></param>
 internal static void UnLockCode(string code)
 {
     DBH.GetBoolean(QA.DBCS_MAIN, CommandType.Text, "UPDATE inviteinfo SET used=0 WHERE code=@code",
                    new SqlParameter("@code", code));
 }
Esempio n. 7
0
 public static bool IsFriend(int uid1, int uid2)
 {
     return(DBH.GetBoolean(QA.DBCS_MAIN, CommandType.Text, "SELECT COUNT(*) FROM friend WHERE uid1=@uid1 AND uid2=@uid2", new SqlParameter("@uid1", uid1), new SqlParameter("@uid2", uid2)));
 }