Пример #1
0
        private void LoadEditData()
        {
            BizSettings biz = TNHelper.GetSettings();

            if (biz != null)
            {
                txtSmtpServer.Text            = biz.SmtpServer;
                txtSmtpUsername.Text          = biz.SmtpUsername;
                txtSmtpPassword.Text          = biz.SmtpPassword;
                chkSmtpAuthentication.Checked = biz.SmtpAuthentication;
                txtSmtpPort.Text = biz.SmtpPort.ToString();

                txtDefaultSender.Text = biz.DefaultSender;
                txtSiteUrl.Text       = biz.SiteUrl;

                txtAcitveSubject.Text       = biz.ActiveEmailSubject;
                txtActiveEmailTemplate.Text = biz.ActiveEmailTemplate;

                txtResetSubject.Text = biz.ResetEmailSubject;
                txtRestBody.Text     = biz.ResetEmailTemplate;

                txtDefaultPoint.Text    = biz.DefaultPoint.ToString();
                txtHomeDisplayItem.Text = biz.HomeDisplayItem.ToString();
            }
        }
Пример #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                BizBettingGameSettings biz = new BizBettingGameSettings();

                biz.IsPaused    = radPauseYes.Checked;
                biz.AllowDelete = radAllowDeleteYes.Checked;

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

                Setting setting = DomainManager.GetObject <Setting>(4);

                if (setting == null)
                {
                    setting = new Setting();
                }

                setting.SettingValue = Utils.SerializeObject <BizBettingGameSettings>(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 phần tích thành công.");
            }
        }
Пример #3
0
        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;
                }
            }
        }
Пример #4
0
        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;
            }
        }
Пример #5
0
        protected void LoadData()
        {
            if (ContentType == null)
            {
                Utils.ShowMessage(lblMsg, "Dữ liệu cung cấp chưa đúng. Bạn kiểm tra lại");
                return;
            }

            litType.Text = ContentType.ContentTypeName;

            List <DM.Content> lst = TNHelper.GetContentsByType(ContentType.Id);
            int totalRow          = 0;

            if (lst != null)
            {
                totalRow = lst.Count;
                lst      = lst.OrderByDescending(p => p.Id)
                           .Skip((PageIndex - 1) * PageSize)
                           .Take(PageSize).ToList();
            }

            if (lst != null)
            {
                rptList.DataSource = lst;
                rptList.DataBind();
            }

            pagerList.ItemCount = totalRow;
            pagerList.Visible   = (pagerList.PageCount > 1);

            if (totalRow == 0)
            {
                Utils.ShowMessage(lblMsg, "Không tìm thấy dữ liệu thông báo.");
            }
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            int from = 0;

            int.TryParse(txtFrom.Text.Trim(), out from);

            int to = 0;

            int.TryParse(txtTo.Text.Trim(), out to);

            List <DataRow> lst      = TNHelper.SearchBettingGame(from, to);
            int            totalRow = 0;

            if (lst != null)
            {
                totalRow = lst.Count;
                lst      = lst.Skip((PageIndex - 1) * PageSize)
                           .Take(PageSize).ToList();
            }

            if (lst != null)
            {
                string msg = string.Format("{0} kết quả đựoc tìm thấy", totalRow);
                Utils.ShowMessage(litResult, msg);
            }

            pager.ItemCount      = totalRow;
            rptSearch.DataSource = lst;
            rptSearch.DataBind();
        }
Пример #7
0
        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;
                    }
                }
            }
        }
Пример #8
0
        protected void BindRepeater()
        {
            string strId = Page.RouteData.Values["id"] as string;
            int    id    = 0;

            int.TryParse(strId, out id);
            litUserId.Text = id.ToString();

            List <UserLog> lst      = TNHelper.GetUserLogs(id);
            int            totalRow = 0;

            if (lst != null)
            {
                totalRow = lst.Count;
                lst      = lst.Skip((PageIndex - 1) * PageSize)
                           .Take(PageSize).ToList();
            }

            rptList.DataSource = lst;
            rptList.DataBind();

            if (lst != null)
            {
                pager.ItemCount = totalRow;
            }
        }
Пример #9
0
        public static User GetCurrentUser()
        {
            User        user = null;
            HttpContext ctx  = HttpContext.Current;

            if (ctx != null)
            {
                string key = string.Format("{0}-SessionId:{1}", TNHelper.LoginKey, ctx.Session.SessionID);
                // user = ctx.Session[TNHelper.LoginKey] as User;
                user = CMSCache.Get(key) as User;
                if (user != null)
                {
                    return(user);
                }

                if (ctx.User != null && !string.IsNullOrEmpty(ctx.User.Identity.Name))
                {
                    user = TNHelper.GetUserByEmail(ctx.User.Identity.Name);
                    if (user != null)
                    {
                        CMSCache.Insert(key, user);
                    }
                    else
                    {
                        // ko tìm thấy thông tin user, redirect về tragn login
                        ctx.Response.Redirect("/dang-nhap?logout=true", true);
                    }
                }
            }

            return(user);
        }
Пример #10
0
        public static string ResolveMessage(string template, User user)
        {
            string result = template;

            if (user != null && !string.IsNullOrEmpty(template))
            {
                string activeLink = string.Format("/kich-hoat-tai-khoan/{0}", user.ActiveCode);
                string siteUrl    = TNHelper.GetSettings().SiteUrl;
                if (siteUrl.EndsWith("/"))
                {
                    siteUrl = siteUrl.Substring(0, siteUrl.Length - 1);
                }

                activeLink = string.Format("{0}{1}", siteUrl, activeLink);

                if (!string.IsNullOrEmpty(result))
                {
                    result = result.Replace("$SiteUrl$", TNHelper.GetSettings().SiteUrl);
                    result = result.Replace("$Username$", user.DisplayName);
                    result = result.Replace("$Password$", user.Password);
                    result = result.Replace("$ActiveLink$", activeLink);
                    result = result.Replace("$AcitveCode$", user.ActiveCode);
                }
            }
            return(result);
        }
Пример #11
0
        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();
                }
            }
        }
Пример #12
0
        public void BindNews()
        {
            string tmpId = Page.RouteData.Values["newsid"] as string;
            int    id    = 0;

            int.TryParse(tmpId, out id);

            New objNew = DomainManager.GetObject <New>(id);

            if (objNew != null)
            {
                litTitle.Text      = objNew.NewsTitle;
                litPostDate.Text   = objNew.CreatedDate.ToString(TNHelper.DateTimeFormat);
                litSummary.Text    = objNew.Summary;
                litNewContent.Text = objNew.NewsContent;

                imgPhoto.Visible = false;
                if (!string.IsNullOrEmpty(objNew.Photo))
                {
                    imgPhoto.ImageUrl = "/Userfiles/News/" + objNew.Photo;
                    imgPhoto.Visible  = true;
                }

                List <New> lst = TNHelper.GetRelateNew(DisplayRelateItem, objNew.CreatedDate);
                if (lst != null && lst.Count > 0)
                {
                    rptNews.DataSource = lst;
                    rptNews.DataBind();
                }
            }
        }
Пример #13
0
        public void BindNews()
        {
            pnlNewsTop.Visible  = false;
            pnlNewsList.Visible = false;

            List <New> lst = TNHelper.GetTopNews(DisplayItem);

            if (lst != null && lst.Count > 0)
            {
                if (!IsNewsList)
                {
                    rptNews.DataSource = lst;
                    rptNews.DataBind();
                    pnlNewsTop.Visible = true;
                }
                else
                {
                    rptNewsList.DataSource = lst;
                    rptNewsList.DataBind();
                    pnlNewsList.Visible = true;
                }
            }
            else
            {
                litMsg.Visible = true;
            }
        }
Пример #14
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string   strDate  = string.Format("{0}/{1}/{2}", Convert.ToInt32(ddlDay.SelectedValue).ToString("00"), Convert.ToInt32(ddlMonth.SelectedValue).ToString("00"), txtYear.Text);
            DateTime?birthday = Utils.GetDate(strDate);

            if (!birthday.HasValue)
            {
                Utils.ShowMessage(lblMsg, "Ngày sinh không hợp lệ. Hãy kiểm tra lại.");
                return;
            }

            User user = Utils.GetCurrentUser();

            if (Page.IsValid && user != null)
            {
                user = DomainManager.GetObject <User>(user.Id);
                if (user != null)
                {
                    user.FullName    = TextInputUtil.GetSafeInput(txtFullName.Text.Trim());
                    user.DisplayName = TextInputUtil.GetSafeInput(txtDisplayName.Text.Trim());
                    user.Phone       = TextInputUtil.GetSafeInput(txtPhone.Text);

                    if (string.IsNullOrEmpty(user.IDNumber))
                    {
                        if (txtIDNumber.Text.Trim().Length > 0)
                        {
                            bool valid = TNHelper.IsValidIdNumber(txtIDNumber.Text.Trim());
                            if (valid)
                            {
                                user.IDNumber = TextInputUtil.GetSafeInput(txtIDNumber.Text.Trim());
                            }
                            else
                            {
                                Utils.ShowMessage(lblMsg, string.Format("CMND \"{0}\" đã được đăng ký. Bạn hãy kiểm tra lại.", txtIDNumber.Text.Trim()));
                                return;
                            }
                        }
                    }

                    if (!user.Birthday.HasValue)
                    {
                        user.Birthday = birthday;
                    }

                    user.Address  = TextInputUtil.GetSafeInput(txtAddress.Text);
                    user.Province = ddlProvince.SelectedValue;

                    if (user.Id > 0)
                    {
                        DomainManager.Update(user);
                        Utils.ResetCurrentUser();
                        LoadUserData();
                        TNHelper.LogAction(LogType.UserLog, "Cập nhật thông tin tài khoản");

                        Utils.ShowMessage(lblMsg, "Thông tin tài khoản của bạn được cập nhật thành công");
                    }
                }
            }
        }
Пример #15
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string email    = string.Empty;
            string password = string.Empty;

            if (txtEmail != null)
            {
                email = txtEmail.Text;
            }

            if (txtPassword != null)
            {
                password = txtPassword.Text;
                password = Utils.EncodePassword(password);
            }

            User user = TNHelper.GetUserByEmail(email);

            if (user == null)
            {
                Utils.ShowMessage(lblMsg, "Địa chỉ email đăng nhập không tồn tại.");
            }
            else if (user != null && !user.Active)
            {
                Utils.ShowMessage(lblMsg, "Tài khoản của bạn chưa được kích hoạt. Liện hệ với admin để được hỗ trợ.");
            }
            else
            {
                if (string.Compare(user.Password, password, false) == 0)
                {
                    FormsAuthentication.SetAuthCookie(user.Email, chkSave.Checked);
                    Session[TNHelper.LoginKey] = user;
                    TNHelper.LogAction(LogType.UserLog, "Đăng nhập thành công");

                    string returnUrl = Page.Request.QueryString["returnurl"];
                    if (!string.IsNullOrEmpty(returnUrl))
                    {
                        returnUrl = Page.Server.UrlDecode(returnUrl);
                        Page.Response.Redirect(returnUrl, true);
                    }
                    else
                    {
                        if (user.IsAdmin)
                        {
                            Page.Response.Redirect("/admincp", true);
                        }
                        else
                        {
                            Page.Response.Redirect("/", true);
                        }
                    }
                }
                else
                {
                    Utils.ShowMessage(lblMsg, "Mật khẩu đăng nhập chưa đúng.");
                }
            }
        }
        private void LoadData()
        {
            BizBettingGameSettings setting = TNHelper.GetBettingGameSettings();

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

            rptList.DataSource = lst;
            rptList.DataBind();
        }
Пример #17
0
        public static bool SendEmail(string from, string to, string subject, string body)
        {
            string server         = TNHelper.GetSettings().SmtpServer;
            string username       = TNHelper.GetSettings().SmtpUsername;
            string password       = TNHelper.GetSettings().SmtpPassword;
            bool   authentication = TNHelper.GetSettings().SmtpAuthentication;
            int    port           = TNHelper.GetSettings().SmtpPort;

            MailMessage msg = new MailMessage();

            string[] addresses = to.Split(new string[] { ";", "," }, StringSplitOptions.RemoveEmptyEntries);
            msg.To.Clear();
            Regex regr = new Regex(@"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");

            foreach (string adr in addresses)
            {
                if (regr.IsMatch(adr.Trim()))
                {
                    msg.To.Add(adr);
                }
            }

            msg.From            = new MailAddress(from);
            msg.Subject         = subject;
            msg.Body            = body;
            msg.BodyEncoding    = Encoding.UTF8;
            msg.IsBodyHtml      = true;
            msg.SubjectEncoding = Encoding.UTF8;

            SmtpClient mailClient = new SmtpClient();

            if (authentication)
            {
                System.Net.NetworkCredential credential = new System.Net.NetworkCredential(username, password);
                mailClient.Credentials = credential;

                if (username.ToLower().Contains("gmail.com"))
                {
                    mailClient.EnableSsl = true;
                }
            }

            mailClient.Host = server;
            mailClient.Port = port;

            try
            {
                mailClient.Send(msg);
                return(true);
            }
            catch (Exception exp)
            {
                TNHelper.LogError(body, exp.ToString());
                return(false);
            }
        }
Пример #18
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();
                }
            }
        }
Пример #19
0
        public bool IsValidateBetting(int bettingId)
        {
            List <DM.Betting> lst = TNHelper.GetAllActiveBetting();

            if (lst != null)
            {
                return(lst.Exists(p => p.Id == bettingId));
            }

            return(false);
        }
Пример #20
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            BizBettingGameSettings biz = TNHelper.GetBettingGameSettings();

            if (biz != null && biz.IsPaused)
            {
                Page.Response.Redirect("/", true);
            }
        }
Пример #21
0
        protected bool Save(int bettingId, string team, int rateId, int point)
        {
            DM.Betting betting = DomainManager.GetObject <DM.Betting>(bettingId);
            if (betting == null)
            {
                msg = "";
                return(false);
            }

            DM.User user = Utils.GetCurrentUser();
            if (user != null)
            {
                user = DomainManager.GetObject <DM.User>(user.Id);
            }

            if (user == null || (user != null && point > user.Point))
            {
                msg = "Số điểm phải nhỏ hơn hoặc bằng số điểm hiện có của bạn.";
                return(false);
            }

            BettingUser bu = new BettingUser();

            bu.Betting     = betting;
            bu.BettingDate = DateTime.Now;
            bu.User        = user;

            BettingUserDetail bud = new BettingUserDetail();

            bud.BettingPoint = point;
            bud.BettingRate  = DomainManager.GetObject <BettingRate>(rateId);
            bud.BettingUser  = bu;

            string selected = betting.HomeTeam;

            if (string.Compare(team, "b", true) == 0)
            {
                selected = betting.VisitingTeam;
            }

            bud.SelectedTeam = selected;
            bu.BettingUserDetailses.Add(bud);

            DomainManager.Insert(bu);
            TNHelper.LogAction(LogType.BettingLog, string.Format("Chơi game thử tài phân tích trận đấu. Số điểm chơi: {0} điểm", point));

            user.Point -= point;
            DomainManager.Update(user);
            Utils.ResetCurrentUser();
            TNHelper.LogAction(LogType.BettingLog, "Cập nhật điểm số người chơi sau khi chơi game thử tài phân thích trận đấu");

            return(true);
        }
Пример #22
0
        private bool SendActiveEmail(User user, string code)
        {
            string subject = TNHelper.GetSettings().ActiveEmailSubject;
            string body    = TNHelper.GetSettings().ActiveEmailTemplate;
            string from    = TNHelper.GetSettings().DefaultSender;
            string to      = user.Email;

            subject = Utils.ResolveMessage(subject, user);
            body    = Utils.ResolveMessage(body, user);

            return(Utils.SendEmail(from, to, subject, body));
        }
Пример #23
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);
        }
Пример #24
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;
            }
        }
Пример #25
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            string email = txtEmail.Text.Trim();
            User   user  = TNHelper.GetUserByEmail(email);

            if (user == null)
            {
                Utils.ShowMessage(lblMsg, "Địa chỉ email không tồn tại.");
            }
            else if (user != null && !user.Active)
            {
                Utils.ShowMessage(lblMsg, "Tài khoản của bạn chưa được kích hoạt. Hãy kích hoạt tài của bạn trước khi gởi yêu cầu mật khẩu mới.");
            }
            else
            {
                user = DomainManager.GetObject <User>(user.Id);
                if (user != null)
                {
                    string newpass = Utils.GetNewPassword();
                    string oldpass = user.Password;
                    user.Password = newpass;

                    string from    = TNHelper.GetSettings().DefaultSender;
                    string to      = user.Email;
                    string subject = TNHelper.GetSettings().ResetEmailSubject;
                    subject = Utils.ResolveMessage(subject, user);

                    string content = TNHelper.GetSettings().ResetEmailTemplate;
                    content = Utils.ResolveMessage(content, user);

                    if (Utils.SendEmail(from, to, subject, content))
                    {
                        pnlReset.Visible = false;
                        user.Password    = Utils.EncodePassword(newpass);
                        DomainManager.Update(user);
                        Utils.ResetCurrentUser();
                        Utils.ShowMessage(lblMsg, string.Format("Mật khẩu mới đã được gởi vào địa chỉ email <b>{0}</b>", email));
                        TNHelper.LogAction(user, LogType.UserLog, "Reset mật khẩu");
                    }
                    else
                    {
                        user.Password = oldpass;
                        DomainManager.Update(user);
                        Utils.ResetCurrentUser();
                        Utils.ShowMessage(lblMsg, "Gởi mật khẩu không thành công. Bạn hãy thử lại sau.");
                        TNHelper.LogAction(user, LogType.UserLog, "Reset mật khẩu không thành công.");
                    }
                }
            }
        }
Пример #26
0
        private void LoadEditData()
        {
            BizBettingGameSettings biz = TNHelper.GetBettingGameSettings();

            if (biz != null)
            {
                radPauseYes.Checked = biz.IsPaused;
                radPauseNo.Checked  = !biz.IsPaused;

                radAllowDeleteYes.Checked = biz.AllowDelete;
                radAllowDeleteNo.Checked  = !biz.AllowDelete;

                txtMaxDisplayItem.Text = biz.MaxDisplayItem.ToString();
            }
        }
Пример #27
0
        protected void btnResetAccount_Click(object sender, EventArgs e)
        {
            User user = Utils.GetCurrentUser();

            if (user != null && TNHelper.ResetUser(user.Id))
            {
                TNHelper.LogAction(LogType.UserLog, "Khởi tạo thông tin tài khoản");
                litPoint.Text = TNHelper.GetSettings().DefaultPoint.ToString("N0");
                Utils.ShowMessage(lblMsgPoint, "Tài khoản của bạn đã được khởi tạo lại thành công.");
            }
            else
            {
                Utils.ShowMessage(lblMsgPoint, "Khởi tạo tài khoản không thành công.");
            }
        }
Пример #28
0
        private void LoadData()
        {
            List <Betting> lst = TNHelper.GetAllActiveBetting();

            if (lst != null && lst.Count > 0)
            {
                rptList.DataSource = lst;
                rptList.DataBind();
            }

            else
            {
                Utils.ShowMessage(lblMsg, "Không tìm thấy dữ liệu yêu cầu");
            }
        }
Пример #29
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                BizQuestionGameSettings biz = new BizQuestionGameSettings();

                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(ddlQG.SelectedValue))
                {
                    int.TryParse(ddlQG.SelectedValue, out gameid);
                }

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

                Setting setting = DomainManager.GetObject <Setting>(2);
                if (setting == null)
                {
                    throw new Exception("No question game settings");
                }

                setting.SettingValue = Utils.SerializeObject <BizQuestionGameSettings>(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 kiến thức thành công.");
            }
        }
Пример #30
0
 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";
             }
         }
     }
 }