This commit is contained in:
GukSang.Jin
2026-01-05 17:24:49 +08:00
parent b1338a3f03
commit f9f66b7a94
2 changed files with 26 additions and 7 deletions

View File

@@ -35,9 +35,10 @@ namespace WindowsFormsApp6
private System.Windows.Forms.Timer dataTimer; private System.Windows.Forms.Timer dataTimer;
private System.Windows.Forms.Timer clockTimer; private System.Windows.Forms.Timer clockTimer;
private DataTable sampleDataTable; private DataTable sampleDataTable;
private int currentSampleCount = 5; // 当前试样数量,可动态调整 private int currentSampleCount = 5; // 当前试样数量,固定为5最多5组共15次测试
private readonly Random random = new Random(); private readonly Random random = new Random();
private bool isVerticalLayout = true; // true=纵向当前false=横向 private bool isVerticalLayout = true; // true=纵向当前false=横向
private const int MAX_SAMPLE_COUNT = 5; // 最大试样数量限制为5
#endregion #endregion
public Form3() public Form3()
@@ -50,13 +51,16 @@ namespace WindowsFormsApp6
} }
/// <summary> /// <summary>
/// 设置试样数量1-20 /// 设置试样数量1-5
/// Form3限定为最多5组试样每组3次测试共15次测试数据
/// </summary> /// </summary>
public void SetSampleCount(int count) public void SetSampleCount(int count)
{ {
if (count < 1 || count > 20) if (count < 1 || count > MAX_SAMPLE_COUNT)
{ {
ShowMessage("试样数量必须在1-20之间", "参数错误", MessageBoxIcon.Warning); ShowMessage($"试样数量必须在1-{MAX_SAMPLE_COUNT}之间\n" +
$"Form3限定为最多{MAX_SAMPLE_COUNT}组试样(共{MAX_SAMPLE_COUNT * 3}次测试)",
"参数错误", MessageBoxIcon.Warning);
return; return;
} }

View File

@@ -1183,8 +1183,23 @@ namespace WindowsFormsApp6
int sampleIndex = position.Item1; // 试样索引1-based int sampleIndex = position.Item1; // 试样索引1-based
int testIndex = position.Item2; // 测试次数1-3 int testIndex = position.Item2; // 测试次数1-3
// 如果需要扩展试样数量(动态增长 // Form3限制最多5组试样15次测试
if (sampleIndex > currentSampleCount) const int MAX_FORM3_SAMPLES = 5;
// 如果超过最大试样数量,显示警告并停止
if (sampleIndex > MAX_FORM3_SAMPLES)
{
this.Invoke(new Action(() =>
{
MessageBox.Show($"Form3已达到最大试样数量限制{MAX_FORM3_SAMPLES}组,共{MAX_FORM3_SAMPLES * 3}次测试)\n" +
"无法继续添加数据。",
"数据已满", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}));
return;
}
// 如果需要扩展试样数量(动态增长,但不超过最大值)
if (sampleIndex > currentSampleCount && sampleIndex <= MAX_FORM3_SAMPLES)
{ {
currentSampleCount = sampleIndex; currentSampleCount = sampleIndex;
currentSampleCountField.SetValue(form3Instance, currentSampleCount); currentSampleCountField.SetValue(form3Instance, currentSampleCount);
@@ -1774,7 +1789,7 @@ namespace WindowsFormsApp6
cell27.CellStyle = styles.dataStyle; cell27.CellStyle = styles.dataStyle;
ICell cell28 = infoRow2.CreateCell(9); ICell cell28 = infoRow2.CreateCell(9);
cell28.SetCellValue("(报告保存路径)"); cell28.SetCellValue("");
cell28.CellStyle = styles.yellowStyle; cell28.CellStyle = styles.yellowStyle;
} }