protected void lbtnSave_Click(object sender, EventArgs e) { //DatabaseOperater dbOperator = new DatabaseOperater(); //dbOperator.GetModelName = "sys_UserListlogin"; //dbOperator.GetStrProcParaValue = txtUserName.Text + "," + encrypObject.EncryptMD5(); ; BLL.Security.UserBll userBll = new BLL.Security.UserBll(); DataTable dtUserList = userBll.GetUserInfo(txtUserName.Text.Trim()); if (dtUserList.Rows[0]["UserPassword"].ToString().Trim() == this.txtOldPwd.Text.Trim()) { userBll.UpdateUserPWD(this.txtUserName.Text.Trim(), this.txtAckPwd.Text.Trim()); //WMS.App_Code.JScript.Instance.ShowMessage(this, "密码修改成功!"); ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "myscript", "<script type='text/javascript'>alert('密码修改成功!'); Exit();</script>"); } else { WMS.App_Code.JScript.Instance.ShowMessage(this, "原密码错误!"); } }
protected void btnSave_Click(object sender, EventArgs e) { try { BLL.Security.UserBll ubll = new BLL.Security.UserBll(); if (ViewState["OpFlag"].ToString() == "0")//新增 { DataTable dtTemp = ubll.GetUserInfo(this.txtUserName.Text.Trim()); if (dtTemp.Rows.Count > 0) { WMS.App_Code.JScript.Instance.ShowMessage(this.UpdatePanel1, "该用户名已经存在!"); return; } if (this.txtEmployeeCode.Text.Trim() == "") { txtEmployeeCode.Text = txtUserName.Text.Trim(); } ubll.InsertUser(this.txtUserName.Text.Trim(), this.txtEmployeeCode.Text, this.txtMemo.Text); SetBtnEnabled(int.Parse(ViewState["CurrentPage"].ToString()), SqlCmd, ViewState["filter"].ToString(), pageSize, gvMain, btnFirst, btnPre, btnNext, btnLast, btnToPage, lblCurrentPage, this.UpdatePanel1); SwitchView(0); WMS.App_Code.JScript.Instance.ShowMessage(this.UpdatePanel1, "数据添加成功!"); AddOperateLog("用户管理", "添加用户信息"); } else//修改 { foreach (DataRow dr in dtUser.Rows) { if (dr["UserID"].ToString() == this.txtUserID.Text.Trim()) { DataTable dtTemp =ubll. GetUserList(1, 10, string.Format("UserID<>{0} and UserName='******'", this.txtUserID.Text, this.txtUserName.Text.Trim()), OrderByFields); if (dtTemp.Rows.Count > 0) { WMS.App_Code.JScript.Instance.ShowMessage(this.UpdatePanel1, "该用户名已经存在!"); return; } ubll.UpdateUser(this.txtUserName.Text.Trim(), this.txtEmployeeCode.Text.Trim(), this.txtMemo.Text.Trim(), int.Parse(this.txtUserID.Text)); break; } } this.gvMain.EditIndex = -1; SetBtnEnabled(int.Parse(ViewState["CurrentPage"].ToString()), SqlCmd, ViewState["filter"].ToString(), pageSize, gvMain, btnFirst, btnPre, btnNext, btnLast, btnToPage, lblCurrentPage, this.UpdatePanel1); WMS.App_Code.JScript.Instance.ShowMessage(this.UpdatePanel1, "数据修改成功!"); SwitchView(0); AddOperateLog("用户管理", "修改用户信息"); } } catch (Exception exp) { WMS.App_Code.JScript.Instance.ShowMessage(this.UpdatePanel1, exp.Message); } }