private void LoadEditData() { IList <QuestionGame> lst = DomainManager.GetAll <QuestionGame>(); if (lst != null) { lst = lst.Where(p => p.Active).ToList(); ddlQG.DataSource = lst; ddlQG.DataValueField = "Id"; ddlQG.DataTextField = "QuestionGameName"; ddlQG.DataBind(); ddlQG.Items.Insert(0, new ListItem("[Rỗng]", "0")); } BizQuestionGameSettings biz = TNHelper.GetQuestionGameSettings(); 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 = ddlQG.Items.FindByValue(biz.QuestionGameID.ToString()); if (item != null) { item.Selected = true; } } }
protected void rptQuestion_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Question question = e.Item.DataItem as Question; Repeater rptAnswer = e.Item.FindControl("rptAnswer") as Repeater; LinkButton lnkDelete = e.Item.FindControl("lnkDelete") as LinkButton; if (lnkDelete != null) { string strId = Page.RouteData.Values["id"] as string; int gameid = 0; int.TryParse(strId, out gameid); BizQuestionGameSettings biz = TNHelper.GetQuestionGameSettings(); if (biz != null && biz.QuestionGameID == gameid) { lnkDelete.Enabled = false; lnkDelete.OnClientClick = ""; } } if (rptAnswer != null) { rptAnswer.DataSource = question.Answerses; rptAnswer.ItemDataBound += new RepeaterItemEventHandler(rptAnswer_ItemDataBound); rptAnswer.DataBind(); } } }
protected void LoadData() { // load setting BizQuestionGameSettings settings = TNHelper.GetQuestionGameSettings(); if (settings != null && settings.Timer > 0) { hfTimer.Value = settings.Timer.ToString(); pnlQuestion.Attributes["style"] = "display: none"; } // load radom question and save to cache QuestionGame qgame = TNHelper.GetCurrentQuestionGame(); if (qgame != null && qgame.Questionses.Count > 0) { string key = string.Format("Question-{0}", Guid.NewGuid().ToString()); CMSCache.Insert(key, qgame); Question question = qgame.Questionses[0] as Question; LoadAnswerList(question); litQuestion.Text = question.QuestionName; litInfo.Text = string.Format("Bạn đang trả lời câu hỏi {0}/{1}", 1, qgame.Questionses.Count); hfIndex.Value = "0"; hfTotal.Value = qgame.Questionses.Count.ToString(); hfCache.Value = key; hfID.Value = question.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; } }
private void LoadData() { BizQuestionGameSettings setting = TNHelper.GetQuestionGameSettings(); List <DataRow> lst = TNHelper.GetTopQuestionGameWinner(setting.MaxDisplayItem); rptList.DataSource = lst; rptList.DataBind(); }
protected void rptQG_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { QuestionGame qgame = e.Item.DataItem as QuestionGame; LinkButton lnkDelete = e.Item.FindControl("lnkDelete") as LinkButton; if (lnkDelete != null) { BizQuestionGameSettings biz = TNHelper.GetQuestionGameSettings(); if (biz != null && biz.QuestionGameID == qgame.Id) { lnkDelete.OnClientClick = "aler('Bạn khổng thế xóa bộ đề vì nó đang được cấu hình cho game trả lời câu hỏi'); return false"; } } } }
protected override void OnInit(EventArgs e) { base.OnInit(e); BizQuestionGameSettings biz = TNHelper.GetQuestionGameSettings(); if (biz != null && biz.IsPaused) { Page.Response.Redirect("/", true); } if (!TNHelper.IsValidToPlayQuestionGame()) { Utils.ShowMessage(lblMsg, "Bạn đã hết số lượt chơi trong ngày. Mời bạn quay lại sau."); pnlUpdate.Visible = false; pnlStart.Visible = false; } }
protected void LoadEditData() { string strId = Page.RouteData.Values["id"] as string; int id = 0; int.TryParse(strId, out id); QuestionGame obj = DomainManager.GetObject <QuestionGame>(id); if (obj != null) { BizQuestionGameSettings biz = TNHelper.GetQuestionGameSettings(); bool isPermit = true; if (biz != null) { isPermit = biz.QuestionGameID == obj.Id ? false : true; } btnDelete.Enabled = isPermit; btnSave.Enabled = isPermit; trAdd.Visible = isPermit; txtQGName.Text = obj.QuestionGameName; radYes.Checked = obj.Active; radNo.Checked = !obj.Active; rptQuestion.DataSource = obj.Questionses; 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); }
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; } } }
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); QuestionGame qgame = DomainManager.GetObject <QuestionGame>(id); BizQuestionGameSettings biz = TNHelper.GetQuestionGameSettings(); if (qgame != null) { if (biz.QuestionGameID != qgame.Id) { DomainManager.Delete(qgame); Utils.ShowMessage(lblMsgQG, "Xóa bộ đề game trả lời câu hỏi thành công"); LoadData(); } else { Utils.ShowMessage(lblMsgQG, "Bộ đề này đang được sử dụng trong cấu hình game trả lời câu hỏi. Bạn không thể xóa bộ đề này."); } } } }
protected void rptQuestion_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { BizQuestionGameSettings setting = TNHelper.GetQuestionGameSettings(); QuestionUser qu = e.Item.DataItem as QuestionUser; 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 rptQDetail = e.Item.FindControl("rptQDetail") as Repeater; Literal litQDetail = e.Item.FindControl("litQDetail") as Literal; Panel pnlPopupQDetail = e.Item.FindControl("pnlPopupQDetail") as Panel; if (litTotalQuestion != null) { litTotalQuestion.Text = qu.QuestionUserDetailses.Count.ToString("N0"); } if (litRightAnswer != null) { int count = 0; foreach (QuestionUserDetail detail in qu.QuestionUserDetailses) { if (detail.Question != null && detail.Question.CorrectAnswer != null && detail.Answer != null && detail.Question.CorrectAnswer.Id == detail.Answer.Id) { count++; } } litRightAnswer.Text = count.ToString("N0"); } if (litBonusPoint != null) { litBonusPoint.Text = qu.WinPoint.ToString("N0"); } if (litOnSiteTime != null) { litOnSiteTime.Text = string.Format("{0} phút {1} giây", (qu.Time / 60), (qu.Time % 60)); } if (qu.QuestionGame != null && qu.QuestionGame.Id != setting.QuestionGameID) { if (litQDetail != null) { litQDetail.Text = string.Format("<a class='fancybox' href='#q{0}'>Chi tiết</a>", qu.Id); } if (rptQDetail != null && qu.QuestionUserDetailses != null) { rptQDetail.DataSource = qu.QuestionUserDetailses.Cast <QuestionUserDetail>(); rptQDetail.ItemDataBound += new RepeaterItemEventHandler(rptQDetail_ItemDataBound); rptQDetail.DataBind(); } } else { if (litQDetail != null) { litQDetail.Text = string.Format("<a href='javascript:void(0);' title='{0}'>Đang cập nhật</a>", "Bạn chỉ được xem chi tiết đáp án khi bộ đề câu hỏi này không còn được sử dụng ở trang trò chơi thử tài kiến thức"); } if (pnlPopupQDetail != null) { pnlPopupQDetail.Visible = false; } } } }