示例#1
0
 /// <summary>
 /// 添加新手卡号
 /// </summary>
 /// <param name="c">卡号</param>
 /// <returns>返回是否添加成功</returns>
 public Boolean AddCard(cards c)
 {
     try
     {
         string sql = "insert into cards(cardnum,cardnameid)values (@cardnum,@cardnameid)";
         SqlParameter[] sp = new SqlParameter[]
         {
            new SqlParameter("@cardnum",c.cardnum),
             new SqlParameter("@cardnameid",c.cardnameid)
         };
         return db.ExecuteNonQuery(sql, sp);
     }
     catch (SqlException ex)
     {
         throw new Exception("数据库异常!原因:" + ex.Message);
     }
     catch (Exception ex)
     {
         throw new Exception("未知异常!原因:" + ex.Message);
     }
 }
示例#2
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>";
     }
 }
示例#3
0
 public Boolean DoImportCard()
 {
     if (Session[Keys.SESSION_ADMIN_INFO] == null)
     {
         return false;
     }
     else
     {
         Master master = Session[Keys.SESSION_ADMIN_INFO] as Master;
         if (rcm.GetRoleCompetence(master.RoleId, 11254))
         {
             try
             {
                 cards c = new cards();
                 int CardId = int.Parse(Request["CardId"]);
                 string CardTextContent = Request["CardTextContent"].Replace("\n", "|");
                 string[] CardContent = CardTextContent.Split('|');
                 foreach (string Card in CardContent)
                 {
                     if (!string.IsNullOrEmpty(Card) && !cm.ExitCard(CardId, Card))
                     {
                         c.cardnum = Card;
                         c.cardnameid = CardId;
                         c.addtime = DateTime.Now;
                         c.state = 0;
                         cm.AddCard(c);
                     }
                 }
                 return true;
             }
             catch (Exception)
             {
                 return false;
             }
         }
         else
         {
             return false;
         }
     }
 }
示例#4
0
 /// <summary>
 /// 添加新手卡号
 /// </summary>
 /// <param name="c">卡号</param>
 /// <returns>返回是否添加成功</returns>
 public Boolean AddCard(cards c)
 {
     return cs.AddCard(c);
 }
示例#5
0
 /// <summary>
 /// 获取一张未领取的新手卡
 /// </summary>
 /// <param name="CardId">卡Id</param>
 /// <returns>返回新手卡</returns>
 public cards GetCards(int CardId)
 {
     cards c = new cards();
     try
     {
         string sql = "select top 1 * from cards where state =0 and cardnameid=@CardId";
         SqlParameter[] sp = new SqlParameter[]
        {
            new SqlParameter("@CardId",CardId)
        };
         using (SqlDataReader reder = db.GetReader(sql, sp))
         {
             while (reder.Read())
             {
                 c.id = (int)reder["id"];
                 c.cardnum = reder["cardnum"].ToString();
                 c.cardnameid = (int)reder["cardnameid"];
                 c.state = (int)reder["state"];
                 c.addtime = (DateTime)reder["addtime"];
             }
         }
     }
     catch (SqlException ex)
     {
         throw new Exception("数据库异常!原因:" + ex.Message);
     }
     catch (Exception ex)
     {
         throw new Exception("未知异常!原因:" + ex.Message);
     }
     return c;
 }