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

.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. namespace Web.Common.controls
  15. {
  16.     public partial class userDetails : System.Web.UI.UserControl
  17.     {
  18.         protected void Page_Load(object sender, EventArgs e)
  19.         {
  20.             if (!IsPostBack)
  21.             {
  22.                 BindData();
  23.             }
  24.         }
  25.         public void BindData()
  26.         {
  27.             Users LoginUser = new Users();
  28.             LoginUser.UserID = Session["UserID"].ToString();
  29.             DataSet ds = LoginUser.GetUserInfoByID(LoginUser.UserID);
  30.             lblID.Text = Session["UserID"].ToString();
  31.             lblName.Text = ds.Tables[0].Rows[0]["userName"].ToString();
  32.             string gender = ds.Tables[0].Rows[0]["userGender"].ToString();
  33.             if (gender=="True")
  34.             lblGender.Text = "男";
  35.             else
  36.             lblGender.Text = "女";
  37.             int power = Convert.ToInt32(ds.Tables[0].Rows[0]["roleID"]);
  38.             switch (power)
  39.             {
  40.                 case 1:
  41.                     lblPower.Text = "管理员";
  42.                     break;
  43.                 case 2:
  44.                     lblPower.Text = "操作员";
  45.                     break;
  46.                 case 3:
  47.                     lblPower.Text = "读者";
  48.                     break;
  49.                 default:
  50.                     break;
  51.             }             
  52.            
  53.             txtAddress.Text = ds.Tables[0].Rows[0]["userAddress"].ToString();
  54.             txtDept.Text = ds.Tables[0].Rows[0]["userDepartment"].ToString();
  55.             txtPhone.Text = ds.Tables[0].Rows[0]["userPhone"].ToString();
  56.         }
  57.         protected void imgUpdate_Click(object sender, ImageClickEventArgs e)
  58.         {
  59.             //Response.Write("<script language=javascript>alert('TODO:')</script>")
  60.             string userID = Convert.ToString(Session["userID"]);
  61.             Users user=new Users();
  62.             user.UserDepartment=txtDept.Text.Trim();
  63.             user.UserAddress=txtAddress.Text.Trim();
  64.             user.UserPhone=txtPhone.Text.Trim();
  65.             if (user.UpdateUserComm(userID) == true)
  66.                 Response.Write("<script language=javascript>alert('修改成功!') </script>");
  67.             else
  68.                 Response.Write("<script language=javascript>alert('修改失败!') </script>");
  69.             //gridviewUserList.EditIndex = -1;//善后处理,重新绑定
  70.             //BindGrdUserList();
  71.         }
  72.     }
  73. }