98 lines
2.8 KiB
C#
98 lines
2.8 KiB
C#
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)
|
||
{
|
||
}
|
||
|
||
private void labelTitle_Click(object sender, EventArgs e)
|
||
{
|
||
}
|
||
}
|
||
} |