Exemplo n.º 1
0
        private void lblLogin_Click(object sender, EventArgs e)
        {
            var msg = string.Empty;

            UserInfo.Instance.Account = txtUserCode.Text.Trim();
            if (string.IsNullOrEmpty(txtUserCode.Text.Trim()))
            {
                msg = "请输入用户名和密码";
                ShowMessage(msg);
                return;
            }
            var resultEntity = UserBLL.Instance.GetUserByLogin(UserInfo.Instance);

            if (resultEntity == null)
            {
                msg = "该用户不存在,请重新输入!";
                ShowMessage(msg);
                return;
            }
            else
            {
                if (string.IsNullOrEmpty(resultEntity.StoreName ?? ""))
                {
                    msg = "用户未指定所属门店,无法登录系统!";
                    WriteLog(new PartialLog {
                        Description = msg, Result = ResultType.error.ToString(), ModuleName = "前台登录", Type = LogType.CS.ToString()
                    });
                    ShowMessage(msg);
                    return;
                }
                var checkStore = SysBLL.Instance.GetBy <StoreInfoEntity>(item => item.ID == resultEntity.StoreID);
                if (checkStore == null)
                {
                    msg = $"用户所属门店编号:{resultEntity.StoreID}不存在!";
                    ShowMessage(msg);
                    return;
                }
                var encrytPass = Encodetool.Md5(txtPassword.Text.Trim());
                if (resultEntity.Password.Equals(encrytPass))
                {
                    UserInfo.Instance           = resultEntity;
                    UserInfo.Instance.UserRoles = SysBLL.Instance.GetUserRoles(resultEntity.ID);
                    new frmMain().Show();
                    if (ShowCustomerDispaly)
                    {
                        CustomerDispalyControl();
                    }
                    OnCloseAnimat();
                    WriteLog(new PartialLog {
                        Description = "登录成功", Result = ResultType.success.ToString(), ModuleName = "前台登录", Type = LogType.CS.ToString()
                    });
                    return;
                }
                WriteLog(new PartialLog {
                    Description = msg, Result = ResultType.error.ToString(), ModuleName = "前台登录", Type = LogType.CS.ToString()
                });
                msg = "用户密码错误,请重新输入!";
                ShowMessage(msg);
            }
        }
Exemplo n.º 2
0
        private void btnChanged_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtPasswordNew.Text) || string.IsNullOrEmpty(txtPasswordConfirm.Text))
            {
                XtraMessageBox.Show("新密码不能为空!", "系统提示");
                txtPasswordNew.Focus();
                return;
            }
            if (txtPasswordNew.Text.Length < 6)
            {
                XtraMessageBox.Show("密码长度不能少于6位!", "系统提示");
                txtPasswordNew.Focus();
                return;
            }
            if (txtPassordOld.Text == txtPasswordNew.Text)
            {
                XtraMessageBox.Show("原密码与新密码不能是同一个密码,请重新输入!", "系统提示");
                txtPasswordNew.Text = string.Empty;
                txtPasswordNew.Focus();
                return;
            }

            if (txtPasswordNew.Text != txtPasswordConfirm.Text)
            {
                XtraMessageBox.Show("两次输入的新密码不一致,请重新输入!", "系统提示");
                txtPasswordNew.Text     = string.Empty;
                txtPasswordConfirm.Text = string.Empty;
                txtPasswordNew.Focus();
                return;
            }

            var account    = UserInfo.Instance.Account;
            var oldPassorw = UserInfo.Instance.Password;

            if (oldPassorw == Encodetool.Md5(txtPassordOld.Text.Trim()))
            {
                var result = SysBLL.Instance.UpdatePassword(UserInfo.Instance.ID, Encodetool.Md5(txtPasswordNew.Text.Trim()));
                if (result)
                {
                    if (XtraMessageBox.Show("修改密码成功!是否重启系统重新登录?", "系统提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Application.Exit();
                        Process.Start(Application.ExecutablePath);
                    }
                }
                else
                {
                    XtraMessageBox.Show("修改密码失败!", "系统提示");
                }
            }
            else
            {
                XtraMessageBox.Show("原密码错误,请重新输入!", "系统提示");
                txtPassordOld.Text = string.Empty;
                txtPassordOld.Focus();
                return;
            }
        }
Exemplo n.º 3
0
 private void txtPassword_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
 {
     if (UserInfo.Instance.Password == Encodetool.Md5(txtPassword.Text.Trim()))
     {
         this.Close();
     }
     else
     {
         ShowMessage("用户密码错误!");
     }
 }
Exemplo n.º 4
0
        public ActionResult CheckLogin(string username, string password, string code)
        {
            try
            {
                if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
                {
                    return(Content(new AjaxResult {
                        state = ResultType.error, message = "请输入用户名和密码!"
                    }.ToJson()));
                }

                if (Session["session_verifycode"] == null || VerifyCode.md5(code.ToLower(), 16) != Session["session_verifycode"].ToString())
                {
                    WriteLog(ResultType.error.ToString(), $"验证码错误");
                    return(Content(new AjaxResult {
                        state = ResultType.error, message = "验证码错误,请重新输入!"
                    }.ToJson()));
                }
                UserInfo.Instance.Account = username.Trim();
                var resultEntity = UserBLL.Instance.GetUserByLogin(UserInfo.Instance);
                if (resultEntity != null)
                {
                    var encrytPass = Encodetool.Md5(password.Trim());
                    if (encrytPass != resultEntity.Password)
                    {
                        WriteLog(ResultType.error.ToString(), "用户密码错误");
                        return(Content(new AjaxResult {
                            state = ResultType.error, message = "用户密码错误!"
                        }.ToJson()));
                    }
                    UserInfo.Instance           = resultEntity;
                    UserInfo.Instance.UserRoles = SysBLL.Instance.GetUserRoles(resultEntity.ID);
                    WebHelper.WriteCookie("loginTag", Encodetool.Encrypt(UserInfo.Instance.ToJson()));
                    WriteLog(ResultType.success.ToString(), "登录成功");
                }
                else
                {
                    return(Content(new AjaxResult {
                        state = ResultType.error.ToString(), message = "用户名或密码不正确!"
                    }.ToJson()));
                }
                return(Content(new AjaxResult {
                    state = ResultType.success.ToString(), message = "登录成功!"
                }.ToJson()));
            }
            catch (Exception ex)
            {
                WriteLog(ResultType.success.ToString(), $"登录失败!失败原因:{ex.Message}");
                return(Content(new AjaxResult {
                    state = ResultType.error.ToString(), message = ex.Message
                }.ToJson()));
            }
        }
Exemplo n.º 5
0
 private void frmLock_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (UserInfo.Instance.Password == Encodetool.Md5(txtPassword.Text.Trim()))
     {
         e.Cancel = false;
     }
     else
     {
         if (XtraMessageBox.Show("您确定要退出收银系统吗?", "系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
         {
             Application.ExitThread();
         }
         else
         {
             e.Cancel = true;
         }
     }
 }
Exemplo n.º 6
0
        public ActionResult SubmitForm(UserEntity entity, string keyValue)
        {
            PartialLog log = new PartialLog();

            if (string.IsNullOrEmpty(keyValue))
            {
                var existsRole = Sys.GetALL <UserEntity>().Where(item => item.Account == entity.Account || item.UserCode == entity.UserCode);
                if (existsRole.Count() > 0)
                {
                    return(Error("用户账户已存在请修改后再试!"));
                }
                else
                {
                    entity.ID         = Guid.NewGuid();
                    entity.CreateDate = DateTime.Now;
                    if (entity.Password.Length < 6)
                    {
                        return(Error("用户密码长度不能低于6位!"));
                    }
                    entity.Password = Infrastructure.Encodetool.Md5(entity.Password);
                    var res         = UserBLL.Instance.InsertUsersAndRoleRelation(entity) > 0;
                    var description = res ? "新建用户成功" : "新建用户失败";
                    log.Description = $"新建:{entity.Account}信息.{description}";
                    log.ModuleName  = "员工管理";
                    log.Result      = res ? ResultType.success.ToString() : ResultType.error.ToString();
                    WriteLog(log);
                    if (res)
                    {
                        UpdateStoreEmpCount(entity.StoreID);
                    }
                    return(res ? Success(description) : Error(description));
                }
            }
            else
            {
                var roleName = new List <string>();
                if (!string.IsNullOrEmpty(entity.RoleId))
                {
                    var roleids   = entity.RoleId.Split(',');
                    var baseRoles = SysBLL.Instance.GetALL <BaseRoleEntity>();
                    roleids.ToList().ForEach(item =>
                    {
                        string name = baseRoles.Where(role => role.ID == item).Select(role => role.RoleName).FirstOrDefault();
                        roleName.Add(name);
                    });
                }
                entity.RoleName = string.Join(",", roleName);
                entity.ID       = Guid.Parse(keyValue);
                var user    = Sys.GetALL <UserEntity>().FirstOrDefault(k => k.ID == entity.ID);
                var storeID = user == null ? null : user.StoreID;
                if (entity.StoreID == null)
                {
                    entity.StoreID = -99999;
                }
                var pwdExist = Sys.GetALL <UserEntity>().Any(item => item.ID == entity.ID && item.Password == entity.Password);
                if (!pwdExist)
                {
                    entity.Password = Encodetool.Md5(entity.Password);
                }
                var res         = Business.UserBLL.Instance.UpdateUser(entity) > 0;
                var description = res ? "更新用户信息成功" : "更新用户信息失败";
                log.Description = $"更新:{entity.Account}信息.{description}";
                log.ModuleName  = "员工管理";
                log.Result      = res ? ResultType.success.ToString() : ResultType.error.ToString();
                WriteLog(log);
                if (res)
                {
                    if (storeID != entity.StoreID)
                    {
                        UpdateStoreEmpCount(storeID);
                        UpdateStoreEmpCount(entity.StoreID);
                    }
                }
                return(res ? Success(description) : Error(description));
            }
        }