using DevExpress.XtraEditors; using DeviceRepair.Models; using DeviceRepair.Models.Enum; using DeviceRepair.Utils; using System; using System.Linq; using System.Windows.Forms; using TsSFCDevice.Client.Biz.Impl; namespace TsSFCDevice.Client.Launch.Common { public partial class pageSignature : XtraForm { /// /// 操作人 /// public string OperateBy { get { return bTxtUserCode.Text.Trim(); } } /// /// 操作人密码 /// public string OperateByPwd { get { return bTxtPassword.Text.Trim(); } } /// /// 备注 /// public string ConfirmNotes { get { return bTxtNotes.Text.Trim(); } } /// /// 待认证的权限字符串 /// public string AuthString { get; set; } private UserConfirmModel m_ConfirmModel; public UserConfirmModel ConfirmModel { get { return m_ConfirmModel; } set { m_ConfirmModel = value; } } /// /// 验证内容描述 /// public string ConfirmContent { get; set; } public bool? NeedNotes { get; set; } public bool? CanNa { get; set; } public int NoteMaxLen { get; set; } = 200; public ApiOperationRtn OperationResult; public pageSignature() { InitializeComponent(); } private void pageSignature_Load(object sender, EventArgs e) { try { Text = $"用户确认-{ConfirmContent}"; } catch (Exception ex) { XtraMessageBoxHelper.Error(ex.Message); } } private void btnCancel_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; } private void btnOK_Click(object sender, EventArgs e) { try { if (string.IsNullOrWhiteSpace(OperateBy)) { XtraMessageBoxHelper.Error("请录入账号!"); bTxtUserCode.Focus(); return; } if (OperateBy.Length > 50) { XtraMessageBoxHelper.Error("输入的账号长度不正确!"); bTxtUserCode.Focus(); return; } if (string.IsNullOrEmpty(OperateByPwd)) { XtraMessageBoxHelper.Error("请录入密码!"); bTxtPassword.Focus(); return; } if (OperateByPwd.Length > 200) { XtraMessageBoxHelper.Error("输入的密码长度不正确!"); bTxtUserCode.Focus(); return; } if (NeedNotes ?? false) { if (string.IsNullOrEmpty(ConfirmNotes)) { XtraMessageBoxHelper.Error("备注必须录入,请录入备注!"); bTxtNotes.Focus(); return; } if (!CanNa ?? true) { if (ConfirmNotes.Equals("NA", StringComparison.CurrentCultureIgnoreCase) || ConfirmNotes.Equals("N/A", StringComparison.CurrentCultureIgnoreCase)) { XtraMessageBoxHelper.Error("备注必须录入且不允许为N/A或NA,请录入备注!"); bTxtNotes.Focus(); return; } } if (ConfirmNotes.Length > NoteMaxLen) { XtraMessageBoxHelper.Error($"备注必须录入且长度不允许大于{NoteMaxLen},请检查!"); bTxtNotes.Focus(); return; } System.Data.DataTable dtTable = null; APIResponseData apiResponseData = UserRepository.Instance.UserConfirm(new DeviceRepair.Models.History.UserConfirmHistory { bSuccess = false, cContent = ConfirmContent, cModel = ConfirmModel.Description(), ConfirmAuth = AuthString, UserCode = OperateBy, PassWord = DeviceRepair.Utils.Security.DESEncrypt.Encrypt(OperateByPwd), Note = ConfirmNotes },out dtTable); if (!apiResponseData.IsSuccess) throw new Exception(apiResponseData.Message); OperationResult = DTOHelper.DataTableToList(dtTable)?.FirstOrDefault(); DialogResult = DialogResult.OK; } } catch (Exception ex) { XtraMessageBoxHelper.Error(ex.Message); } } } }