private void LoadInfo() { InitUserRole(); if (id > 0) { //用户为系统管理员则不允许修改,修改密码从修改密码地址进入修改 if (id == 1) { ShowMassage.Html("不允许修改该用户资"); Response.End(); } UserModel model = new UserBLL().GetModelById(id); if (model != null) { txtUName.Text = HttpUtility.HtmlDecode(model.Name); txtVerityName.Text = HttpUtility.HtmlDecode(model.RealName); txtEmail.Text = HttpUtility.HtmlDecode(model.Email); txtMobile.Text = HttpUtility.HtmlDecode(model.Mobile); txtTel.Text = HttpUtility.HtmlDecode(model.Tel); chkDisabled.Checked = model.Disabled; txtUName.Enabled = false; txtPwd.Required = false; txtPwd.ShowRedStar = false; } else { Alert.ShowInParent("读取数据失败!", String.Empty, ActiveWindow.GetHideReference()); } } else { Alert.ShowInParent("参数错误!", String.Empty, ActiveWindow.GetHideReference()); } }
protected void Grid1_RowCommand(object sender, FineUI.GridCommandEventArgs e) { if (e.CommandName == "UDISABLED") { //上架操作权限 if (!VerifyPurview(",SU-EDIT,")) { Alert.ShowInParent(CHECK_POWER_FAIL_ACTION_MESSAGE); return; } CheckBoxField checkField = (CheckBoxField)Grid1.FindColumn(e.ColumnIndex); bool checkState = checkField.GetCheckedState(e.RowIndex); int result = new UserBLL().SetDisabled(Convert.ToInt32(Grid1.DataKeys[e.RowIndex][0]), checkState); string tipText = checkState ? "禁用" : "启用"; if (result > 0) { Alert.ShowInParent(tipText + "成功!"); BindData(); } else { Alert.ShowInParent(tipText + "失败!"); } } }
protected void btnSave_Click(object sender, EventArgs e) { string oldPwd = MD5Encrypt.GetPass(txtOldPwd.Text.Trim(), currentUser.Encrypt); if (oldPwd == currentUser.Pwd) { string encrypt = RandomHelper.CreateRandomStr(6); string newPwd = MD5Encrypt.GetPass(txtNewPwdT.Text.Trim(), encrypt); int result = new UserBLL().ModifyPwd(currentUser.Id, newPwd, encrypt); txtOldPwd.Text = String.Empty; txtNewPwd.Text = String.Empty; txtNewPwdT.Text = String.Empty; if (result > 0) { cookie.ClearCookie(); Alert.ShowInParent("修改密码成功,请重新登录", String.Empty, "top.location.href='/default.aspx'"); } else { Alert.ShowInTop("修改密码失败"); } } else { Alert.ShowInTop("输入的旧密码错误"); } }
private void LoadInfo() { int id = RequestHelper.GetRequestInt("id", 0); if (id > 0) { UserModel model = new UserBLL().GetModelById(id); if (model != null) { labName.Text = HttpUtility.HtmlDecode(model.Name); labRealName.Text = HttpUtility.HtmlDecode(model.RealName); labEmail.Text = HttpUtility.HtmlDecode(model.Email); labMobile.Text = HttpUtility.HtmlDecode(model.Mobile); labPhone.Text = HttpUtility.HtmlDecode(model.Tel); imgShowStatus.Icon = model.Disabled ? Icon.Tick : Icon.BulletCross; StringBuilder sbText = new StringBuilder(); using (DataTable dt = SqlPagerHelper.GetTableByCondition(DefaultConnection.ConnectionStringByDefaultDB, "R_NAME", "[S_ROLE_USER] a JOIN [S_ROLE] b ON b.R_ID=a.R_ID", "WHERE a.U_ID=" + id, "ORDER BY a.R_ID ASC")) { if (dt != null && dt.Rows.Count > 0) { foreach (DataRow role in dt.Rows) { sbText.AppendFormat("{0},", role["R_NAME"]); } labRole.Text = sbText.ToString().TrimEnd(','); } } labPT.Text = model.PrevLoginTime.HasValue ? model.PrevLoginTime.Value.ToString() : ""; labPIP.Text = HttpUtility.HtmlDecode(model.PrevLoginIP); labLT.Text = model.LastLoginTime.HasValue ? model.LastLoginTime.Value.ToString() : ""; labLIP.Text = HttpUtility.HtmlDecode(model.LastLoginIP); labLTS.Text = model.LoginTimes.ToString(); labCT.Text = model.CreateTime.Value.ToString(); } else { Alert.ShowInParent("读取数据失败!", String.Empty, ActiveWindow.GetHideReference()); } } else { Alert.ShowInParent("参数错误!", String.Empty, ActiveWindow.GetHideReference()); } }
protected void btnSave_Click(object sender, EventArgs e) { //保存权限 if (!VerifyPurview(",SU-EDIT,")) { Alert.ShowInParent(CHECK_POWER_FAIL_ACTION_MESSAGE); return; } string strErr = String.Empty; int num = 1; if (id <= 0) { strErr += num + "、参数错误 <br />"; num++; } string vName = HttpUtility.HtmlEncode(txtVerityName.Text.Trim()); if (vName.Length == 0) { strErr += num + "、真实姓名不能为空 <br />"; } if (strErr.Length > 0) { Alert.ShowInParent(strErr); return; } UserModel model = new UserModel(); model.Id = id; string pwd = HttpUtility.HtmlEncode(txtPwd.Text.Trim()); if (pwd.Length > 0) { model.Encrypt = RandomHelper.CreateRandomStr(6); model.Pwd = MD5Encrypt.GetPass(pwd, model.Encrypt); } model.RealName = vName; model.Email = HttpUtility.HtmlEncode(txtEmail.Text.Trim()); model.Mobile = HttpUtility.HtmlEncode(txtMobile.Text.Trim()); model.Tel = HttpUtility.HtmlEncode(txtTel.Text.Trim()); model.Disabled = chkDisabled.Checked; int result = 0; UserBLL bll = new UserBLL(); using (DataTable roleDT = new DataTable()) { roleDT.Columns.Add("roleid", typeof(int)); roleDT.Columns.Add("userid", typeof(int)); #region 角色用户 string userRole = hfSelectedRole.Text.Trim(); if (userRole.Length > 0) { string[] userRoleArr = userRole.Split(','); foreach (string s in userRoleArr) { DataRow dr = roleDT.NewRow(); dr[0] = Convert.ToInt32(s); dr[1] = model.Id; roleDT.Rows.Add(dr); } } #endregion result = bll.Modify(model, roleDT); } if (result > 0) { Alert.ShowInParent("保存成功!", String.Empty, ActiveWindow.GetHidePostBackReference()); } else { Alert.ShowInParent("保存失败"); } }