public ActionResult Update(user User) { if (ModelState.IsValid) { var dao = new RegisterDao(); if (!string.IsNullOrEmpty(User.MK)) { var encryptedMD5Pass = Encryptor.MD5Hash(User.MK); // đọc mã hóa và mã hóa mật khẩu User.MK = encryptedMD5Pass; } bool result = dao.Update(User); if (result) { return(RedirectToAction("Update", "DangKy")); } else { ModelState.AddModelError("", "Cập nhật user thất bại"); } } return(View("Detail", "DangKy")); }
/// <summary> /// 保存 /// </summary> private void saveInfo() { Register register = getPrintInfo(); try { if (this.isUpdate) { RegisterDao.Update(register); } else { object id = RegisterDao.Add(register); MessageBox.Show("当前流水号为 " + id); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } }
/// <summary> /// 保存按钮点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void saveBtn_Click(object sender, EventArgs e) { this.ValidateChildren(ValidationConstraints.Enabled & ValidationConstraints.TabStop & ValidationConstraints.Selectable); if (Utilities.IsNullOrEmpty(apply.Text) && apply.Enabled) { applyErrorProvider.SetError(apply, "不能为空!"); } else { applyErrorProvider.Clear(); } if (!VTMS.ControlLib.ValidatorManager.ValidateControls(this)) { MessageBox.Show("控件内容不合法"); return; } Register register = getRegisterInfo(); try { if (this.isUpdate) { RegisterDao.Update(register); } else { object id = RegisterDao.Add(register); MessageBox.Show("当前流水号为 " + id); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } this.isUpdate = true; }