ModifyPassword.ascx.cs
上传用户:gooyliu
上传日期:2018-09-29
资源大小:5816k
文件大小:2k
源码类别:

.net编程

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.HtmlControls;
  10. using System.Web.UI.WebControls;
  11. using System.Web.UI.WebControls.WebParts;
  12. using System.Xml.Linq;
  13. using BusinessLogicLayer;
  14. using DataAccessLayer;
  15. namespace Web.Common.controls
  16. {
  17.     public partial class ModifyPassword : System.Web.UI.UserControl
  18.     {
  19.         protected void Page_Load(object sender, EventArgs e)
  20.         {
  21.             
  22.         }
  23.         protected void btnSave_Click(object sender, EventArgs e)
  24.         {
  25.             Users LoginUser = new Users();
  26.             LoginUser.UserID = Session["UserID"].ToString();
  27.             DataSet ds = LoginUser.GetUserInfoByID(LoginUser.UserID);
  28.             string correctPwd = ds.Tables[0].Rows[0]["userPassword"].ToString();
  29.             if (txtCurrPwd.Text != correctPwd)
  30.             {
  31.                 Page.RegisterStartupScript("ggg", "<script>showError( );</script>");//注意这是调用js函数的方法
  32.             }
  33.             else
  34.                 if (txtNewPwd.Text != txtConfimPwd.Text)
  35.                 {
  36.                     Page.RegisterStartupScript("chec=", "<script>checkPS( );</script>");//注意这是调用js函数的方法
  37.                 }
  38.                 else
  39.                     if (txtNewPwd.Text == string.Empty)
  40.                     {
  41.                         Page.RegisterStartupScript("ch=", "<script>emptyError( );</script>");//注意这是调用js函数的方法
  42.                     }
  43.                else
  44.                  update();
  45.                    
  46.         }
  47.         public void update()
  48.         {
  49.             string newPwd = txtNewPwd.Text.Trim();
  50.             string updateStrsql = "UPDATE Users SET userPassword='" + newPwd + "'WHERE userID='"+ Session["UserID"].ToString()+"'";
  51.             DataBase db = new DataBase();
  52.             int cnt= db.ExecuteNonQuery(updateStrsql);
  53.             if (cnt==1)
  54.                 Response.Write("<script languge=javascript> alert('密码修改成功!');</script>");
  55.             else
  56.                 Response.Write("<script languge=javascript> alert('密码修改失败!');</script>");
  57.         }
  58.     }
  59. }