/// <summary> /// 保存修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { if (txtPwd1.Text.Trim() != "" && txtPwd2.Text.Trim() != "") { if (txtPwd1.Text.Trim() != txtPwd2.Text.Trim()) { MessageBox.Show("两次输入的密码不一致!"); return; } UIModels.LoginUserInfo _loginfo=LoginManager.Instance.GetThisUserLoginInfo(); KPS.Model.UserInfo _user=new UserInfo(); _user.ID=_loginfo.UserID; _user.userName=_loginfo.LoginName; _user.userPwd=txtPwd1.Text.Trim(); KPS.BLL.UserInfoManager manager = new BLL.UserInfoManager(); if (manager.Update(_user)) { MessageBox.Show("修改成功!"); this.DialogResult = DialogResult.OK; } else { MessageBox.Show("修改失败!"); } } else { MessageBox.Show("新密码和确认密码都不可为空!"); } }
/// <summary> /// 显示用户权限菜单 /// </summary> /// <param name="ListPerms"></param> /// <param name="_seluser"></param> private void ShowUserAuthMenu(List <Model.PermissionInfo> ListPerms, Model.UserInfo _seluser) { //if (_seluser.userName == "admin") //{ // treeView1.Nodes[0].Checked = true; //} //else //{ treeView1.Nodes[0].Checked = false; //} if (ListPerms != null && ListPerms.Count > 0) { List <int> MIDlist = new List <int>(); foreach (KPS.Model.PermissionInfo _pers in ListPerms) { MIDlist.Add(Convert.ToInt32(_pers.moduleInfoID)); } SelectedNode(treeView1.Nodes[0], MIDlist);//选中节点 } }
/// <summary> /// 2.1 方式添加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { string strUserName = textBox1.Text.Trim(); string strPwd = textBox2.Text.Trim(); if (string.IsNullOrEmpty(strUserName) || string.IsNullOrEmpty(strPwd)) { MessageBox.Show("用户名和密码不可为空!"); return; } //1.调用用户的业务逻辑,实现用户信息添加 UserInfo _user = new UserInfo(); _user.userName = strUserName; _user.userPwd = strPwd; UserInfoManager usermanager = new UserInfoManager(); DataSet _Dt = usermanager.GetList(string.Format("userName='******'", strUserName)); if (_Dt.Tables != null && _Dt.Tables[0].Rows.Count > 0) { MessageBox.Show("同名称用户已存在,请输入其它用户名!"); return; } if (usermanager.Add(_user)) { _user.ID = usermanager.GetMaxId(); } else { MessageBox.Show("添加失败!"); } //2.添加成功将用户信息(需要获取此)添加到当前_RecordListView和RecordList列表中 if (RecordList == null) { RecordList = new List<UserInfo>(); } RecordList.Add(_user); _RecordListView.AddObject(_user);//刷新ListView 列表 }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(KPS.Model.UserInfo model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(KPS.Model.UserInfo model) { return(dal.Add(model)); }