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); } }
/// <summary> /// 优惠券接口(同步方法) /// 算法 /// 1:key-value 降序排列(a-z) /// 2:对value url编码 /// 3:value url编码结果小写全部转换为大写 /// 4:url参数+key MD5 32加密生成sign作为参数 /// </summary> /// <param name="memberOrder"></param> /// <param name="doPost"></param> public static string ConfirmMemberOrder(ConfirmMemberOrder memberOrder) { using (var client = new HttpClient()) { var url = ConfigHelper.GetAppConfig("MemberOrderConfirm"); var paramaters = new List <KeyValuePair <string, string> >(); paramaters.Add(new KeyValuePair <string, string>("appid", 1002.ToString())); paramaters.Add(new KeyValuePair <string, string>("product_fee", memberOrder.product_fee.ToString())); paramaters.Add(new KeyValuePair <string, string>("products", Newtonsoft.Json.JsonConvert.SerializeObject(memberOrder.products))); paramaters.Add(new KeyValuePair <string, string>("shop_name", memberOrder.shop_name)); paramaters.Add(new KeyValuePair <string, string>("shop_sn", memberOrder.shop_sn)); paramaters.Add(new KeyValuePair <string, string>("uid", memberOrder.uid.ToString())); paramaters = paramaters.OrderBy(item => item.Key).ToList(); var paramString = string.Empty; paramaters.ForEach(item => { paramString += $"{item.Key}={Ingpal.BusinessStore.Infrastructure.Encodetool.UrlEncode((item.Value??""))}&"; }); int pos = paramString.LastIndexOf("&"); paramString = paramString.Remove(pos); var urlString = paramString.Trim() + $"6196248fb93d30b7de7553749857300c"; var sign = Encodetool.Md5_32(urlString); paramString += $"&sign={sign}"; Task <HttpResponseMessage> resonse = client.GetAsync(url + paramString); var resString = resonse.Result.Content.ReadAsStringAsync().GetAwaiter().GetResult(); return(resString); } }
/// <summary> /// 会员查询接口 /// </summary> /// <param name="member"></param> /// <param name="doPost"></param> /// <param name="queryType"></param> public async static void ValidMemberInfo(MemberParams member, Func <string, bool> doPost, MemberQueryType queryType = MemberQueryType.Mobile) { using (var client = new HttpClient()) { bool isMobileQuery = queryType == MemberQueryType.Mobile; var queryTypeName = isMobileQuery ? "mobile" : "cardid"; var interfaceName = isMobileQuery ? MemberInterface.mobile : MemberInterface.card; var url = string.Format(ConfigHelper.GetAppConfig("MemberGateway"), interfaceName); member.url = url; member.appid = ConfigHelper.GetAppConfig("appid"); member.secret_key = ConfigHelper.GetAppConfig("Secretkey"); var sign = Encodetool.Md5_32($"appid={member.appid}&{queryTypeName}={member.queryid}{member.secret_key}"); member.sign = sign; var values = new List <KeyValuePair <string, string> >(); values.Add(new KeyValuePair <string, string>(queryTypeName, member.queryid)); values.Add(new KeyValuePair <string, string>("appid", member.appid)); values.Add(new KeyValuePair <string, string>("sign", sign)); var content = new FormUrlEncodedContent(values); var response = await client.PostAsync(member.url, content); var resString = await response.Content.ReadAsStringAsync(); doPost(resString); } }
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; } }
private void txtPassword_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { if (UserInfo.Instance.Password == Encodetool.Md5(txtPassword.Text.Trim())) { this.Close(); } else { ShowMessage("用户密码错误!"); } }
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())); } }
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; } } }
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)); } }