2024-07-27 01:44:19 +00:00
|
|
|
|
using DevExpress.XtraBars.ToolbarForm;
|
|
|
|
|
using DevExpress.XtraEditors;
|
|
|
|
|
using DevExpress.XtraEditors.DXErrorProvider;
|
|
|
|
|
using DeviceRepair.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using TsSFCDevice.Client.Biz.Impl;
|
|
|
|
|
|
|
|
|
|
namespace TsSFCDevice.Client.Launch.Maintain
|
|
|
|
|
{
|
|
|
|
|
public partial class pageMaintainEdit : ToolbarForm
|
|
|
|
|
{
|
|
|
|
|
public DeviceWarrantyRequestFormView CurrentRequestForm = null;
|
|
|
|
|
public List<DeviceWarrantyRequestAccessoriesInfo> Accessories = null;
|
|
|
|
|
|
2024-08-02 02:52:45 +00:00
|
|
|
|
#region 控件值转字段
|
2024-07-27 01:44:19 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 现象区分
|
|
|
|
|
/// </summary>
|
|
|
|
|
int SymptomlDistinction
|
|
|
|
|
{
|
|
|
|
|
get { return Convert.ToInt32(ddlSymptomlDistinction.EditValue); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 维修方式
|
|
|
|
|
/// </summary>
|
|
|
|
|
int Maintenance
|
|
|
|
|
{
|
|
|
|
|
get { return Convert.ToInt32(ddlMaintenance.EditValue); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 开始时间
|
|
|
|
|
/// </summary>
|
|
|
|
|
DateTime StartTime
|
|
|
|
|
{
|
|
|
|
|
get { return Convert.ToDateTime(de_StartDate.EditValue); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 结束时间
|
|
|
|
|
/// </summary>
|
|
|
|
|
DateTime EndTime
|
|
|
|
|
{
|
|
|
|
|
get { return Convert.ToDateTime(de_EndDate.EditValue); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 故障原因
|
|
|
|
|
/// </summary>
|
|
|
|
|
string MaintainCause
|
|
|
|
|
{
|
|
|
|
|
get { return txtCause.EditValue?.ToString()?.Trim(); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 维修内容
|
|
|
|
|
/// </summary>
|
|
|
|
|
string MaintainContent
|
|
|
|
|
{
|
|
|
|
|
get { return txtContent.EditValue?.ToString()?.Trim(); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否需要验证
|
|
|
|
|
/// </summary>
|
|
|
|
|
bool NeedValidate
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
get { return (bool)ckbNeedValidate.EditValue; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 二次验证的理由
|
|
|
|
|
/// </summary>
|
|
|
|
|
string MaintaionReason
|
|
|
|
|
{
|
|
|
|
|
get { return txtReason.EditValue?.ToString()?.Trim() ?? ""; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 验证编号
|
|
|
|
|
/// </summary>
|
|
|
|
|
string ValidateNo
|
|
|
|
|
{
|
|
|
|
|
get { return txtNo.EditValue?.ToString()?.Trim() ?? ""; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否停机(停机状态)
|
|
|
|
|
/// </summary>
|
|
|
|
|
bool IsDown
|
|
|
|
|
{
|
|
|
|
|
get { return (bool)ckbIsDown.EditValue; }
|
|
|
|
|
}
|
2024-08-02 02:52:45 +00:00
|
|
|
|
#endregion
|
2024-07-27 01:44:19 +00:00
|
|
|
|
|
|
|
|
|
public pageMaintainEdit() : this(null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public pageMaintainEdit(DeviceWarrantyRequestFormView qequestForm)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
CurrentRequestForm = qequestForm;
|
|
|
|
|
this.Load += PageMaintainEdit_Load;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PageMaintainEdit_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
InitializeLookupControl();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
layoutControlItem9.Enabled = !NeedValidate;
|
|
|
|
|
layoutControlItem10.Enabled = NeedValidate;
|
|
|
|
|
|
|
|
|
|
de_StartDate.EditValue = CurrentRequestForm.CreatOn.Value;
|
|
|
|
|
de_EndDate.EditValue = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
if (CurrentRequestForm != null && CurrentRequestForm.MaintaionItems != null)
|
|
|
|
|
{
|
|
|
|
|
// 现象区分
|
|
|
|
|
ddlSymptomlDistinction.EditValue = CurrentRequestForm.MaintaionItems.SymptomlDistinction;
|
|
|
|
|
|
|
|
|
|
// 维修方式
|
|
|
|
|
ddlMaintenance.EditValue = CurrentRequestForm.MaintaionItems.Maintenance;
|
|
|
|
|
|
|
|
|
|
// 开始时间
|
|
|
|
|
de_StartDate.EditValue = CurrentRequestForm.MaintaionItems.MaintainStartTime;
|
|
|
|
|
|
|
|
|
|
// 结束时间
|
|
|
|
|
de_EndDate.EditValue = CurrentRequestForm.MaintaionItems.MaintainEndTime;
|
|
|
|
|
|
|
|
|
|
// 故障原因
|
|
|
|
|
txtCause.EditValue = CurrentRequestForm.MaintaionItems.MaintainCause;
|
|
|
|
|
|
|
|
|
|
// 故障内容
|
|
|
|
|
txtContent.EditValue = CurrentRequestForm.MaintaionItems.MaintainContent;
|
|
|
|
|
|
|
|
|
|
// 配件
|
|
|
|
|
if (CurrentRequestForm.MaintaionItems.AccessoriesItems != null && CurrentRequestForm.MaintaionItems.AccessoriesItems.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
Accessories = CurrentRequestForm.MaintaionItems.AccessoriesItems;
|
|
|
|
|
string[] AccessoriesLst = Accessories.Select(x => x.FieldName).ToArray();
|
|
|
|
|
txt_Accessories.EditValue = string.Join(";", AccessoriesLst);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 是否需要再验证
|
|
|
|
|
ckbNeedValidate.EditValue = CurrentRequestForm.MaintaionItems.BeValidate;
|
|
|
|
|
|
|
|
|
|
// 理由
|
|
|
|
|
txtReason.EditValue = CurrentRequestForm.MaintaionItems.Reason ?? "";
|
|
|
|
|
|
|
|
|
|
// 验证编码
|
|
|
|
|
txtNo.EditValue = CurrentRequestForm.MaintaionItems.ValidateNo ?? "";
|
|
|
|
|
|
|
|
|
|
// 是否停机
|
|
|
|
|
ckbIsDown.EditValue = CurrentRequestForm.IsDown;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
XtraMessageBoxHelper.Error(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void InitializeLookupControl()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
splashScreenManager1.ShowWaitForm();
|
|
|
|
|
|
|
|
|
|
IList<FieldsInfo> SelectionDatas = CustomFieldRepository.Instance.GetDatas(("SymptomlDistinction,Maintenance").Split(','));
|
|
|
|
|
|
2024-09-29 14:22:39 +00:00
|
|
|
|
ddlSymptomlDistinction.Properties.DataSource = SelectionDatas.Where(x => x.FieldCode.Equals("SymptomlDistinction", StringComparison.CurrentCultureIgnoreCase) && x.Status).ToList();
|
2024-07-27 01:44:19 +00:00
|
|
|
|
ddlSymptomlDistinction.Properties.DisplayMember = "FieldText";
|
|
|
|
|
ddlSymptomlDistinction.Properties.ValueMember = "AutoID";
|
|
|
|
|
ddlSymptomlDistinction.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
|
|
|
|
|
if (ddlSymptomlDistinction.Properties.DataSource != null && (ddlSymptomlDistinction.Properties.DataSource as List<FieldsInfo>).Count > 0)
|
|
|
|
|
{
|
|
|
|
|
ddlSymptomlDistinction.EditValue = (ddlSymptomlDistinction.Properties.DataSource as List<FieldsInfo>)[0].AutoID;
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-29 14:22:39 +00:00
|
|
|
|
ddlMaintenance.Properties.DataSource = SelectionDatas.Where(x => x.FieldCode.Equals("Maintenance", StringComparison.CurrentCultureIgnoreCase) && x.Status).ToList();
|
2024-07-27 01:44:19 +00:00
|
|
|
|
ddlMaintenance.Properties.DisplayMember = "FieldText";
|
|
|
|
|
ddlMaintenance.Properties.ValueMember = "AutoID";
|
|
|
|
|
ddlMaintenance.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
|
|
|
|
|
if (ddlMaintenance.Properties.DataSource != null && (ddlMaintenance.Properties.DataSource as List<FieldsInfo>).Count > 0)
|
|
|
|
|
{
|
|
|
|
|
ddlMaintenance.EditValue = (ddlMaintenance.Properties.DataSource as List<FieldsInfo>)[0].AutoID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
splashScreenManager1.TryCloseWait();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
splashScreenManager1.TryCloseWait();
|
|
|
|
|
XtraMessageBoxHelper.Error(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化验证控件
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void InitializeValidationProvider()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
List<BaseEdit> param = new List<BaseEdit> { ddlSymptomlDistinction, ddlMaintenance, de_StartDate, de_EndDate, txtCause, txtContent };
|
|
|
|
|
foreach (var item in param)
|
|
|
|
|
{
|
|
|
|
|
dxValidationProvider1.RemoveControlError(item);
|
|
|
|
|
}
|
|
|
|
|
dxValidationProvider1.RemoveControlError(txtNo);
|
|
|
|
|
dxValidationProvider1.RemoveControlError(txtReason);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dxValidationProvider1 = new DXValidationProvider();
|
|
|
|
|
|
|
|
|
|
//实例化一个必填规则,错误提示为:该字段不能为空
|
|
|
|
|
ConditionValidationRule required = new ConditionValidationRule("RequiredRule", ConditionOperator.IsNotBlank) { ErrorText = $"字段不能为空" };
|
|
|
|
|
|
|
|
|
|
if (NeedValidate)
|
|
|
|
|
{
|
|
|
|
|
param.Add(txtNo);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
param.Add(txtReason);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < param.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
string FieldName = Root.Items.FirstOrDefault(x => (x as DevExpress.XtraLayout.LayoutControlItem).Control == param[i])?.Text;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
required.ErrorText = $"字段:{FieldName.Replace(":", "")} 不能为空";
|
|
|
|
|
|
|
|
|
|
dxValidationProvider1.SetValidationRule(param[i], required);
|
|
|
|
|
dxValidationProvider1.SetIconAlignment(param[i], ErrorIconAlignment.MiddleRight);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
XtraMessageBoxHelper.Error(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 配件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void btn_AccessoriesEdit_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using (dlgAccessoriesEdit dlg = new dlgAccessoriesEdit(Accessories))
|
|
|
|
|
{
|
|
|
|
|
if (dlg.ShowDialog(this) == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
Accessories = dlg.CurrentAccessories;
|
|
|
|
|
string[] AccessoriesLst = dlg.CurrentAccessories.Select(x => x.FieldName).ToArray();
|
|
|
|
|
txt_Accessories.EditValue = string.Join(";", AccessoriesLst);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ckbNeedValidate_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
layoutControlItem9.Enabled = !NeedValidate;
|
|
|
|
|
layoutControlItem10.Enabled = NeedValidate;
|
|
|
|
|
|
|
|
|
|
if (NeedValidate)
|
|
|
|
|
{
|
|
|
|
|
txtNo.EditValue = "";
|
|
|
|
|
txtReason.EditValue = "N/A";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
txtReason.EditValue = "";
|
|
|
|
|
txtNo.EditValue = "N/A";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 关闭窗体前 先保存数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void pageMaintainEdit_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (DialogResult == DialogResult.OK)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (MaintenanceRepository.Instance.DataBeSubmit(CurrentRequestForm.AutoID))
|
|
|
|
|
return;
|
|
|
|
|
|
2024-08-02 02:52:45 +00:00
|
|
|
|
DeviceRepair.Models.DeviceMaintenance.DeviceWarrantyRequestMaintaionInfo Entity = new DeviceRepair.Models.DeviceMaintenance.DeviceWarrantyRequestMaintaionInfo
|
2024-07-27 01:44:19 +00:00
|
|
|
|
{
|
2024-08-02 02:52:45 +00:00
|
|
|
|
//AccessoriesItems = Accessories,
|
2024-07-27 01:44:19 +00:00
|
|
|
|
BeValidate = NeedValidate,
|
|
|
|
|
FormID = CurrentRequestForm.AutoID,
|
|
|
|
|
MaintainCause = MaintainCause,
|
|
|
|
|
MaintainContent = MaintainContent,
|
|
|
|
|
MaintainStartTime = StartTime,
|
|
|
|
|
MaintainEndTime = EndTime,
|
|
|
|
|
Maintenance = Maintenance,
|
|
|
|
|
SymptomlDistinction = SymptomlDistinction,
|
|
|
|
|
Reason = MaintaionReason,
|
2024-08-02 02:52:45 +00:00
|
|
|
|
ValidateNo = ValidateNo
|
2024-07-27 01:44:19 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (CurrentRequestForm.MaintaionItems != null)
|
|
|
|
|
{
|
|
|
|
|
Entity.AutoID = CurrentRequestForm.MaintaionItems.AutoID;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-02 02:52:45 +00:00
|
|
|
|
APIResponseData apiResponseData = MaintenanceRepository.Instance.Insert(Entity, Accessories ?? new List<DeviceWarrantyRequestAccessoriesInfo>());
|
2024-07-27 01:44:19 +00:00
|
|
|
|
if (!apiResponseData.IsSuccess)
|
|
|
|
|
throw new Exception(apiResponseData.Message);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
InitializeValidationProvider();
|
|
|
|
|
if (dxValidationProvider1.Validate())
|
|
|
|
|
{
|
|
|
|
|
if (StartTime > EndTime)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception($"修理结束时间在修理开始时间之后!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 故障原因
|
|
|
|
|
if (string.IsNullOrWhiteSpace(MaintainCause))
|
|
|
|
|
{
|
|
|
|
|
dxErrorProvider1.SetError(txtCause, $"字段:故障原因 不能为空");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 维修内容
|
|
|
|
|
if (string.IsNullOrWhiteSpace(MaintainContent))
|
|
|
|
|
{
|
|
|
|
|
dxErrorProvider1.SetError(txtContent, $"字段:维修内容 不能为空");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 理由 | 验证编码
|
|
|
|
|
if (NeedValidate && string.IsNullOrWhiteSpace(ValidateNo))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
dxErrorProvider1.SetError(txtNo, $"字段:验证编码 不能为空");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (!NeedValidate && string.IsNullOrWhiteSpace(MaintaionReason))
|
|
|
|
|
{
|
|
|
|
|
dxErrorProvider1.SetError(txtReason, $"字段:理由 不能为空");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-02 02:52:45 +00:00
|
|
|
|
DeviceRepair.Models.DeviceMaintenance.DeviceWarrantyRequestMaintaionInfo Entity = new DeviceRepair.Models.DeviceMaintenance.DeviceWarrantyRequestMaintaionInfo
|
2024-07-27 01:44:19 +00:00
|
|
|
|
{
|
2024-08-02 02:52:45 +00:00
|
|
|
|
//AccessoriesItems = Accessories,
|
2024-07-27 01:44:19 +00:00
|
|
|
|
BeValidate = NeedValidate,
|
|
|
|
|
FormID = CurrentRequestForm.AutoID,
|
|
|
|
|
MaintainCause = MaintainCause,
|
|
|
|
|
MaintainContent = MaintainContent,
|
|
|
|
|
MaintainStartTime = StartTime,
|
|
|
|
|
MaintainEndTime = EndTime,
|
|
|
|
|
Maintenance = Maintenance,
|
|
|
|
|
SymptomlDistinction = SymptomlDistinction,
|
|
|
|
|
Reason = MaintaionReason,
|
2024-08-02 02:52:45 +00:00
|
|
|
|
ValidateNo = ValidateNo
|
2024-07-27 01:44:19 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (CurrentRequestForm.MaintaionItems != null)
|
|
|
|
|
{
|
|
|
|
|
Entity.AutoID = CurrentRequestForm.MaintaionItems.AutoID;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-02 02:52:45 +00:00
|
|
|
|
APIResponseData apiResponseData = MaintenanceRepository.Instance.Insert(Entity, Accessories ?? new List<DeviceWarrantyRequestAccessoriesInfo>(), true);
|
2024-07-27 01:44:19 +00:00
|
|
|
|
if (!apiResponseData.IsSuccess)
|
|
|
|
|
throw new Exception(apiResponseData.Message);
|
|
|
|
|
|
|
|
|
|
this.DialogResult = DialogResult.OK;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
XtraMessageBoxHelper.Error(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|