Example #1
0
 public FrmLogin()
 {
     InitializeComponent();
     eu   = new EUser();
     ea   = new EAccount();
     ubol = new UserBOL();
 }
Example #2
0
        public static ResultBOL <int> InsertOrUpdate(UserBOL user)
        {
            string stored = "sp_Users_Insert_Update";
            var    result = DataAccessHelpers.ExecuteStored(stored, user.GetParameters());

            return(result);
        }
Example #3
0
 public static void SaveLoggedInfo(UserBOL user)
 {
     try
     {
         var session = HttpContext.Current.Session;
         session["LoggedId"]       = user.Id;
         session["LoggedUsername"] = user.Username;
     }
     catch (Exception ex)
     {
         LogHelpers.WriteError("[Utilities][SaveLoggedInfo] Exception: " + ex.ToString());
     }
 }
Example #4
0
        private void InsertOrUpdateUserProcess()
        {
            string tag = __tag + "[InsertOrUpdateUserProcess]";

            LogHelpers.WriteStatus(tag, "Start...");

            try
            {
                UserBOL user = new UserBOL()
                {
                    Id           = string.IsNullOrEmpty(hfId.Value) ? 0 : int.Parse(hfId.Value),
                    FirstName_VN = tbxFirstNameVN.Text,
                    FirstName_EN = tbxFirstNameEN.Text,
                    LastName_VN  = tbxLastNameVN.Text,
                    LastName_EN  = tbxLastNameEN.Text,
                    Username     = tbxUsername.Text,
                    Password     = Utilities.EncryptPassword(tbxPassword.Text),
                    Email        = tbxEmail.Text,
                    Phone        = tbxPhone.Text,
                    DateOfBirth  = Utilities.ToDateTime(tbxDateOfBirth.Text),
                    Gender       = ddlGender.SelectedValue == "0" ? "Nam" : "Nữ",
                    InsertDate   = DateTime.Now,
                    UpdatedDate  = DateTime.Now
                };

                var result = UsersDAL.InsertOrUpdate(user);
                if (result.Code < 0)
                {
                    lbError.InnerText = result.ErrorMessage;
                    lbError.Visible   = true;

                    return;
                }

                Response.Redirect("~/Introductions.aspx", false);
                //string url = Request.RawUrl;
                //Response.Redirect(url, false);
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
                //---
                lbError.InnerText = ex.Message;
                lbError.Visible   = true;
            }
            finally
            {
                LogHelpers.WriteStatus(tag, "End.");
            }
        }
Example #5
0
        private void StartLoadUserInfo(int id)
        {
            string tag = __tag + "[StartLoadUserInfo]";

            LogHelpers.WriteStatus(tag, "Id = " + id.ToString(), "Start...");

            try
            {
                var result = UsersDAL.Get(id);
                if (result.Code < 0)
                {
                    lbError.InnerText = result.ErrorMessage;
                    lbError.Visible   = true;
                    LogHelpers.WriteError(tag, result.ErrorMessage);

                    return;
                }

                UserBOL user = new UserBOL(result.Data.Tables[0].Rows[0]);
                hfId.Value              = user.Id.ToString();
                tbxFirstNameVN.Text     = user.FirstName_VN;
                tbxFirstNameEN.Text     = user.FirstName_EN;
                tbxLastNameVN.Text      = user.LastName_VN;
                tbxLastNameEN.Text      = user.LastName_EN;
                tbxUsername.Text        = user.Username;
                tbxEmail.Text           = user.Email;
                tbxPhone.Text           = user.Phone;
                tbxDateOfBirth.Text     = user.DateOfBirth.ToString("yyyy-MM-dd");
                ddlGender.SelectedValue = user.Gender.Trim() == "Nam" ? "0" : "1";

                lbError.Visible   = false;
                btnSubmit.Text    = "Update";
                btnCancel.Visible = true;
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());

                lbError.InnerText = ex.Message;
                lbError.Visible   = true;
            }
            finally
            {
                LogHelpers.WriteStatus(tag, "End.");
            }
        }
Example #6
0
        private void StartCheckLogin()
        {
            try
            {
                lbError.InnerText = "";
                lbError.Visible   = false;
                string username = tbxUsername.Text;
                string password = tbxPassword.Text;

                var result = UsersDAL.Login(username, password);
                if (result.Code < 0 || result.DbReturnValue < 0)
                {
                    lbError.InnerText = result.ErrorMessage;
                    lbError.Visible   = true;
                    return;
                }

                if (result.Data.Tables.Count == 0 ||
                    result.Data.Tables[0].Rows.Count == 0)
                {
                    lbError.InnerText = "Sai tên đăng nhập hoặc mật khẩu không đúng.";
                    lbError.Visible   = true;
                    return;
                }

                UserBOL BOL = new UserBOL(result.Data.Tables[0].Rows[0]);
                Utilities.SaveLoggedInfo(BOL);
                //---
                GoToHome();
            }
            catch (Exception ex)
            {
                LogHelpers.WriteError("[Default][btnLogin_Click] Exception: {0}", ex.ToString());
                lbError.InnerText = ex.Message;
                lbError.Visible   = true;
            }
        }
Example #7
0
 public FrmSignUp()
 {
     InitializeComponent();
     eu   = new EUser();
     ubol = new UserBOL();
 }