コード例 #1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = base.OnCreateView(inflater, container, savedInstanceState);

            SetupToolbar(view, Resource.String.prefPasswordTitle);

            _preferences = new PreferenceWrapper(Context);
            _hasPassword = _preferences.PasswordProtected;

            _progressBar = view.FindViewById <ProgressBar>(Resource.Id.appBarProgressBar);

            _setPasswordButton        = view.FindViewById <MaterialButton>(Resource.Id.buttonSetPassword);
            _setPasswordButton.Click += OnSetPasswordButtonClick;

            _passwordText              = view.FindViewById <TextInputEditText>(Resource.Id.editPassword);
            _passwordText.TextChanged += delegate { UpdateSetPasswordButton(); };

            _passwordConfirmLayout = view.FindViewById <TextInputLayout>(Resource.Id.editPasswordConfirmLayout);
            _passwordConfirmText   = view.FindViewById <TextInputEditText>(Resource.Id.editPasswordConfirm);
            TextInputUtil.EnableAutoErrorClear(_passwordConfirmLayout);

            _passwordConfirmText.EditorAction += (_, e) =>
            {
                if (_setPasswordButton.Enabled && e.ActionId == ImeAction.Done)
                {
                    OnSetPasswordButtonClick(null, null);
                }
            };

            _cancelButton        = view.FindViewById <MaterialButton>(Resource.Id.buttonCancel);
            _cancelButton.Click += delegate { Dismiss(); };

            UpdateSetPasswordButton();
            return(view);
        }
コード例 #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            foreach (RepeaterItem item in rptList.Items)
            {
                HiddenField hfContentID = item.FindControl("hfContentID") as HiddenField;
                TextBox     txtContent  = item.FindControl("txtContent") as TextBox;
                CheckBox    chkActive   = item.FindControl("chkActive") as CheckBox;

                int id = 0;
                if (hfContentID != null)
                {
                    int.TryParse(hfContentID.Value, out id);
                }

                DM.Content content = DomainManager.GetObject <DM.Content>(id);
                if (content != null)
                {
                    if (txtContent != null)
                    {
                        content.ContentText = TextInputUtil.GetSafeInput(txtContent.Text);
                    }

                    if (chkActive != null)
                    {
                        content.Active = chkActive.Checked;
                    }

                    DomainManager.Update(content);
                }
            }
            Utils.ShowMessage(lblMsg, "Cập nhật dữ liệu thành công");
        }
コード例 #3
0
ファイル: Profile.ascx.cs プロジェクト: wefasdfaew2/tngames
        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");
                    }
                }
            }
        }
コード例 #4
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = base.OnCreateView(inflater, container, savedInstanceState);

            SetupToolbar(view, Resource.String.rename);

            _issuerLayout   = view.FindViewById <TextInputLayout>(Resource.Id.editIssuerLayout);
            _issuerText     = view.FindViewById <TextInputEditText>(Resource.Id.editIssuer);
            _usernameLayout = view.FindViewById <TextInputLayout>(Resource.Id.editUsernameLayout);
            _usernameText   = view.FindViewById <TextInputEditText>(Resource.Id.editUsername);

            _issuerText.Append(_issuer);

            if (_username != null)
            {
                _usernameText.Append(_username);
            }

            _issuerLayout.CounterMaxLength = Authenticator.IssuerMaxLength;
            _issuerText.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(Authenticator.IssuerMaxLength) });
            _usernameLayout.CounterMaxLength = Authenticator.UsernameMaxLength;
            _usernameText.SetFilters(
                new IInputFilter[] { new InputFilterLengthFilter(Authenticator.UsernameMaxLength) });

            TextInputUtil.EnableAutoErrorClear(_issuerLayout);

            var cancelButton = view.FindViewById <MaterialButton>(Resource.Id.buttonCancel);

            cancelButton.Click += delegate
            {
                Dismiss();
            };

            var renameButton = view.FindViewById <MaterialButton>(Resource.Id.buttonRename);

            renameButton.Click += delegate
            {
                var issuer = _issuerText.Text.Trim();
                if (issuer == "")
                {
                    _issuerLayout.Error = GetString(Resource.String.noIssuer);
                    return;
                }

                var args = new RenameEventArgs(_position, issuer, _usernameText.Text);
                RenameClicked?.Invoke(this, args);
                Dismiss();
            };

            _usernameText.EditorAction += (_, args) =>
            {
                if (args.ActionId == ImeAction.Done)
                {
                    renameButton.PerformClick();
                }
            };

            return(view);
        }
コード例 #5
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activityUnlock);
            Window.SetSoftInputMode(SoftInput.AdjustPan);

            _preferences = new PreferenceWrapper(this);

            SetResult(Result.Canceled);

            _passwordLayout = FindViewById <TextInputLayout>(Resource.Id.editPasswordLayout);
            _passwordText   = FindViewById <TextInputEditText>(Resource.Id.editPassword);
            TextInputUtil.EnableAutoErrorClear(_passwordLayout);

            _passwordText.EditorAction += (_, e) =>
            {
                if (e.ActionId == ImeAction.Done)
                {
                    OnUnlockButtonClick(null, null);
                }
            };

            _passwordText.TextChanged += delegate
            {
                _unlockButton.Enabled = _passwordText.Text != "";
            };

            _unlockButton        = FindViewById <MaterialButton>(Resource.Id.buttonUnlock);
            _unlockButton.Click += OnUnlockButtonClick;

            var canUseBiometrics = false;

            if (_preferences.AllowBiometrics)
            {
                var biometricManager = BiometricManager.From(this);
                canUseBiometrics = biometricManager.CanAuthenticate() == BiometricManager.BiometricSuccess;
            }

            _useBiometricsButton         = FindViewById <MaterialButton>(Resource.Id.buttonUseBiometrics);
            _useBiometricsButton.Enabled = canUseBiometrics;
            _useBiometricsButton.Click  += delegate
            {
                ShowBiometricPrompt();
            };

            if (canUseBiometrics)
            {
                ShowBiometricPrompt();
            }
            else
            {
                await FocusPasswordText();
            }
        }
コード例 #6
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = base.OnCreateView(inflater, container, savedInstanceState);

            SetupToolbar(view, Resource.String.unlock);

            _preferences = new PreferenceWrapper(Context);
            _progressBar = view.FindViewById <ProgressBar>(Resource.Id.appBarProgressBar);

            _passwordLayout = view.FindViewById <TextInputLayout>(Resource.Id.editPasswordLayout);
            _passwordText   = view.FindViewById <TextInputEditText>(Resource.Id.editPassword);
            TextInputUtil.EnableAutoErrorClear(_passwordLayout);

            _passwordText.EditorAction += (_, e) =>
            {
                if (e.ActionId == ImeAction.Done)
                {
                    UnlockAttempted?.Invoke(this, _passwordText.Text);
                }
            };

            _unlockButton        = view.FindViewById <MaterialButton>(Resource.Id.buttonUnlock);
            _unlockButton.Click += delegate
            {
                UnlockAttempted?.Invoke(this, _passwordText.Text);
            };

            if (_preferences.AllowBiometrics)
            {
                var biometricManager = BiometricManager.From(Context);
                _canUseBiometrics = biometricManager.CanAuthenticate(BiometricManager.Authenticators.BiometricStrong) ==
                                    BiometricManager.BiometricSuccess;
            }

            _useBiometricsButton         = view.FindViewById <MaterialButton>(Resource.Id.buttonUseBiometrics);
            _useBiometricsButton.Enabled = _canUseBiometrics;
            _useBiometricsButton.Click  += delegate
            {
                ShowBiometricPrompt();
            };

            if (_canUseBiometrics)
            {
                ShowBiometricPrompt();
            }
            else
            {
                FocusPasswordText();
            }

            return(view);
        }
コード例 #7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Window.SetSoftInputMode(SoftInput.AdjustResize);
            SetResult(Result.Canceled);

            _preferences       = new PreferenceWrapper(this);
            _unlockLayout      = FindViewById <LinearLayout>(Resource.Id.layoutUnlock);
            _progressIndicator = FindViewById <LinearProgressIndicator>(Resource.Id.progressIndicator);

            _passwordLayout = FindViewById <TextInputLayout>(Resource.Id.editPasswordLayout);
            _passwordText   = FindViewById <TextInputEditText>(Resource.Id.editPassword);
            TextInputUtil.EnableAutoErrorClear(_passwordLayout);

            _passwordText.EditorAction += (_, e) =>
            {
                if (e.ActionId == ImeAction.Done)
                {
                    OnUnlockButtonClick(null, null);
                }
            };

            _unlockButton        = FindViewById <MaterialButton>(Resource.Id.buttonUnlock);
            _unlockButton.Click += OnUnlockButtonClick;

            if (_preferences.AllowBiometrics)
            {
                var biometricManager = BiometricManager.From(this);
                _canUseBiometrics = biometricManager.CanAuthenticate(BiometricManager.Authenticators.BiometricStrong) == BiometricManager.BiometricSuccess;
            }

            _useBiometricsButton         = FindViewById <MaterialButton>(Resource.Id.buttonUseBiometrics);
            _useBiometricsButton.Enabled = _canUseBiometrics;
            _useBiometricsButton.Click  += delegate
            {
                ShowBiometricPrompt();
            };

            if (_canUseBiometrics)
            {
                ShowBiometricPrompt();
            }
            else
            {
                FocusPasswordText();
            }
        }
コード例 #8
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                DM.Content content = new DM.Content();
                content.ContentText = TextInputUtil.GetSafeInput(txtContent.Text);
                content.Active      = radYes.Checked;
                content.ContentType = ContentType;
                DomainManager.Insert(content);

                txtContent.Text = string.Empty;
                radYes.Checked  = true;
                radNo.Checked   = false;

                LoadData();
                Utils.ShowMessage(lblMsg, "Lưu banner thành công");
            }
        }
コード例 #9
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            int point = 0;

            int.TryParse(txtBonus.Text.Trim(), out point);

            Prediction question = new Prediction();

            question.PredictionName = TextInputUtil.GetSafeInput(txtQuestion.Text);
            question.BonusPoint     = point;

            List <PredictionAnswer> lstAnswer = GetAnswerList(rptAnswers);

            if (lstAnswer != null)
            {
                foreach (PredictionAnswer answer in lstAnswer)
                {
                    answer.Prediction = question;
                    question.PredictionAnswerses.Add(answer);
                }
            }

            List <Prediction> lst = GetQuestionList();

            if (lst != null)
            {
                lst.Add(question);
            }

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

            txtQuestion.Text = string.Empty;
            txtBonus.Text    = string.Empty;
            LoadDefaultData();
        }
コード例 #10
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            #region Valid data

            if (txtQGName.Text.Trim().Length == 0)
            {
                Utils.ShowMessage(lblMsg, "Tên bộ đè không thể rỗng");
                return;
            }

            List <Prediction> lstQuestion = GetQuestionList();
            if (lstQuestion == null || (lstQuestion != null && lstQuestion.Count == 0))
            {
                Utils.ShowMessage(lblMsg, "Bạn chưa nhập câu hỏi");
                return;
            }

            #endregion

            if (Page.IsValid)
            {
                string strId = Page.RouteData.Values["id"] as string;
                int    id    = 0;
                int.TryParse(strId, out id);

                PredictionGame qgame = DomainManager.GetObject <PredictionGame>(id);
                if (qgame == null)
                {
                    qgame             = new PredictionGame();
                    qgame.CreatedDate = DateTime.Now;
                    qgame.User        = Utils.GetCurrentUser();
                }

                qgame.PredictionGameName = TextInputUtil.GetSafeInput(txtQGName.Text);
                qgame.Active             = radYes.Checked;
                qgame.IsUpdateAnswer     = CheckUpdateAnswer(lstQuestion);
                if (qgame.Id > 0)
                {
                    DomainManager.Update(qgame);
                }
                else
                {
                    DomainManager.Insert(qgame);
                }

                if (lstQuestion != null)
                {
                    for (int i = 0; i < lstQuestion.Count; i++)
                    {
                        Prediction question = lstQuestion[i];
                        if (question.Id == 0)
                        {
                            // Prediction newPrediction = SavePrediction(question);
                            DomainManager.Insert(question);
                            question.PredictionGame = qgame;
                            qgame.Predictionses.Add(question);
                        }
                        else // update data
                        {
                            Prediction tmpQ = qgame.Predictionses.Cast <Prediction>().Where(p => p.Id == question.Id).FirstOrDefault();
                            if (tmpQ != null)
                            {
                                tmpQ.PredictionName = question.PredictionName;
                                tmpQ.BonusPoint     = question.BonusPoint;
                                foreach (PredictionAnswer ans in question.PredictionAnswerses.Cast <PredictionAnswer>())
                                {
                                    PredictionAnswer tmpA = tmpQ.PredictionAnswerses.Cast <PredictionAnswer>().Where(p => p.Id == ans.Id).FirstOrDefault();
                                    if (tmpA != null)
                                    {
                                        tmpA.AnswerText      = ans.AnswerText;
                                        tmpA.IsCorrectAnswer = ans.IsCorrectAnswer;
                                    }
                                }
                            }
                        }
                    }
                }

                string msg = string.Empty;
                if (qgame.Id > 0)
                {
                    DomainManager.Update(qgame);
                    msg = Page.Server.UrlEncode("Cập nhật bộ đề dự đoán thành công");
                }
                else
                {
                    DomainManager.Insert(qgame);
                    msg = Page.Server.UrlEncode("Thêm bộ dự đoán thành công");
                }

                Page.Response.Redirect(string.Format("/admincp/prediction-list?msg={0}", msg), true);
            }
        }
コード例 #11
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            #region Valid data

            if (txtName.Text.Trim().Length == 0)
            {
                Utils.ShowMessage(lblMsg, "Tên dự đoán không thể rỗng");
                return;
            }

            if (txtHomeTeam.Text.Trim().Length == 0)
            {
                Utils.ShowMessage(lblMsg, "Tên đội A không thể rỗng");
                return;
            }

            if (txtVisitingTeam.Text.Trim().Length == 0)
            {
                Utils.ShowMessage(lblMsg, "Tên đội B không thể rỗng");
                return;
            }

            List <BettingRate> lst = GetRateList();
            if (lst == null || (lst != null && lst.Count == 0))
            {
                Utils.ShowMessage(lblMsg, "Bạn chưa nhập tỷ lệ");
                return;
            }

            if (lst != null)
            {
                BettingRate rate = lst[0];
                if (rate.HomeRate == 0 && rate.VisitingRate == 0)
                {
                    Utils.ShowMessage(lblMsg, "Bạn chưa nhập tỷ lệ");
                    return;
                }
            }

            DateTime?playDate = GetDate(txtPlayDate.Text.Trim(), txtPlayTime.Text.Trim());
            if (txtPlayDate.Text.Trim().Length > 0 && !playDate.HasValue)
            {
                Utils.ShowMessage(lblMsg, "Ngày thi đấu không hợp lệ");
                return;
            }

            DateTime?startDate = GetDate(txtStartDate.Text.Trim());
            if (txtStartDate.Text.Trim().Length > 0 && !startDate.HasValue)
            {
                Utils.ShowMessage(lblMsg, "Ngày bắt đầu không hợp lệ");
                return;
            }

            DateTime?endDate = GetDate(txtEndDate.Text.Trim());
            if (txtEndDate.Text.Trim().Length > 0 && !endDate.HasValue)
            {
                Utils.ShowMessage(lblMsg, "Ngày kết thúc không hợp lệ");
                return;
            }

            if (startDate.HasValue && endDate.HasValue && startDate.Value > endDate.Value)
            {
                Utils.ShowMessage(lblMsg, "Ngày bắt đầu phải nhỏ hơn ngày kết thúc");
                return;
            }

            #endregion

            if (Page.IsValid)
            {
                string strId = Page.RouteData.Values["id"] as string;
                int    id    = 0;
                int.TryParse(strId, out id);


                Betting obj = DomainManager.GetObject <Betting>(id);
                if (obj == null)
                {
                    obj = new Betting();
                }

                obj.BettingName  = TextInputUtil.GetSafeInput(txtName.Text);
                obj.Description  = TextInputUtil.GetSafeInput(txtDesc.Text);
                obj.HomeTeam     = TextInputUtil.GetSafeInput(txtHomeTeam.Text);
                obj.VisitingTeam = TextInputUtil.GetSafeInput(txtVisitingTeam.Text);

                int homescore = 0;
                int.TryParse(txtHomeGoalScore.Text.Trim(), out homescore);
                obj.HomeGoalScore = homescore;

                int visitingscore = 0;
                int.TryParse(txtVisitingGoalScore.Text.Trim(), out visitingscore);
                obj.VisitingGoalScore = visitingscore;

                obj.PlayDate  = playDate;
                obj.StartDate = startDate;

                if (endDate.HasValue)
                {
                    endDate = new DateTime(endDate.Value.Year, endDate.Value.Month, endDate.Value.Day, 23, 59, 59);
                }
                obj.EndDate = endDate;

                obj.Active = radYes.Checked;

                #region betting rate

                obj.BettingRateses.Clear();
                foreach (BettingRate br in lst)
                {
                    BettingRate rate = new BettingRate();
                    rate.HomeRate     = br.HomeRate;
                    rate.VisitingRate = br.VisitingRate;
                    rate.Order        = br.Order;
                    rate.Betting      = obj;
                    obj.BettingRateses.Add(rate);
                }

                #endregion

                string msg = string.Empty;
                if (obj.Id > 0)
                {
                    obj.ModifiedDate = DateTime.Now;
                    DomainManager.Update(obj);
                    msg = Page.Server.UrlEncode("Cập nhật thông tin thành công");
                }
                else
                {
                    obj.CreatedDate = DateTime.Now;
                    DomainManager.Insert(obj);
                    msg = Page.Server.UrlEncode("Thêm thông tin thành công");
                }

                Page.Response.Redirect(string.Format("/admincp/betting-list?msg={0}", msg), true);
            }
        }
コード例 #12
0
ファイル: Settings.ascx.cs プロジェクト: wefasdfaew2/tngames
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                BizSettings biz = TNHelper.GetSettings();
                if (biz == null)
                {
                    biz = new BizSettings();
                }

                biz.SmtpServer   = TextInputUtil.GetSafeInput(txtSmtpServer.Text);
                biz.SmtpUsername = TextInputUtil.GetSafeInput(txtSmtpUsername.Text);
                if (txtSmtpPassword.Text.Trim().Length > 0)
                {
                    biz.SmtpPassword = TextInputUtil.GetSafeInput(txtSmtpPassword.Text);
                }
                biz.SmtpAuthentication = chkSmtpAuthentication.Checked;

                int port;
                int.TryParse(txtSmtpPort.Text.Trim(), out port);
                if (port == 0)
                {
                    port = 80;
                }
                biz.SmtpPort = port;

                biz.DefaultSender       = TextInputUtil.GetSafeInput(txtDefaultSender.Text);
                biz.SiteUrl             = TextInputUtil.GetSafeInput(txtSiteUrl.Text.Trim());
                biz.ActiveEmailSubject  = TextInputUtil.GetSafeInput(txtAcitveSubject.Text);
                biz.ActiveEmailTemplate = TextInputUtil.GetSafeInput(txtActiveEmailTemplate.Text);

                biz.ResetEmailSubject  = TextInputUtil.GetSafeInput(txtResetSubject.Text);
                biz.ResetEmailTemplate = TextInputUtil.GetSafeInput(txtRestBody.Text);

                int point;
                int.TryParse(txtDefaultPoint.Text.Trim(), out point);
                if (point == 0)
                {
                    point = new BizSettings().DefaultPoint;
                }
                biz.DefaultPoint = point;


                int homeDisplayItem;
                int.TryParse(txtHomeDisplayItem.Text.Trim(), out homeDisplayItem);
                if (homeDisplayItem == 0)
                {
                    homeDisplayItem = new BizSettings().HomeDisplayItem;
                }
                biz.HomeDisplayItem = homeDisplayItem;

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

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

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

                TNHelper.RemoveCaches();
                Utils.ShowMessage(lblMsg, "Cập nhật thông tin cấu hình thành công.");
            }
        }
コード例 #13
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strId = Page.RouteData.Values["id"] as string;
            int    id    = 0;

            int.TryParse(strId, out id);

            #region Valid data

            string email = TextInputUtil.GetSafeInput(txtEmail.Text);
            User   user  = TNHelper.GetUserByEmail(email);
            if (user != null && user.Id != id)
            {
                Utils.ShowMessage(lblMsg, string.Format("Địa chỉ email <b>{0}</b> đã được sử dụng bởi <b>{1}</b>", email, user.FullName));
                return;
            }

            if (string.Compare(txtPassword.Text, txtRetypePass.Text, false) != 0)
            {
                Utils.ShowMessage(lblMsg, "Mật khẩu chưa trùng khớp. Hãy kiểm tra lại");
                return;
            }

            DateTime?birthday = null;
            if (!string.IsNullOrEmpty(ddlDay.SelectedValue) && !string.IsNullOrEmpty(ddlMonth.SelectedValue) && !string.IsNullOrEmpty(txtYear.Text))
            {
                string strDate = string.Format("{0}/{1}/{2}", Convert.ToInt32(ddlDay.SelectedValue).ToString("00"), Convert.ToInt32(ddlMonth.SelectedValue).ToString("00"), txtYear.Text);
                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;
                }
            }

            #endregion

            if (Page.IsValid)
            {
                User obj = DomainManager.GetObject <User>(id);
                if (obj == null)
                {
                    obj = new User();
                }

                obj.DisplayName = TextInputUtil.GetSafeInput(txtDisplayName.Text.Trim());
                obj.FullName    = TextInputUtil.GetSafeInput(txtFullName.Text.Trim());
                obj.Email       = TextInputUtil.GetSafeInput(txtEmail.Text.Trim());
                obj.Address     = TextInputUtil.GetSafeInput(txtAddress.Text.Trim());
                obj.Province    = TextInputUtil.GetSafeInput(ddlProvince.SelectedValue);
                obj.Phone       = TextInputUtil.GetSafeInput(txtPoint.Text);
                obj.IDNumber    = TextInputUtil.GetSafeInput(txtIDNumber.Text);
                obj.Active      = radYes.Checked;
                obj.Birthday    = birthday;
                obj.IsAdmin     = radIsAdmin.Checked;

                if (obj.Active)
                {
                    obj.ActiveCode = string.Empty;
                }

                if (!string.IsNullOrEmpty(txtPassword.Text))
                {
                    string pass = TextInputUtil.GetSafeInput(txtPassword.Text.Trim());
                    obj.Password = Utils.EncodePassword(pass);
                }

                if (obj.Id > 0)
                {
                    DomainManager.Update(obj);
                }
                else
                {
                    obj.RegisterDate = DateTime.Now;
                    obj.ActiveCode   = string.Empty;
                    DomainManager.Insert(obj);
                }

                Page.Response.Redirect("/admincp/user-list");
            }
        }
コード例 #14
0
ファイル: NewsEdit.ascx.cs プロジェクト: wefasdfaew2/tngames
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string strId = Page.RouteData.Values["id"] as string;
                int    id    = 0;
                int.TryParse(strId, out id);

                New obj = DomainManager.GetObject <New>(id);
                if (obj == null)
                {
                    obj = new New();
                }

                obj.NewsTitle   = TextInputUtil.GetSafeInput(txtTitle.Text.Trim());
                obj.NewsAlias   = TextInputUtil.GetSafeInput(txtAlias.Text.Trim());
                obj.Summary     = TextInputUtil.GetSafeInput(txtSummary.Text.Trim());
                obj.NewsContent = TextInputUtil.GetSafeInput(txtContent.Text);
                obj.Active      = true;

                int catId = 0;
                int.TryParse(ddlCategories.SelectedValue, out catId);
                obj.Category = DomainManager.GetObject <Category>(catId);

                if (obj.Id > 0)
                {
                    obj.ModifedDate = DateTime.Now;
                    DomainManager.Update(obj);
                }
                else
                {
                    obj.NewsAlias   = Utils.GenerateAlias(obj.NewsTitle, true);
                    obj.CreatedDate = DateTime.Now;
                    obj.ModifedDate = DateTime.Now;
                    DomainManager.Insert(obj);
                }

                if (fuPhoto.HasFile)
                {
                    string path = string.Empty;
                    // delete exist photo
                    if (!string.IsNullOrEmpty(obj.Photo))
                    {
                        path = Page.Server.MapPath(string.Format("~/Userfiles/News/{0}", obj.Photo));
                        if (File.Exists(path))
                        {
                            try { File.Delete(path); }
                            catch { }
                        }
                    }


                    string photoName = string.Format("{0}{1}", obj.Id, Path.GetExtension(fuPhoto.FileName));
                    path = Page.Server.MapPath(string.Format("~/Userfiles/News/{0}", photoName));
                    fuPhoto.SaveAs(path);

                    obj.Photo = photoName;
                    DomainManager.Update(obj);
                }

                string msg = Page.Server.UrlEncode("Lưu dữ liệu thành công");
                Page.Response.Redirect(string.Format("/admincp/news-list?msg={0}", msg), true);
            }
        }
コード例 #15
0
ファイル: Register.ascx.cs プロジェクト: wefasdfaew2/tngames
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            #region Valid data

            string captcha = Session[TNHelper.CaptchaKey] as string;
            if (string.Compare(txtCaptcha.Text, captcha, false) != 0)
            {
                Utils.ShowMessage(lblMsg, "Mã captcha chưa đúng. Bạn hãy kiểm tra lại.");
                return;
            }

            string email = TextInputUtil.GetSafeInput(txtEmail.Text.Trim());
            if (!TNHelper.IsValidRegisterEmail(email))
            {
                Utils.ShowMessage(lblMsg, string.Format("Địa chỉ email <b>{0}</b> đã được sử dụng.", email));
                return;
            }

            if (string.Compare(txtPassword.Text, txtRetypePass.Text, false) != 0)
            {
                Utils.ShowMessage(lblMsg, "Mật khẩu chưa trùng khớp. Hãy kiểm tra lại");
                return;
            }

            #endregion

            if (Page.IsValid)
            {
                User user = new User();
                user.DisplayName  = TextInputUtil.GetSafeInput(txtDisplayName.Text);
                user.FullName     = TextInputUtil.GetSafeInput(txtFullName.Text);
                user.Email        = email;
                user.Password     = Utils.EncodePassword(txtPassword.Text);
                user.RegisterDate = DateTime.Now;
                string code = Utils.GenerateNewActiveCode();
                user.ActiveCode = code;
                user.Point      = TNHelper.GetSettings().DefaultPoint;

                if (user.Point == 0)
                {
                    TNHelper.LogError("Không lấy được điểm khởi tạo. Khởi tạo lại điểm mặc định.", "Error get GetSettings object");
                    user.Point = new BizSettings().DefaultPoint;
                }


                if (DomainManager.Insert(user))
                {
                    bool isSent = SendActiveEmail(user, code);
                    if (isSent)
                    {
                        Utils.ShowMessage(lblMsg, string.Format("Đăng ký tài khoản thành công. Email kích hoạt đã đựoc gởi tới địa chỉ email <b>{0}</b> của bạn.", user.Email));
                    }
                    else
                    {
                        Utils.ShowMessage(lblMsg, string.Format("Gởi email kích hoạt không thành công. Bạn liên hệ admin để kích hoạt tài khoản.", user.Email));
                        lblMsg.ForeColor = Color.Red;
                    }

                    TNHelper.LogAction(user, LogType.UserLog, "Đăng ký tài khoản");
                    pnlRegister.Visible = false;
                }
                else
                {
                    Utils.ShowMessage(lblMsg, "Đăng ký tài khoản không thành công. Bạn hãy thử lại");
                }
            }
        }