//保存用户 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(); } }