/// <summary> /// 检验表单数据 /// </summary> /// <returns></returns> //public string CheckPageInfo(string type, string userid, string uname, string upwd, string realname, string umobile, string empcode, string remark, string status, string cname, string ccode, string scope, string stocode, string sigmonthmoney, string sigstocode,string buscode, string utype, out string spansid) public bool CheckPageInfo(string type, string userid, string uname, string upwd, string realname, string umobile, string remark, string status, string cname, string ccode) { bool rel = false; try { Entity = new AdminsEntity(); Entity.userid = StringHelper.StringToInt(userid); Entity.uname = uname; Entity.upwd = OEncryp.Encrypt(upwd); Entity.realname = realname; Entity.umobile = umobile; Entity.remark = remark; Entity.status = status; Entity.cname = cname; Entity.ccode = ccode; rel = true; } catch (Exception) { } return(rel); }
private void CheckUser(string username, string password) { bllAdmins bll = new bllAdmins(); string userpwd = OEncryp.Encrypt(password); AdminsEntity adminEntity = bll.GetEntitySigInfo(" WHERE uname='" + username + "' AND upwd='" + userpwd + "'"); if (adminEntity.userid > 0) { LoginedUserEntity loginedUser = new LoginedUserEntity(adminEntity.userid.ToString(), adminEntity.upwd, adminEntity.uname, adminEntity.umobile); DataTable dtPermission = bll.GetPermissionInfo(loginedUser.GUID, loginedUser.UserID, loginedUser.UserID); if (dtPermission != null && dtPermission.Rows.Count > 0) { loginedUser.Permission = dtPermission; loginedUser.SetLoginCookie(); //string appJson = JsonHelper.ObjectToJSON(loginedUser); Context.Cache.Insert("logincache_" + loginedUser.UserID, loginedUser); loginedUser.SetLoginCookie(); Response.Redirect("index.html"); } else { Message.InnerHtml = "您的帐号无效,请联系管理员!"; } } else { Message.InnerHtml = "用户或密码错误!"; } }
public string GetFromCookieData() { string sCookieName = FormsAuthentication.FormsCookieName; HttpCookie authCookie = HttpContext.Current.Request.Cookies[sCookieName]; if (authCookie == null) { //跳转到登录页 try { System.Web.UI.Page page = (System.Web.UI.Page)System.Web.HttpContext.Current.Handler; if (page != null) { page.Response.Write("<script> top.location.href='" + Helper.GetAppSettings("HomePageUrl") + "';</script>"); } return(null); } catch (Exception e) { return(null); } } FormsAuthenticationTicket authTicket = null; authTicket = FormsAuthentication.Decrypt(authCookie.Value); if (authTicket == null) { HttpContext.Current.Response.Clear(); FormsAuthentication.RedirectToLoginPage(); HttpContext.Current.Response.End(); return(null); } if (!authTicket.Expired && FormsAuthentication.SlidingExpiration) { FormsAuthenticationTicket newTicket = FormsAuthentication.RenewTicketIfOld(authTicket); if (authTicket.Expiration != newTicket.Expiration) { string encTicket = FormsAuthentication.Encrypt(newTicket); authCookie.Value = encTicket; authCookie.Expires = newTicket.Expiration; authCookie.Domain = FormsAuthentication.CookieDomain; HttpContext.Current.Response.Cookies.Remove(sCookieName); HttpContext.Current.Response.Cookies.Add(authCookie); } } string sData = authTicket.UserData; sData = OEncryp.Decrypt(sData); return(sData); }
/// <summary> /// 设置页面信息 /// </summary> /// <param name="id">ID</param> private void SetPage(string id) { DataTable dt = bll.GetPagingSigInfo("0", "0", " where userid=" + id); if (dt != null && dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; txt_uname.Text = dr["uname"].ToString(); txt_pwd.Text = OEncryp.Decrypt(dr["upwd"].ToString()); txt_pwd.Enabled = false; txt_role.Text = dr["rolename"].ToString(); hidroleid.Value = dr["roleid"].ToString(); ddl_status.SelectedValue = dr["status"].ToString(); txt_descr.Text = dr["remark"].ToString(); } }
/// <summary> /// 用户登录信息 /// </summary> public void SetLoginCookie() { HttpCookie hcCurrent = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; if (hcCurrent != null) { HttpContext.Current.Response.Cookies.Remove(FormsAuthentication.FormsCookieName); } string sData = this.UserID + "|" + this.Pwd + "|" + this.Name + "|" + this.Mobile + "|" + this.UserID + "|" + this.GUID; sData = OEncryp.Encrypt(sData); HttpCookie authCookie = FormsAuthentication.GetAuthCookie(this.GUID, false); FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value); FormsAuthenticationTicket newTicket = new FormsAuthenticationTicket(authTicket.Version, authTicket.Name, authTicket.IssueDate, authTicket.IssueDate.AddMinutes(360), authTicket.IsPersistent, sData, authTicket.CookiePath); authCookie.Value = FormsAuthentication.Encrypt(newTicket); authCookie.Secure = false; authCookie.Expires = newTicket.Expiration; authCookie.Domain = FormsAuthentication.CookieDomain; HttpContext.Current.Response.Cookies.Add(authCookie); }
//保存数据 protected void Save_btn_Click(object sender, EventArgs e) { //获取页面信息 string pwd = tex_oldpwd.Text; string newpwd = this.txt_pwd.Text; string newpwdconfirm = this.txt_repwd.Text; pwd = OEncryp.Encrypt(pwd); if (newpwd.Length < 6) { Script(this.Page, "pcLayerMsg('密码格式为6-16位数字或字母组合!');"); return; } if (newpwd != newpwdconfirm) { Script(this.Page, "pcLayerMsg('两次输入密码不一致');"); return; } newpwd = OEncryp.Encrypt(newpwd); bll.ResetPwd("0", "0", base.LoginedUser.UserID.ToString(), newpwd); Script(this.Page, "pcLayerMsg('" + bll.oResult.Msg + "');"); }
//绑定会员卡 private void BindMemCard(Dictionary <string, object> dicPar) { //要检测的参数信息 List <string> pra = new List <string>() { "GUID", "USER_ID", "cardcode", "phone", "idno", "paypassword" }; //检测方法需要的参数 if (!CheckActionParameters(dicPar, pra)) { return; } string GUID = dicPar["GUID"].ToString(); string USER_ID = dicPar["USER_ID"].ToString(); string cardcode = dicPar["cardcode"].ToString(); //卡号 string phone = dicPar["phone"].ToString(); //手机号 string idno = dicPar["idno"].ToString(); //手机号 string paypassword = dicPar["paypassword"].ToString(); //支付密码 string mescode = String.Empty; if (cardcode.Substring(0, 1).ToLower() == "e") { ToCustomerJson("1", "无法绑定电子卡"); } else { if (!string.IsNullOrEmpty(paypassword)) { paypassword = OEncryp.Encrypt(paypassword); } bll.BindMemCard(USER_ID, cardcode, phone, idno, paypassword, ref mescode); switch (mescode) { case "0": string erqimg = DoWaitProcess(cardcode); new bllPaging().ExecuteNonQueryBySQL("update wx_cardinfo set erqimg='" + erqimg + "' where openid='" + USER_ID + "' and cardcode='" + cardcode + "' and isecard='0';"); ToCustomerJson("0", "绑定成功"); break; case "1": ToCustomerJson("1", "卡号不存在"); break; case "2": ToCustomerJson("1", "卡状态异常"); break; case "3": ToCustomerJson("1", "卡资料手机号或证件号码不全"); break; case "4": ToCustomerJson("1", "手机号或证件号码与系统资料不匹配"); break; case "5": ToCustomerJson("1", "卡密码与系统密码不匹配"); break; case "6": ToCustomerJson("1", "卡已绑定其他账号"); break; case "7": ToCustomerJson("1", "卡已绑定"); break; case "8": ToCustomerJson("1", "卡类型不支持在线购票"); break; case "9": ToCustomerJson("1", "此会员已被其他微信用户绑定"); break; } } }