DeviceManager/TsSFCDevice.Client.Launch/Common/pageSignature.cs

190 lines
5.5 KiB
C#
Raw Normal View History

2024-08-02 02:52:45 +00:00
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
{
/// <summary>
/// 操作人
/// </summary>
public string OperateBy
{
get
{
return bTxtUserCode.Text.Trim();
}
}
/// <summary>
/// 操作人密码
/// </summary>
public string OperateByPwd
{
get
{
return bTxtPassword.Text.Trim();
}
}
/// <summary>
/// 备注
/// </summary>
public string ConfirmNotes
{
get
{
return bTxtNotes.Text.Trim();
}
}
/// <summary>
/// 待认证的权限字符串
/// </summary>
public string AuthString
{
get; set;
}
private UserConfirmModel m_ConfirmModel;
public UserConfirmModel ConfirmModel
{
get
{
return m_ConfirmModel;
}
set
{
m_ConfirmModel = value;
}
}
/// <summary>
/// 验证内容描述
/// </summary>
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<ApiOperationRtn>.DataTableToList(dtTable)?.FirstOrDefault();
DialogResult = DialogResult.OK;
}
}
catch (Exception ex)
{
XtraMessageBoxHelper.Error(ex.Message);
}
}
}
}