fg_yida_2/YiDa_WinForm/Form/RodTestUploadForm.cs
2026-02-03 10:08:13 +08:00

100 lines
2.9 KiB
C#
Raw 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 System;
using System.Windows.Forms;
namespace YiDa_WinForm
{
public partial class RodTestUploadForm : Form
{
public int RodTimedIntervalOne { get; private set; }
public int RodTimedIntervalTwo { get; private set; }
public string DeviceCode;
// 带完整参数的构造函数
public RodTestUploadForm(int lastInterval, string deviceCode)
{
InitializeComponent();
if (deviceCode.Contains("1"))
{
DeviceCode = deviceCode;
RodTimedIntervalOne = lastInterval > 0 ? lastInterval : 120;
InitFormControl("1");
}
else
{
DeviceCode = deviceCode;
RodTimedIntervalTwo = lastInterval > 0 ? lastInterval : 120;
InitFormControl("2");
}
}
/// <summary>
/// 初始化控件状态
/// </summary>
private void InitFormControl(string deviceCode)
{
if (deviceCode.Contains("1"))
{
// 初始化间隔输入框
textBoxInterval.Text = RodTimedIntervalOne.ToString();
}
else
{
textBoxInterval.Text = RodTimedIntervalTwo.ToString();
}
}
// 确定按钮点击事件
private void buttonConfirm_Click(object sender, EventArgs e)
{
// 1. 校验时间间隔(仅当勾选报警时校验)
if (int.TryParse(textBoxInterval.Text, out int interval) && interval > 0)
{
if (DeviceCode.Contains("1"))
{
RodTimedIntervalOne = interval;
}
else
{
RodTimedIntervalTwo = interval;
}
}
else
{
MessageBox.Show("请输入有效的正整数时间间隔!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
// 2. 关闭弹窗返回OK结果
DialogResult = DialogResult.OK;
Close();
}
// 取消按钮点击事件
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
// 无用事件(保留,避免设计器报错)
private void label1_Click(object sender, EventArgs e)
{
}
private void textBoxInterval_TextChanged(object sender, EventArgs e)
{
}
private void labelInterval_Click(object sender, EventArgs e)
{
throw new System.NotImplementedException();
}
private void labelTitle_Click(object sender, EventArgs e)
{
throw new System.NotImplementedException();
}
}
}