//重置选中用户密码 //删除用户 protected void BtnDel_Click(object sender, DirectEventArgs e) { RowSelectionModel sm = this.GridPanel1.SelectionModel.Primary as RowSelectionModel; foreach (SelectedRow row in sm.SelectedRows) { userinfo user = new userinfo(); user.userid = int.Parse(row.RecordID); if (row.RecordID == Session["currentUserID"].ToString()) { X.Msg.Notify("失败", "<font color='red'>系统不允许删除超级管理员!</font>").Show(); continue; } userinfoMgr mgr = new userinfoMgr(); if (mgr.Del_userinfo(user)) { X.Msg.Notify("成功", "<font color='green'>已经成功删除选中的用户</font>").Show(); } else { X.Msg.Notify("失败", "<font color='green'>删除用户失败,请您重试!</font>").Show(); } } GridPanel1.Reload(); }
//保存用户 protected void BtnSave_Click(object sender, DirectEventArgs e) { userinfoMgr mgr = new userinfoMgr(); if (Hid.Text.Length > 0) {//Update User userinfo user = mgr.FindById_userinfo(int.Parse(Hid.Text)); user.roleid = int.Parse(cboRole.SelectedItem.Value); user.telephone = TxtTel.Text.Trim(); user.email = TxtEmail.Text.Trim(); user.address = TxtAddress.Text.Trim(); if (mgr.Update_userinfo(user)) { WinUser.Hide(); X.Msg.Notify("成功", "用户修改成功").Show(); GridPanel1.Reload(); } else { MsgShow("失败", "用户修改失败,请重试"); } } else {//ADD User if (mgr.FindById_userinfo(TxtUserName.Text.Trim()) != null) { MsgShow("提示", "该用户已存在,请使用其他用户名"); return; } userinfo user = new userinfo(); user.username = TxtUserName.Text.Trim(); user.roleid = int.Parse(cboRole.SelectedItem.Value); user.telephone = TxtTel.Text.Trim(); user.password = CJ_DBOperater.CJ.PwdSecurity("123456"); user.logintime = DateTime.Now.ToString(); user.createtime = DateTime.Now.ToString(); user.email = TxtEmail.Text.Trim(); user.address = TxtAddress.Text.Trim(); if (mgr.Add_userinfo(user)) { WinUser.Hide(); X.Msg.Notify("成功", "<font color='green'>用户添加成功,默认密码123456</font>").Show(); GridPanel1.Reload(); } else { MsgShow("失败", "用户添加失败,请重试"); } } }
//双击Grid的列,弹出修改框 protected void GridDBClick(object sender, DirectEventArgs e) { userinfoMgr mgr = new userinfoMgr(); userinfo user = mgr.FindById_userinfo(int.Parse(e.ExtraParams["id"])); if (user != null) { TxtUserName.Text = user.username; TxtTel.Text = user.telephone; TxtEmail.Text = user.email; cboRole.Value = user.roleid; TxtAddress.Text = user.address; Hid.Text = user.userid.ToString(); WinUser.Show(); } }