diff --git a/WindowsFormsApp6/Form3.cs b/WindowsFormsApp6/Form3.cs index 6489898..d5d4e42 100644 --- a/WindowsFormsApp6/Form3.cs +++ b/WindowsFormsApp6/Form3.cs @@ -35,9 +35,10 @@ namespace WindowsFormsApp6 private System.Windows.Forms.Timer dataTimer; private System.Windows.Forms.Timer clockTimer; private DataTable sampleDataTable; - private int currentSampleCount = 5; // 当前试样数量,可动态调整 + private int currentSampleCount = 5; // 当前试样数量,固定为5(最多5组,共15次测试) private readonly Random random = new Random(); private bool isVerticalLayout = true; // true=纵向(当前),false=横向 + private const int MAX_SAMPLE_COUNT = 5; // 最大试样数量限制为5 #endregion public Form3() @@ -50,13 +51,16 @@ namespace WindowsFormsApp6 } /// - /// 设置试样数量(1-20) + /// 设置试样数量(1-5) + /// Form3限定为最多5组试样,每组3次测试,共15次测试数据 /// 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; } diff --git a/WindowsFormsApp6/MainForm.cs b/WindowsFormsApp6/MainForm.cs index 5abe910..f23c436 100644 --- a/WindowsFormsApp6/MainForm.cs +++ b/WindowsFormsApp6/MainForm.cs @@ -1183,8 +1183,23 @@ namespace WindowsFormsApp6 int sampleIndex = position.Item1; // 试样索引(1-based) int testIndex = position.Item2; // 测试次数(1-3) - // 如果需要扩展试样数量(动态增长) - if (sampleIndex > currentSampleCount) + // Form3限制:最多5组试样(15次测试) + 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; currentSampleCountField.SetValue(form3Instance, currentSampleCount); @@ -1774,7 +1789,7 @@ namespace WindowsFormsApp6 cell27.CellStyle = styles.dataStyle; ICell cell28 = infoRow2.CreateCell(9); - cell28.SetCellValue("(报告保存路径)"); + cell28.SetCellValue(""); cell28.CellStyle = styles.yellowStyle; }