Пример #1
0
    public string GenerateLuckLotteryNumber(int LotteryID, string Type, string Name)
    {
        string Key = "Home_Room_Buy_GenerateLuckLotteryNumber" + LotteryID.ToString();

        Type = Shove._Web.Utility.FilteSqlInfusion(Type);
        Name = Shove._Web.Utility.FilteSqlInfusion(Name);

        if (Type == "3")
        {
            try
            {
                DateTime time = Convert.ToDateTime(Name);
                Name = time.ToString("yyyy-MM-dd");

                if (time > DateTime.Now)
                {
                    return("出生日期不能超过当前日期!");
                }
            }
            catch
            {
                return("日期格式不正确!");
            }
        }

        DataTable dt = Shove._Web.Cache.GetCacheAsDataTable(Key);

        if (dt == null || dt.Rows.Count == 0)
        {
            dt = new DAL.Tables.T_LuckNumber().Open("", "datediff(d,getdate(),DateTime)=0 and LotteryID=" + LotteryID.ToString() + "", "");

            Shove._Web.Cache.SetCache(Key, dt, 3600);
        }

        string LotteryNumber = "";

        DataRow[] dr = dt.Select("Type=" + Type + " and Name='" + Name + "'");

        if (dr != null && dr.Length > 0)
        {
            LotteryNumber = dr[0]["LotteryNumber"].ToString();
        }
        else
        {
            LotteryNumber = new SLS.Lottery()[LotteryID].BuildNumber(1);

            DAL.Tables.T_LuckNumber ln = new DAL.Tables.T_LuckNumber();

            ln.LotteryID.Value     = LotteryID;
            ln.LotteryNumber.Value = LotteryNumber;
            ln.Name.Value          = Name;
            ln.Type.Value          = Type;

            ln.Insert();
            ln.Delete("datediff(d,DateTime,getdate())>0");

            Shove._Web.Cache.ClearCache(Key);
        }

        return(LotteryNumber + "|" + FormatLuckLotteryNumber(LotteryNumber));
    }
Пример #2
0
    public string GenerateLuckLotteryNumber(int LotteryID, string Type, string Name, string lotteryName)
    {
        if (string.IsNullOrEmpty(lotteryName))
        {
            lotteryName = "cjdlt";
        }
        string Key = "Home_Room_Buy_GenerateLuckLotteryNumber" + LotteryID.ToString();

        Type = Shove._Web.Utility.FilteSqlInfusion(Type);
        Name = Shove._Web.Utility.FilteSqlInfusion(Name);

        if (Type == "3")
        {
            try
            {
                DateTime time = Convert.ToDateTime(Name);
                Name = time.ToString("yyyy-MM-dd");

                if (time > DateTime.Now)
                {
                    return("出生日期不能超过当前日期!");
                }
            }
            catch
            {
                return("日期格式不正确!");
            }
        }

        DataTable dt = Shove._Web.Cache.GetCacheAsDataTable(Key);

        if (dt == null || dt.Rows.Count == 0)
        {
            dt = new DAL.Tables.T_LuckNumber().Open("", "datediff(d,getdate(),DateTime)=0 and LotteryID=" + LotteryID.ToString() + "", "");

            Shove._Web.Cache.SetCache(Key, dt, 3600);
        }

        string LotteryNumber = "";

        DataRow[] dr = dt.Select("Type=" + Type + " and Name='" + Name + "'");

        if (dr != null && dr.Length > 0)
        {
            LotteryNumber = dr[0]["LotteryNumber"].ToString();
        }
        else
        {
            string num = "";
            switch (lotteryName)
            {
            case "cjdlt":
                num = new SLS.Lottery()[LotteryID].BuildNumber(5, 2, 1);
                break;

            case "pl3":
                num = new SLS.Lottery()[LotteryID].BuildNumber(1);
                break;

            case "ssq":
                num = new SLS.Lottery()[LotteryID].BuildNumber(6, 1, 1);
                break;

            case "3d":
                num = new SLS.Lottery()[LotteryID].BuildNumber(1);
                break;

            case "qlc":
                num = new SLS.Lottery()[LotteryID].BuildNumber(1);
                break;

            case "pl5":
                num = new SLS.Lottery()[LotteryID].BuildNumber(1);
                break;

            case "qxc":
                num = new SLS.Lottery()[LotteryID].BuildNumber(1);
                break;

            case "22x5":
                num = new SLS.Lottery()[LotteryID].BuildNumber(1);
                break;

            case "31x7":
                num = new SLS.Lottery()[LotteryID].BuildNumber(1);
                break;
            }

            LotteryNumber = num;

            DAL.Tables.T_LuckNumber ln = new DAL.Tables.T_LuckNumber();

            ln.LotteryID.Value     = LotteryID;
            ln.LotteryNumber.Value = LotteryNumber;
            ln.Name.Value          = Name;
            ln.Type.Value          = Type;

            ln.Insert();
            ln.Delete("datediff(d,DateTime,getdate())>0");

            Shove._Web.Cache.ClearCache(Key);
        }

        string LuckLottery = "";

        switch (lotteryName)
        {
        case "cjdlt":
            LuckLottery = FormatLuckLotteryNumber_cjdlt(LotteryID, LotteryNumber);
            break;

        case "pl3":
            LuckLottery = FormatLuckLotteryNumber_PL3(LotteryID, LotteryNumber);
            break;

        case "ssq":
            LuckLottery = FormatLuckLotteryNumber_SSQ(LotteryID, LotteryNumber);
            break;

        case "3d":
            LuckLottery = FormatLuckLotteryNumber_3D(LotteryNumber);
            break;

        case "qlc":
            LuckLottery = FormatLuckLotteryNumber_QLC(LotteryNumber);
            break;

        case "pl5":
            LuckLottery = FormatLuckLotteryNumber_PL5(LotteryNumber);
            break;

        case "qxc":
            LuckLottery = FormatLuckLotteryNumber_QXC(LotteryID, LotteryNumber);
            break;

        case "22x5":
            LuckLottery = FormatLuckLotteryNumber_22x5(LotteryNumber);
            break;

        case "31x7":
            LuckLottery = FormatLuckLotteryNumber_31X7(LotteryID, LotteryNumber);
            break;
        }


        return(LotteryNumber + "|" + LuckLottery);
    }