private void BtnOk_Click(object sender, RoutedEventArgs e) { string _old = txt_Old.Text.Trim(); string _new = txt_New.Text.Trim(); if (string.IsNullOrEmpty(_old) || string.IsNullOrEmpty(_new)) { MyFormExtensionMethods.MessageBoxShow("内容不能为空!", "错误"); return; } var user = viewModel.userService.QueryableToEntity(x => x.id == viewModel.EditModel.id); if (user.user_password != _old) { MyFormExtensionMethods.MessageBoxShow("原密码错误!", "错误"); return; } else { viewModel.EditModel.user_password = _new; bool re = viewModel.userService.UpdateEntity(viewModel.EditModel); if (re) { MyFormExtensionMethods.MessageBoxShow("修改成功!", "提示"); this.Close(); } else { MyFormExtensionMethods.MessageBoxShow("修改失败!", "错误"); } } }
private void BtnOk_Click(object sender, RoutedEventArgs e) { if (txtUserName.Text.Length == 0) { MyFormExtensionMethods.MessageBoxShow("用户名称长度为0!", "错误"); return; } if (txtPassword.Text.Length == 0) { MyFormExtensionMethods.MessageBoxShow("密码长度为0!", "错误"); return; } if (viewModel.EditModel.user_type > GloableUserInfo.LoginUser.user_type) { MyFormExtensionMethods.MessageBoxShow("用户的级别大于当前登录用户等级,不能添加!", "错误"); return; } if (viewModel.EditModel.id == 0)//新建模式 { if (viewModel.userService.QueryableToEntity(x => x.user_name == txtUserName.Text) != null) { MyFormExtensionMethods.MessageBoxShow("该用户名已存在!", "错误"); return; } if (viewModel.userService.Insert(viewModel.EditModel)) { MyFormExtensionMethods.MessageBoxShow("添加成功!", "提示"); viewModel.ModelList.Add(viewModel.EditModel); this.Close(); } else { MyFormExtensionMethods.MessageBoxShow("添加失败!", "错误"); } } else { if (viewModel.userService.Update(viewModel.EditModel)) { MyFormExtensionMethods.MessageBoxShow("修改成功!"); CancelBit = false; this.Close(); } else { MyFormExtensionMethods.MessageBoxShow("修改失败!"); } } }