private void SaveData() { var userEntity = currentUserEntity; if (string.IsNullOrEmpty(this.ucOSCompanyName.SelectedFullName)) { MessageBoxHelper.ShowWarningMsg(RDIFrameworkMessage.MSG0229); this.ucOSCompanyName.Focus(); return; } if (!BasePageLogic.ControlValueIsEmpty(gbDetail)) { return; } userEntity.Id = currentUserEntity.Id; userEntity.UserName = txtUserName.Text.Trim(); userEntity.RealName = txtRealName.Text.Trim(); userEntity.Code = txtCode.Text.Trim(); userEntity.Gender = cboGender.Text; userEntity.Mobile = txtMobile.Text.Trim(); userEntity.Birthday = DateTimeHelper.ToDate(txtBirthday.Text); userEntity.Telephone = txtTelphone.Text.Trim(); userEntity.Title = txtTitle.Text.Trim(); userEntity.Duty = txtDuty.Text.Trim(); userEntity.QICQ = txtQQ.Text.Trim(); userEntity.Email = txtEmail.Text.Trim(); userEntity.Enabled = chkEnabled.Checked ? 1 : 0; userEntity.RoleId = BusinessLogic.ConvertToString(BasePageLogic.GetComboSelectedValue(cboRoleName, BasePageLogic.ComboBoxValueType.SelectValue)); userEntity.CompanyId = string.IsNullOrEmpty(ucOSCompanyName.SelectedId) ? null : ucOSCompanyName.SelectedId; userEntity.CompanyName = string.IsNullOrEmpty(ucOSCompanyName.SelectedId) ? null : ucOSCompanyName.SelectedFullName; userEntity.SubCompanyId = string.IsNullOrEmpty(ucOSSubCompanyName.SelectedId) ? null : ucOSSubCompanyName.SelectedId; userEntity.SubCompanyName = string.IsNullOrEmpty(ucOSSubCompanyName.SelectedId) ? null : ucOSSubCompanyName.SelectedFullName; userEntity.DepartmentId = string.IsNullOrEmpty(ucOSDepartmentName.SelectedId) ? null : ucOSDepartmentName.SelectedId; userEntity.DepartmentName = string.IsNullOrEmpty(ucOSDepartmentName.SelectedId) ? null : ucOSDepartmentName.SelectedFullName; userEntity.SubDepartmentId = string.IsNullOrEmpty(ucOSSubDepartmentName.SelectedId) ? null : ucOSSubDepartmentName.SelectedId; userEntity.SubDepartmentName = string.IsNullOrEmpty(ucOSSubDepartmentName.SelectedId) ? null : ucOSSubDepartmentName.SelectedFullName; userEntity.WorkgroupId = string.IsNullOrEmpty(ucOSWorkgroupName.SelectedId) ? null : ucOSWorkgroupName.SelectedId; userEntity.WorkgroupName = string.IsNullOrEmpty(ucOSWorkgroupName.SelectedId) ? null : ucOSWorkgroupName.SelectedFullName; userEntity.HomeAddress = txtHomeAddress.Text.Trim(); userEntity.Description = txtDescription.Text.Trim(); if (base.UserInfo != null) { userEntity.ModifiedBy = UserInfo.RealName; userEntity.ModifiedUserId = UserInfo.Id; } // 设置鼠标繁忙状态,并保留原先的状态 var holdCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; try { string statusCode = string.Empty; string statusMessage = string.Empty; userService.UpdateUser(UserInfo, userEntity, out statusCode, out statusMessage); if (statusCode == StatusCode.OKUpdate.ToString()) { this.Changed = true; if (SystemInfo.ShowInformation) { // 添加成功,进行提示 MessageBoxHelper.ShowSuccessMsg(statusMessage); } this.DialogResult = DialogResult.OK; } else { MessageBoxHelper.ShowWarningMsg(statusMessage); if (statusCode == StatusCode.ErrorUserExist.ToString()) { this.txtUserName.SelectAll(); this.txtUserName.Focus(); } // 是否编号重复了,提高友善性 if (statusCode == StatusCode.ErrorCodeExist.ToString()) { this.txtCode.SelectAll(); this.txtCode.Focus(); } } } catch (Exception ex) { this.ProcessException(ex); } finally { // 鼠标正常状态 this.Cursor = holdCursor; } }
public override bool SaveUpdated() { var returnValue = false; var userEntity = currentUserEntity; if (!BasePageLogic.ControlValueIsEmpty(gbDetail)) { return(returnValue); } userEntity.Id = currentUserEntity.Id; userEntity.UserName = txtUserName.Text.Trim(); userEntity.RealName = txtRealName.Text.Trim(); userEntity.Code = txtCode.Text.Trim(); userEntity.Gender = cboGender.Text; userEntity.Mobile = txtMobile.Text.Trim(); userEntity.Birthday = DateTimeHelper.ToDate(txtBirthday.Text); userEntity.Telephone = txtTelphone.Text.Trim(); userEntity.Title = txtTitle.Text.Trim(); userEntity.Duty = txtDuty.Text.Trim(); userEntity.QICQ = txtQQ.Text.Trim(); userEntity.Email = txtEmail.Text.Trim(); userEntity.Enabled = chkEnabled.Checked ? 1 : 0; userEntity.RoleId = BusinessLogic.ConvertToString(BasePageLogic.GetComboSelectedValue(cboRoleName, BasePageLogic.ComboBoxValueType.SelectValue)); userEntity.CompanyId = string.IsNullOrEmpty(ucOSCompanyName.SelectedId) ? null : ucOSCompanyName.SelectedId; userEntity.CompanyName = string.IsNullOrEmpty(ucOSCompanyName.SelectedId) ? null : ucOSCompanyName.SelectedFullName; userEntity.SubCompanyId = string.IsNullOrEmpty(ucOSSubCompanyName.SelectedId) ? null : ucOSSubCompanyName.SelectedId; userEntity.SubCompanyName = string.IsNullOrEmpty(ucOSSubCompanyName.SelectedId) ? null : ucOSSubCompanyName.SelectedFullName; userEntity.DepartmentId = string.IsNullOrEmpty(ucOSDepartmentName.SelectedId) ? null : ucOSDepartmentName.SelectedId; userEntity.DepartmentName = string.IsNullOrEmpty(ucOSDepartmentName.SelectedId) ? null : ucOSDepartmentName.SelectedFullName; userEntity.SubDepartmentId = string.IsNullOrEmpty(ucOSSubDepartmentName.SelectedId) ? null : ucOSSubDepartmentName.SelectedId; userEntity.SubDepartmentName = string.IsNullOrEmpty(ucOSSubDepartmentName.SelectedId) ? null : ucOSSubDepartmentName.SelectedFullName; userEntity.WorkgroupId = string.IsNullOrEmpty(ucOSWorkgroupName.SelectedId) ? null : ucOSWorkgroupName.SelectedId; userEntity.WorkgroupName = string.IsNullOrEmpty(ucOSWorkgroupName.SelectedId) ? null : ucOSWorkgroupName.SelectedFullName; userEntity.HomeAddress = txtHomeAddress.Text.Trim(); userEntity.Description = txtDescription.Text.Trim(); if (base.UserInfo != null) { userEntity.ModifiedBy = UserInfo.RealName; userEntity.ModifiedUserId = UserInfo.Id; } string statusCode = string.Empty; string statusMessage = string.Empty; userService.UpdateUser(UserInfo, userEntity, out statusCode, out statusMessage); if (statusCode == StatusCode.OKUpdate.ToString()) { returnValue = true; } else { MessageBoxHelper.ShowWarningMsg(statusMessage); if (statusCode == StatusCode.ErrorUserExist.ToString()) { this.txtUserName.SelectAll(); this.txtUserName.Focus(); } // 是否编号重复了,提高友善性 if (statusCode == StatusCode.ErrorCodeExist.ToString()) { this.txtCode.SelectAll(); this.txtCode.Focus(); } returnValue = false; } return(returnValue); }