コード例 #1
0
        public string DoGetGift(int CardId, string CardNum)
        {
            cardsname cn = new cardsname();

            cn = cm.GetCard(CardId);
            g  = gm.GetGame(cn.gameid);
            if (cm.GetCardCount(CardId) < 1)
            {
                return("<span><b>温馨提示:</b><lable style=\"color:red\">该新手卡已经被抢空啦!</span>");
            }
            int UserId = BBRequest.GetUserId();

            if (UserId <= 0)
            {
                if (Utils.GetCookie("6qmgamesame") != "")
                {
                    string   value    = Utils.GetCookie("6qmgamesame");
                    string   UserName = DESEncrypt.DesDecrypt(value.Split('|')[0]);
                    string   PWD      = DESEncrypt.DesDecrypt(value.Split('|')[1]);
                    GameUser gu       = gum.GetGameUser(UserName, DESEncrypt.Md5(PWD, 32));
                    if (gu != null)
                    {
                        BBRequest.WriteUserId(gu.Id);
                        gum.UpdateLastLogin(gu.Id);
                        UserId = BBRequest.GetUserId();
                    }
                    else
                    {
                        return("<span><b>温馨提示:</b><lable style=\"color:red\">登录后才可领取!</lable></span>");
                    }
                }
                else
                {
                    return("<span><b>温馨提示:</b><lable style=\"color:red\">登录后才可领取!</lable></span>");
                }
            }
            if (CardNum == null)
            {
                if (cm.ExitCardLog(UserId, CardId))
                {
                    return("<span id=\"showno\" ><b>温馨提示:</b><lable style=\"color:red\">您已经领取过该新手卡啦!</span>");
                }
                else
                {
                    cards c = new cards();
                    c       = cm.GetCards(CardId);
                    CardNum = c.cardnum;
                    cardslog cl = new cardslog();
                    cl.userid  = UserId;
                    cl.cardid  = CardId;
                    cl.cardsid = c.id;
                    cm.AddCardLog(cl);
                    cm.UpdateCard(1, c.id);
                    sysmsg sysmsg1 = new sysmsg();
                    sysmsg1.msgid  = 0;
                    sysmsg1.title  = "新手卡信息:" + cn.cardname;
                    sysmsg1.type   = 2;
                    sysmsg1.userid = UserId;
                    sysmsg1.msg    = "领取新手卡成功!卡号:" + c.cardnum;
                    sysmsg1.fromid = 0;
                    new SysMsgManager().AddSysMsg(sysmsg1);
                    return("<span id=\"showno\" ><b>领取成功!激活码:</b> <label id=\"lblno\" style=\"color:red\"> " + CardNum + " </label></span>");
                }
            }
            else
            {
                return("<span id=\"showno\" ><b>领取成功!激活码:</b> <label id=\"lblno\" style=\"color:red\"> " + CardNum + " </label></span>");
            }
        }