Example #1
0
        /// <summary>
        /// 获取奖项列表
        /// </summary>
        void GetAwardList()
        {
            if (strSiteCode.Trim() != null && strSiteCode.Trim() != "" &&
                strActID.Trim() != null && strActID.Trim() != "")
            {
                string where = string.Empty;
                where        = " and SiteCode='" + strSiteCode + "' and a.ActID='" + strActID + "' ";
                List <LuckyAward> modelList = new List <LuckyAward>();
                //DataSet modellistds = AwardDal.GetAwardList(where);
                DataSet modellistds = AwardDal.GetActAwardList(strActID, 0);
                foreach (DataRow row in modellistds.Tables[0].Rows)
                {
                    LuckyAward Awardmodel = DataConvert.DataRowToModel <LuckyAward>(row);
                    modelList.Add(Awardmodel);
                }
                int    awardcount = modellistds.Tables[0].Rows.Count;
                string awardpre   = string.Empty;
                //decimal awardpervalue =100/Convert.ToDecimal(awardcount);
                //if (awardpervalue.ToString().Contains("."))
                //{
                //    awardpre = awardpervalue.ToString().Substring(0, awardpervalue.ToString().IndexOf(".") + 3);
                //}
                //else
                //{
                //    awardpre = awardpervalue.ToString();
                //}

                //读取模板内容
                string text = string.Empty;
                text = System.IO.File.ReadAllText(Server.MapPath("Themes/Game/award.html"));
                JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext();
                context.TempData["title"]          = "抽奖活动详细信息";
                context.TempData["awardmodellist"] = modelList;
                context.TempData["sitecode"]       = strSiteCode;
                context.TempData["openid"]         = strOpenID;
                context.TempData["awardcount"]     = awardcount;
                //context.TempData["awardper"] = awardpre+ "%";
                context.TempData["footer"] = "奥琦微商易";
                JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text);
                t.Render(Response.Output);
            }
        }
Example #2
0
        /// <summary>
        /// 获取奖项列表
        /// </summary>
        void GetAwardList()
        {
            if (strSiteCode.Trim() != null && strSiteCode.Trim() != "" &&
                strActID.Trim() != null && strActID.Trim() != "")
            {
                List <LuckyAward> modelList   = new List <LuckyAward>();
                DataSet           modellistds = AwardDal.GetActAwardList(strActID, 0);
                foreach (DataRow row in modellistds.Tables[0].Rows)
                {
                    LuckyAward Awardmodel = DataConvert.DataRowToModel <LuckyAward>(row);
                    modelList.Add(Awardmodel);
                }

                int    awardcount = modellistds.Tables[0].Rows.Count;
                string awardtitle = string.Empty;
                string script = string.Empty;
                string peize = string.Empty;
                string peizeid = string.Empty;
                int    peizenum = 0; int frontpeizenum = 0; int beforpeizenum = 0;
                for (int i = 0; i < awardcount; i++)
                {
                    try
                    {
                        peizenum = Convert.ToInt32(modellistds.Tables[0].Rows[i]["AwardPro"].ToString());
                    }
                    catch (Exception)
                    {
                    }
                    peize   = modellistds.Tables[0].Rows[i]["Award"].ToString();
                    peizeid = modellistds.Tables[0].Rows[i]["ID"].ToString();
                    if (i == 0)
                    {
                        script += "\r\n                              if(randNum>=1&&randNum<=" + peizenum + ")" +
                                  "\r\n                              {prize=\"" + peize + "\";zjl = true;peizeid=\"" + peizeid + "\";}";
                    }
                    else
                    {
                        peizenum = beforpeizenum + peizenum;
                        script  += "\r\n                              if(randNum>=" + frontpeizenum + "&&randNum<=" + peizenum + ")" +
                                   "\r\n                              {prize=\"" + peize + "\";zjl = true;peizeid=\"" + peizeid + "\";}";
                    }
                    frontpeizenum = peizenum + 1;
                    beforpeizenum = peizenum;
                }

                //读取模板内容
                string text = string.Empty;
                text = System.IO.File.ReadAllText(Server.MapPath("Themes/Game/scratchcard.html"));
                JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext();
                context.TempData["title"]          = "刮刮卡活动详细信息";
                context.TempData["awardmodellist"] = modelList;
                context.TempData["sitecode"]       = strSiteCode;
                context.TempData["openid"]         = strOpenID;
                context.TempData["awardcount"]     = awardcount;
                context.TempData["actid"]          = strActID;
                context.TempData["script"]         = script;
                context.TempData["footer"]         = "奥琦微商易";
                JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text);
                t.Render(Response.Output);
            }
        }