private void LoadEditData()
        {
            IList <PredictionGame> lst = DomainManager.GetAll <PredictionGame>();

            if (lst != null)
            {
                lst = lst.Where(p => p.Active && p.IsCalculate == false).ToList();
                ddlPG.DataSource     = lst;
                ddlPG.DataValueField = "Id";
                ddlPG.DataTextField  = "PredictionGameName";
                ddlPG.DataBind();

                ddlPG.Items.Insert(0, new ListItem("[Rỗng]", "0"));
            }

            BizPredictionGameSettings biz = TNHelper.GetPredictionGameSettings();

            if (biz != null)
            {
                txtTime.Text        = biz.Timer.ToString();
                txtPlayNum.Text     = biz.NumPlayPerDay.ToString();
                radPauseYes.Checked = biz.IsPaused;
                radPauseNo.Checked  = !biz.IsPaused;

                txtMaxDisplayItem.Text = biz.MaxDisplayItem.ToString();

                ListItem item = ddlPG.Items.FindByValue(biz.PredictionGameID.ToString());
                if (item != null)
                {
                    item.Selected = true;
                }
            }
        }
        protected void rptQG_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item ||
                e.Item.ItemType == ListItemType.AlternatingItem)
            {
                PredictionGame qgame        = e.Item.DataItem as PredictionGame;
                LinkButton     lnkDelete    = e.Item.FindControl("lnkDelete") as LinkButton;
                LinkButton     lnkCalculate = e.Item.FindControl("lnkCalculate") as LinkButton;

                BizPredictionGameSettings biz = TNHelper.GetPredictionGameSettings();
                if (lnkDelete != null)
                {
                    if (biz != null && biz.PredictionGameID == qgame.Id)
                    {
                        lnkDelete.OnClientClick = "aler('Bạn khổng thế xóa bộ đề vì nó đang được cấu hình cho game dự đoán'); return false";
                    }
                }

                if (lnkCalculate != null)
                {
                    lnkCalculate.Visible = false;
                    if (biz != null && !qgame.IsCalculate)
                    {
                        lnkCalculate.Visible = true;
                    }
                }
            }
        }
        private void LoadData()
        {
            BizPredictionGameSettings setting = TNHelper.GetPredictionGameSettings();

            List <DataRow> lst = TNHelper.GetTopPredictionWinner(setting.MaxDisplayItem);

            rptList.DataSource = lst;
            rptList.DataBind();
        }
Example #4
0
        protected void rptQuestion_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item ||
                e.Item.ItemType == ListItemType.AlternatingItem)
            {
                string strId  = Page.RouteData.Values["id"] as string;
                int    gameid = 0;
                int.TryParse(strId, out gameid);

                Prediction question        = e.Item.DataItem as Prediction;
                Repeater   rptAnswer       = e.Item.FindControl("rptAnswer") as Repeater;
                LinkButton lnkDelete       = e.Item.FindControl("lnkDelete") as LinkButton;
                TextBox    txtQuestionName = e.Item.FindControl("txtQuestionName") as TextBox;
                TextBox    txtBonus        = e.Item.FindControl("txtBonus") as TextBox;

                BizPredictionGameSettings biz   = TNHelper.GetPredictionGameSettings();
                PredictionGame            pgame = DomainManager.GetObject <PredictionGame>(gameid);
                if ((biz.PredictionGameID == gameid) || (pgame != null && pgame.PredictionGameUsers.Count > 0))
                {
                    if (txtQuestionName != null)
                    {
                        txtQuestionName.Enabled = false;
                    }

                    if (txtBonus != null)
                    {
                        txtBonus.Enabled = false;
                    }
                }

                if (lnkDelete != null)
                {
                    if ((biz != null && biz.PredictionGameID == gameid))
                    {
                        lnkDelete.Enabled       = false;
                        lnkDelete.OnClientClick = "";
                    }
                    else
                    {
                        // những dự đoán có người chơi sẽ không đựoc xóa câu hỏi
                        if (pgame != null && pgame.PredictionGameUsers.Count > 0)
                        {
                            lnkDelete.Enabled       = false;
                            lnkDelete.OnClientClick = "";
                        }
                    }
                }

                if (rptAnswer != null)
                {
                    rptAnswer.DataSource = question.PredictionAnswerses;
                    rptAnswer.DataBind();
                }
            }
        }
Example #5
0
        protected void LoadEditData()
        {
            string strId = Page.RouteData.Values["id"] as string;
            int    id    = 0;

            int.TryParse(strId, out id);

            PredictionGame obj = DomainManager.GetObject <PredictionGame>(id);

            if (obj != null)
            {
                BizPredictionGameSettings biz = TNHelper.GetPredictionGameSettings();
                bool isPermit = true;
                if (biz != null)
                {
                    isPermit = biz.PredictionGameID == obj.Id ? false : true;
                    if (obj.PredictionGameUsers.Count > 0)
                    {
                        isPermit = false;
                    }
                }

                btnDelete.Enabled = isPermit;
                trAdd.Visible     = isPermit;

                if (obj.IsCalculate)
                {
                    btnDelete.Enabled = false;
                    btnSave.Enabled   = false;
                    trAdd.Visible     = false;
                }

                txtQGName.Text = obj.PredictionGameName;
                radYes.Checked = obj.Active;
                radNo.Checked  = !obj.Active;

                txtQGName.Enabled = isPermit;
                radYes.Enabled    = isPermit;
                radNo.Enabled     = isPermit;

                rptQuestion.DataSource = obj.Predictionses;
                rptQuestion.DataBind();
            }
            else if (!string.IsNullOrEmpty(strId))
            {
                Utils.ShowMessage(lblMsg, "Không tìm thấy dữ liệu của bộ đề bạn yêu cầu");
            }

            LoadDefaultData();
            btnDelete.Visible = (id > 0);
        }
Example #6
0
        protected void LoadData()
        {
            string key = string.Format("Prediction-{0}", Guid.NewGuid().ToString());

            hfCache.Value = key;

            // load setting
            BizPredictionGameSettings settings = TNHelper.GetPredictionGameSettings();

            if (settings != null && settings.Timer > 0)
            {
                hfTimer.Value = settings.Timer.ToString();
                pnlQuestion.Attributes["style"] = "display: none";
            }

            // check user already play this game
            User user = Utils.GetCurrentUser();
            PredictionGameUser pgu = TNHelper.GetPredictionGameUserByGameId(settings.PredictionGameID, user.Id);

            prePlayedInfo.Visible = false;

            if (pgu != null)
            {
                PredictionGameUser               = pgu;
                prePlayedInfo.Visible            = true;
                divContainer.Attributes["class"] = "invisible " + divContainer.Attributes["class"];
            }

            // load radom question and save to cache
            PredictionGame pgame = TNHelper.GetCurrentPredictionGame();

            if (pgame != null && pgame.Predictionses.Count > 0)
            {
                Prediction prediction = pgame.Predictionses[0] as Prediction;
                LoadAnswerList(prediction);
                litQuestion.Text = prediction.PredictionName;
                litInfo.Text     = string.Format("Bạn đang trả lời câu hỏi {0}/{1}", 1, pgame.Predictionses.Count);
                CMSCache.Insert(key, pgame);

                hfIndex.Value = "0";
                hfTotal.Value = pgame.Predictionses.Count.ToString();

                hfID.Value = prediction.Id.ToString();
            }
            else
            {
                Utils.ShowMessage(lblMsg, "Mời bạn quay lại sau, bạn vui lòng xem thông báo ở cột bên phải để biết thêm chi tiết.");
                divContainer.Visible  = false;
                prePlayedInfo.Visible = false;
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                BizPredictionGameSettings biz = new BizPredictionGameSettings();

                int playNum;
                int.TryParse(txtPlayNum.Text.Trim(), out playNum);
                biz.NumPlayPerDay = playNum;

                int time;
                int.TryParse(txtTime.Text.Trim(), out time);
                biz.Timer = time;

                int maxDisplayItem;
                int.TryParse(txtMaxDisplayItem.Text.Trim(), out maxDisplayItem);
                biz.MaxDisplayItem = maxDisplayItem;

                int gameid = 0;
                if (!string.IsNullOrEmpty(ddlPG.SelectedValue))
                {
                    int.TryParse(ddlPG.SelectedValue, out gameid);
                }

                biz.PredictionGameID = gameid;
                biz.IsPaused         = radPauseYes.Checked;

                Setting setting = DomainManager.GetObject <Setting>(3);
                if (setting == null)
                {
                    setting = new Setting();
                }

                setting.SettingValue = Utils.SerializeObject <BizPredictionGameSettings>(biz);

                if (setting.Id == 0)
                {
                    DomainManager.Insert(setting);
                }
                else
                {
                    DomainManager.Update(setting);
                }

                TNHelper.RemoveCaches();
                Utils.ShowMessage(lblMsg, "Cập nhập cấu hình game thử tài dự đoán thành công.");
            }
        }
Example #8
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            BizPredictionGameSettings biz = TNHelper.GetPredictionGameSettings();

            if (biz != null && biz.IsPaused)
            {
                Page.Response.Redirect("/", true);
            }

            // ko check số lần chơi trong ngày theo request mới
            //if (!TNHelper.IsValidToPlayPredictionGame())
            //{
            //    Utils.ShowMessage(lblMsg, "Bạn đã hết số lượt chơi game trong ngày. Mời bạn quay lại sau.");
            //    pnlUpdate.Visible = false;
            //    pnlStart.Visible = false;
            //}
        }
        protected void rptQG_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (string.Compare(e.CommandName, "delete", true) == 0)
            {
                int id = 0;
                int.TryParse(e.CommandArgument.ToString(), out id);

                PredictionGame            qgame = DomainManager.GetObject <PredictionGame>(id);
                BizPredictionGameSettings biz   = TNHelper.GetPredictionGameSettings();
                if (qgame != null)
                {
                    if (biz.PredictionGameID != qgame.Id)
                    {
                        DomainManager.Delete(qgame);
                        Utils.ShowMessage(lblMsgQG, "Xóa bộ đề dự đoán thành công");
                        LoadData();
                    }
                    else
                    {
                        Utils.ShowMessage(lblMsgQG, "Bộ đề này đang được sử dụng trong cấu hình game dự đoán. Bạn không thể xóa.");
                    }
                }
            }
            else if (string.Compare(e.CommandName, "calculate", true) == 0)
            {
                int id = 0;
                int.TryParse(e.CommandArgument.ToString(), out id);

                PredictionGame            qgame = DomainManager.GetObject <PredictionGame>(id);
                BizPredictionGameSettings biz   = TNHelper.GetPredictionGameSettings();
                if (qgame != null)// && qgame.IsUpdateAnswer)
                {
                    TNHelper.CalculatePredcitionGame(qgame);
                    TNHelper.RemoveRankingCaches();
                    Utils.ShowMessage(lblMsgQG, "Tính điểm cho người chơi thành chơi thành công");
                    LoadData();
                }
                else
                {
                    Utils.ShowMessage(lblMsgQG, "Bạn chưa cập nhật trả lời cho tất cả câu hỏi dự đoán. Hãy cập nhật tất cả câu trả lời trước khi tính điểm");
                }
            }
        }
Example #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BizBettingGameSettings betting = TNHelper.GetBettingGameSettings();
                if (betting != null)
                {
                    IsPausedBetting = betting.IsPaused;
                }

                BizQuestionGameSettings question = TNHelper.GetQuestionGameSettings();
                if (question != null)
                {
                    IsPausedQuestion = question.IsPaused;
                }


                BizPredictionGameSettings prediction = TNHelper.GetPredictionGameSettings();
                if (prediction != null)
                {
                    IsPausedPrediction = prediction.IsPaused;
                }
            }
        }
Example #11
0
        protected void rptPrediction_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item ||
                e.Item.ItemType == ListItemType.AlternatingItem)
            {
                BizPredictionGameSettings setting = TNHelper.GetPredictionGameSettings();
                PredictionGameUser        pu      = e.Item.DataItem as PredictionGameUser;
                Literal  litTotalQuestion         = e.Item.FindControl("litTotalQuestion") as Literal;
                Literal  litRightAnswer           = e.Item.FindControl("litRightAnswer") as Literal;
                Literal  litBonusPoint            = e.Item.FindControl("litBonusPoint") as Literal;
                Literal  litOnSiteTime            = e.Item.FindControl("litOnSiteTime") as Literal;
                Repeater rptPDetail      = e.Item.FindControl("rptPDetail") as Repeater;
                Literal  litPDetail      = e.Item.FindControl("litPDetail") as Literal;
                Panel    pnlPopupPDetail = e.Item.FindControl("pnlPopupPDetail") as Panel;

                if (litTotalQuestion != null)
                {
                    litTotalQuestion.Text = pu.PredictionGameUserDetailses.Count.ToString("N0");
                }

                if (litRightAnswer != null)
                {
                    if (pu.PredictionGame != null && pu.PredictionGame.IsCalculate)
                    {
                        int count = 0;
                        foreach (PredictionGameUserDetail detail in pu.PredictionGameUserDetailses)
                        {
                            if (detail.Prediction != null)
                            {
                                PredictionAnswer rightAnswer = detail.Prediction.PredictionAnswerses.Cast <PredictionAnswer>().Where(p => p.IsCorrectAnswer).FirstOrDefault();
                                if (rightAnswer != null && detail.PredictionAnswer != null && rightAnswer.Id == detail.PredictionAnswer.Id)
                                {
                                    count++;
                                }
                            }
                        }
                        litRightAnswer.Text = count.ToString("N0");
                    }
                    else
                    {
                        litRightAnswer.Text = "Đang cập nhật";
                    }
                }

                if (litBonusPoint != null)
                {
                    if (pu.PredictionGame != null && pu.PredictionGame.IsCalculate)
                    {
                        litBonusPoint.Text = pu.WinPoint.ToString("N0");
                    }
                    else
                    {
                        litBonusPoint.Text = "Đang cập nhật";
                    }
                }

                if (litOnSiteTime != null)
                {
                    litOnSiteTime.Text = string.Format("{0} phút {1} giây", (pu.Time / 60), (pu.Time % 60));
                }

                if (litPDetail != null)
                {
                    litPDetail.Text = string.Format("<a class='fancybox' href='#p{0}'>Chi tiết</a>", pu.Id);
                }

                if (rptPDetail != null && pu.PredictionGameUserDetailses != null)
                {
                    rptPDetail.DataSource     = pu.PredictionGameUserDetailses.Cast <PredictionGameUserDetail>();
                    rptPDetail.ItemDataBound += new RepeaterItemEventHandler(rptPDetail_ItemDataBound);
                    rptPDetail.DataBind();
                }
            }
        }