DeviceManager/TsSFCDevice.Client.Launch/PreserveTemplate/Template_AM_17.cs
2024-07-27 09:44:19 +08:00

170 lines
6.6 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using DevExpress.Spreadsheet;
using DevExpress.Utils.Menu;
using DevExpress.XtraSpreadsheet.Menu;
using DeviceRepair.Models;
using DeviceRepair.Models.Enum;
using TsSFCDevice.Client.Launch.Common.NpoiExtend;
namespace TsSFCDevice.Client.Launch.PreserveTemplate
{
public class Template_AM_17 : BaseTemplate
{
/// <summary>
/// 设备名称
/// </summary>
internal readonly string EquipmentNameAddress = "[F,1]";
/// <summary>
/// 安装地点
/// </summary>
internal readonly string InstallationSiteAddress = "[R,1]";
/// <summary>
/// 设备编号
/// </summary>
internal readonly string EquipmentNumberAddress = "[F,2]";
/// <summary>
/// 设备型号
/// </summary>
internal readonly string EquipmentModelAddress = "[R,2]";
/// <summary>
/// 异常处理固定字符
/// </summary>
internal override string ExceptionFreezeString
{
get { return "异常备注:"; }
}
/// <summary>
/// 正文
/// </summary>
internal override SpreadsheetPopupMenu popupContent
{
get
{
if (_popupContent == null)
{
_popupContent = new SpreadsheetPopupMenu()
{
Caption = "正文",
Items =
{
new DXMenuItem("已保养",(s,e)=>{WriteValue(EnumMaintenanceCellType.Content, "√"); }),
new DXMenuItem("未保养",(s,e)=>{WriteValue(EnumMaintenanceCellType.Content, "×", EnumMaintenanceOperationType.Write, true); }),
new DXMenuItem("不适用",(s,e)=>{WriteValue(EnumMaintenanceCellType.Content, "N/A"); }),
new DXMenuItem("清空",(s,e)=>{WriteValue(EnumMaintenanceCellType.Content, "", EnumMaintenanceOperationType.Clear); }),
}
};
}
return _popupContent;
}
}
/// <summary>
/// 其他异常处理
/// </summary>
internal override SpreadsheetPopupMenu popupException
{
get
{
if (_popupException == null)
{
_popupException = new SpreadsheetPopupMenu()
{
Caption = "其他异常处理",
Items =
{
new DXMenuItem("编辑",(s,e)=>
{
WriteValue(EnumMaintenanceCellType.ExceptionDescription, ExceptionFreezeString, EnumMaintenanceOperationType.Write,true);
}),
new DXMenuItem("清空", (a, aa) =>
{
WriteValue(EnumMaintenanceCellType.ExceptionDescription, "", EnumMaintenanceOperationType.Clear);
}),
}
};
}
return _popupException;
}
}
public Template_AM_17() : base()
{
}
/// <summary>
/// 初始化对象
/// </summary>
/// <param name="ws">Worksheet 控件对象</param>
/// <param name="CurrentType">当前计划类型</param>
/// <param name="EditColValue">当前编辑列</param>
public Template_AM_17(Worksheet ws) : base(ws)
{
#region
EquipmentName.Add(SheetExtend.AddressToIndex(EquipmentNameAddress));
#endregion
#region
InstallationSite.Add(SheetExtend.AddressToIndex(InstallationSiteAddress));
#endregion
#region
EquipmentID.Add(SheetExtend.AddressToIndex(EquipmentNumberAddress));
#endregion
#region
DeviceSpecification.Add(SheetExtend.AddressToIndex(EquipmentModelAddress));
#endregion
int JanColIndex = SheetExtend.ColumnIndexFromLetter("O");
int DecColIndex = SheetExtend.ColumnIndexFromLetter("Z");
for (int rowIndex = 4; rowIndex < LastUsedRowIndex; rowIndex++)
{
#region
Cell FirstCell = worksheet.Cells[rowIndex, 0];
if (FirstCell.Value.IsEmpty && !FirstCell.IsMerged)
break;
#endregion
for (int colIndex = JanColIndex; colIndex <= DecColIndex; colIndex++)
{
Cell cell = worksheet.Cells[rowIndex, colIndex];
Cell PreviousCell = worksheet[rowIndex, JanColIndex - 1];
if (PreviousCell.IsMerged)
{
//获取主单元格位置
int PreRowIndex = (PreviousCell.GetMergedRanges()[0]).TopRowIndex;
int PreColumnIndex = (PreviousCell.GetMergedRanges()[0]).LeftColumnIndex;
PreviousCell = worksheet[PreRowIndex, PreColumnIndex];
}
if ((PreviousCell?.Value?.TextValue ?? "") == "保养人签字")
{
// 保养人签字
Operation.Add(new SheetDataItem { RowIndex = rowIndex, ColumnIndex = colIndex, MaintenanceType = EnumMaintenanceType.Monthly, MaintenanceTypeValue = worksheet.Cells[3, colIndex].Value.TextValue + "" });
// 异常备注:
ExceptionDescription.Add(new SheetDataItem { RowIndex = rowIndex, ColumnIndex = 0, MaintenanceType = EnumMaintenanceType.Monthly, MaintenanceTypeValue = worksheet.Cells[3, colIndex].Value.TextValue + "" });
}
else if ((PreviousCell?.Value?.TextValue ?? "") == "保养日期")
{
// 保养日期
OperationDate.Add(new SheetDataItem { RowIndex = rowIndex, ColumnIndex = colIndex, MaintenanceType = EnumMaintenanceType.Monthly, MaintenanceTypeValue = worksheet.Cells[3, colIndex].Value.TextValue + "" });
}
else
{
// 正文
Content.Add(new SheetDataItem { RowIndex = rowIndex, ColumnIndex = colIndex, MaintenanceType = EnumMaintenanceType.Monthly, MaintenanceTypeValue = worksheet.Cells[3, colIndex].Value.TextValue + "" });
}
}
}
}
}
}