/// <summary> /// 得到一个对象实体 by SQLpara /// </summary> public Lebi_User_Answer GetModel(SQLPara para) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from [Lebi_User_Answer] "); if (para.Where != "") { strSql.Append(" where " + para.Where + ""); } Lebi_User_Answer model = new Lebi_User_Answer(); DataSet ds = SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString(), para.Para); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } model.Answer = ds.Tables[0].Rows[0]["Answer"].ToString(); if (ds.Tables[0].Rows[0]["User_Question_id"].ToString() != "") { model.User_Question_id = int.Parse(ds.Tables[0].Rows[0]["User_Question_id"].ToString()); } if (ds.Tables[0].Rows[0]["User_id"].ToString() != "") { model.User_id = int.Parse(ds.Tables[0].Rows[0]["User_id"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 修改支付密码 /// </summary> public void SetPayPassword() { string PWD = RequestTool.RequestSafeString("Pay_Password"); string PWD1 = RequestTool.RequestSafeString("Pay_Password1"); string PWD2 = RequestTool.RequestSafeString("Pay_Password2"); PWD = EX_User.MD5(PWD); if (PWD != CurrentUser.Pay_Password && CurrentUser.Pay_Password != "") { Response.Write("{\"msg\":\"" + Tag("原始密码错误") + "\"}"); return; } else { Lebi_User_Answer user_answer = B_Lebi_User_Answer.GetModel("User_id= " + CurrentUser.id); if (user_answer == null) { Response.Write("{\"msg\":\"" + Tag("请先设置安全问题") + "\"}"); return; } } CurrentUser.Pay_Password = EX_User.MD5(PWD1); B_Lebi_User.Update(CurrentUser); Response.Write("{\"msg\":\"OK\"}"); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Lebi_User_Answer model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [Lebi_User_Answer]("); strSql.Append("Answer,User_Question_id,User_id)"); strSql.Append(" values ("); strSql.Append("@Answer,@User_Question_id,@User_id)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Answer", model.Answer), new SqlParameter("@User_Question_id", model.User_Question_id), new SqlParameter("@User_id", model.User_id) }; object obj = SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 安全方式绑定对象表单 /// </summary> public Lebi_User_Answer SafeBindForm(Lebi_User_Answer model) { if (HttpContext.Current.Request["Answer"] != null) { model.Answer = Shop.Tools.RequestTool.RequestSafeString("Answer"); } if (HttpContext.Current.Request["User_Question_id"] != null) { model.User_Question_id = Shop.Tools.RequestTool.RequestInt("User_Question_id", 0); } if (HttpContext.Current.Request["User_id"] != null) { model.User_id = Shop.Tools.RequestTool.RequestInt("User_id", 0); } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Lebi_User_Answer model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [Lebi_User_Answer] set "); strSql.Append("[Answer]=@Answer,"); strSql.Append("[User_Question_id]=@User_Question_id,"); strSql.Append("[User_id]=@User_id"); strSql.Append(" where id=" + model.id); OleDbParameter[] parameters = { new OleDbParameter("@Answer", model.Answer), new OleDbParameter("@User_Question_id", model.User_Question_id), new OleDbParameter("@User_id", model.User_id) }; AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Lebi_User_Answer model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [Lebi_User_Answer]("); strSql.Append("[Answer],[User_Question_id],[User_id])"); strSql.Append(" values ("); strSql.Append("@Answer,@User_Question_id,@User_id)"); OleDbParameter[] parameters = { new OleDbParameter("@Answer", model.Answer), new OleDbParameter("@User_Question_id", model.User_Question_id), new OleDbParameter("@User_id", model.User_id) }; AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters); return(1); }
/// <summary> /// 编辑安全问题 /// </summary> public void Question_Edit() { if (!EX_Admin.Power("user_edit", "编辑会员")) { AjaxNoPower(); } int id = RequestTool.RequestInt("id", 0); int Question_id1 = RequestTool.RequestInt("Question_id1", 0); int Question_id2 = RequestTool.RequestInt("Question_id2", 0); string Answer1 = EX_User.MD5(RequestTool.RequestSafeString("Answer1")); string Answer2 = EX_User.MD5(RequestTool.RequestSafeString("Answer2")); if (Question_id1 == Question_id2) { Response.Write("{\"msg\":\"" + Tag("请选择两个不同的问题") + "\"}"); return; } if (Answer1 == "" || Answer2 == "") { Response.Write("{\"msg\":\"" + Tag("请填写问题答案") + "\"}"); return; } Lebi_User_Answer model = B_Lebi_User_Answer.GetModel("User_id = " + id + ""); if (model == null) { model = new Lebi_User_Answer(); model.User_Question_id = Question_id1; model.Answer = Answer1; model.User_id = id; B_Lebi_User_Answer.Add(model); model.User_Question_id = Question_id2; model.Answer = Answer2; model.User_id = id; B_Lebi_User_Answer.Add(model); Log.Add("添加安全问题", "User_Answer", id.ToString(), CurrentAdmin, id.ToString()); } Response.Write("{\"msg\":\"OK\"}"); }
/// <summary> /// 对象实体绑定数据 /// </summary> public Lebi_User_Answer ReaderBind(IDataReader dataReader) { Lebi_User_Answer model = new Lebi_User_Answer(); object ojb; ojb = dataReader["id"]; if (ojb != null && ojb != DBNull.Value) { model.id = (int)ojb; } model.Answer = dataReader["Answer"].ToString(); ojb = dataReader["User_Question_id"]; if (ojb != null && ojb != DBNull.Value) { model.User_Question_id = (int)ojb; } ojb = dataReader["User_id"]; if (ojb != null && ojb != DBNull.Value) { model.User_id = (int)ojb; } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Lebi_User_Answer model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [Lebi_User_Answer] set "); strSql.Append("Answer= @Answer,"); strSql.Append("User_Question_id= @User_Question_id,"); strSql.Append("User_id= @User_id"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@Answer", SqlDbType.NVarChar, 50), new SqlParameter("@User_Question_id", SqlDbType.Int, 4), new SqlParameter("@User_id", SqlDbType.Int, 4) }; parameters[0].Value = model.id; parameters[1].Value = model.Answer; parameters[2].Value = model.User_Question_id; parameters[3].Value = model.User_id; SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters); }
/// <summary> /// 得到一个对象实体 by id /// </summary> public Lebi_User_Answer GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from [Lebi_User_Answer] "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Lebi_User_Answer model = new Lebi_User_Answer(); DataSet ds = SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } model.Answer = ds.Tables[0].Rows[0]["Answer"].ToString(); if (ds.Tables[0].Rows[0]["User_Question_id"].ToString() != "") { model.User_Question_id = int.Parse(ds.Tables[0].Rows[0]["User_Question_id"].ToString()); } if (ds.Tables[0].Rows[0]["User_id"].ToString() != "") { model.User_id = int.Parse(ds.Tables[0].Rows[0]["User_id"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public static void Update(Lebi_User_Answer model) { D_Lebi_User_Answer.Instance.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public static int Add(Lebi_User_Answer model) { return(D_Lebi_User_Answer.Instance.Add(model)); }
/// <summary> /// 安全方式绑定表单数据 /// </summary> public static Lebi_User_Answer SafeBindForm(Lebi_User_Answer model) { return(D_Lebi_User_Answer.Instance.SafeBindForm(model)); }
/// <summary> /// 编辑安全问题 /// </summary> public void Question_Edit() { int type = RequestTool.RequestInt("type", 0); int Question_id1 = RequestTool.RequestInt("Question_id1", 0); int Question_id2 = RequestTool.RequestInt("Question_id2", 0); string Answer1 = EX_User.MD5(RequestTool.RequestSafeString("Answer1")); string Answer2 = EX_User.MD5(RequestTool.RequestSafeString("Answer2")); if (Question_id1 == Question_id2) { Response.Write("{\"msg\":\"" + Tag("请选择两个不同的问题") + "\"}"); return; } if (Answer1 == "" || Answer2 == "") { Response.Write("{\"msg\":\"" + Tag("请填写问题答案") + "\"}"); return; } bool addflag = false; Lebi_User_Answer model = B_Lebi_User_Answer.GetModel("User_id = " + CurrentUser.id + ""); if (model == null) { addflag = true; model = new Lebi_User_Answer(); } if (addflag) { model.User_Question_id = Question_id1; model.Answer = Answer1; model.User_id = CurrentUser.id; B_Lebi_User_Answer.Add(model); model.User_Question_id = Question_id2; model.Answer = Answer2; model.User_id = CurrentUser.id; B_Lebi_User_Answer.Add(model); } else { int i = 0; List <Lebi_User_Answer> modellists = B_Lebi_User_Answer.GetList("User_id = " + CurrentUser.id + "", "id asc"); foreach (Lebi_User_Answer modellist in modellists) { if (i == 0 && modellist.Answer != Answer1) { Response.Write("{\"msg\":\"" + Tag("问题答案回答不正确") + "\"}"); return; } if (i == 1 && modellist.Answer != Answer2) { Response.Write("{\"msg\":\"" + Tag("问题答案回答不正确") + "\"}"); return; } i++; } if (type == 1) { CurrentUser.Pay_Password = ""; B_Lebi_User.Update(CurrentUser); Response.Write("{\"msg\":\"OK\",\"type\":\"1\",\"url\":\"" + URL("P_UserChangePassword", "") + "\"}"); return; } else { B_Lebi_User_Answer.Delete("User_id = " + CurrentUser.id + ""); } } Response.Write("{\"msg\":\"OK\",\"type\":\"0\"}"); }
/// <summary> /// 忘记密码的处理 /// </summary> public void User_forgetpwd() { int type = RequestTool.RequestInt("type", 0); string Email_ = RequestTool.RequestSafeString("Email"); string UserName = RequestTool.RequestSafeString("UserName"); string verifycode = RequestTool.RequestString("verifycode"); if (SYS.Verifycode_ForgetPassword == "1") { if (CurrentCheckCode != verifycode) { Response.Write("{\"msg\":\"" + Tag("验证码错误") + "\"}"); return; } } if (type == 0) { //发送邮件 Lebi_User user = B_Lebi_User.GetModel("Email=lbsql{'" + Email_ + "'}"); if (user == null) { Response.Write("{\"msg\":\"" + Tag("用户不存在") + "\"}"); return; } try { //发送邮件 Email.SendEmail_forgetpwd(user, CurrentTheme); //发送短信 SMS.SendSMS_forgetpwd(user); } catch (Exception ex) { Response.Write("{\"msg\":\"" + ex.Message + "\"}"); } Response.Write("{\"msg\":\"OK\"}"); } else if (type == 1) { Lebi_User user = B_Lebi_User.GetModel("UserName=lbsql{'" + UserName + "'}"); if (user == null) { Response.Write("{\"msg\":\"" + Tag("用户不存在") + "\"}"); return; } Lebi_User_Answer user_answer = B_Lebi_User_Answer.GetModel("User_id= " + user.id); if (user_answer == null) { Response.Write("{\"msg\":\"" + Tag("未设置安全问题") + "\"}"); return; } BaseConfig conf = ShopCache.GetBaseConfig(); user.CheckCode = EX_User.MD5(System.DateTime.Now.ToString() + conf.InstallCode); B_Lebi_User.Update(user); Response.Write("{\"msg\":\"OK\",\"url\":\"" + ThemeUrl.GetURL("P_FindPassword", "", "", user.Language) + "?id=" + user.id + "&v=" + user.CheckCode + "&type=1\"}"); } else if (type == 2) { Lebi_User user = B_Lebi_User.GetModel("UserName=lbsql{'" + UserName + "'}"); if (user == null) { Response.Write("{\"msg\":\"" + Tag("用户不存在") + "\"}"); return; } if (user.MobilePhone == "") { Response.Write("{\"msg\":\"" + Tag("未设置手机号码") + "\"}"); return; } Random Random = new Random(); int RandNum = Random.Next(100000, 999999); user.Password = EX_User.MD5(RandNum.ToString()); B_Lebi_User.Update(user); //发送短信 SMS.SendSMS_newpwd(user, RandNum.ToString()); Response.Write("{\"msg\":\"OK\",\"url\":\"" + ThemeUrl.GetURL("P_Login", "", "", user.Language) + "\"}"); } }