|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace ClientTest
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
*类名称:MeterAddrForm
|
|
|
|
|
*创建人:韩荣伟
|
|
|
|
|
*创建时间:2010-10-30
|
|
|
|
|
*功能描述:仪表地址与置位设置窗口
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public partial class MeterAddrForm : Form
|
|
|
|
|
{
|
|
|
|
|
public CheckedListBox checkedListBox;
|
|
|
|
|
public TextBox [] arrTextBox = new TextBox[16];
|
|
|
|
|
public MeterAddrForm()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
checkedListBox = clbMeterAdd;
|
|
|
|
|
|
|
|
|
|
arrTextBox[0] = textBox1;
|
|
|
|
|
arrTextBox[1] = textBox2;
|
|
|
|
|
arrTextBox[2] = textBox3;
|
|
|
|
|
arrTextBox[3] = textBox4;
|
|
|
|
|
arrTextBox[4] = textBox5;
|
|
|
|
|
arrTextBox[5] = textBox6;
|
|
|
|
|
arrTextBox[6] = textBox7;
|
|
|
|
|
arrTextBox[7] = textBox8;
|
|
|
|
|
arrTextBox[8] = textBox9;
|
|
|
|
|
arrTextBox[9] = textBox10;
|
|
|
|
|
arrTextBox[10] = textBox11;
|
|
|
|
|
arrTextBox[11] = textBox12;
|
|
|
|
|
arrTextBox[12] = textBox13;
|
|
|
|
|
arrTextBox[13] = textBox14;
|
|
|
|
|
arrTextBox[14] = textBox15;
|
|
|
|
|
arrTextBox[15] = textBox16;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*方法名称:btnOK_Click
|
|
|
|
|
*创建人:韩荣伟
|
|
|
|
|
*创建时间:2010-10-30
|
|
|
|
|
*参数描述:object sender 事件发起者, EventArgs e 事件参数
|
|
|
|
|
*返回描述:void
|
|
|
|
|
*功能描述:执行登录
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
private void tbCheck_KeyPress(object sender, KeyPressEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if ((int)e.KeyChar <= 32) // 特殊键(含空格), 不处理
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!char.IsDigit(e.KeyChar)) // 非数字键, 放弃该输入
|
|
|
|
|
{
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
*方法名称:btnApply_Click
|
|
|
|
|
*创建人:韩荣伟
|
|
|
|
|
*创建时间:2010-10-30
|
|
|
|
|
*参数描述:object sender 事件发起者, EventArgs e 事件参数
|
|
|
|
|
*返回描述:void
|
|
|
|
|
*功能描述:执行设置
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
private void btnApply_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (CheckAddrs() == true)
|
|
|
|
|
{
|
|
|
|
|
this.DialogResult = DialogResult.OK;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*方法名称:CheckAddrs
|
|
|
|
|
*创建人:韩荣伟
|
|
|
|
|
*创建时间:2010-10-30
|
|
|
|
|
*参数描述:void
|
|
|
|
|
*返回描述:bool true 正确,false 错误
|
|
|
|
|
*功能描述:检查地址
|
|
|
|
|
*/
|
|
|
|
|
private bool CheckAddrs()
|
|
|
|
|
{
|
|
|
|
|
bool res = true;
|
|
|
|
|
int nAcceptCount = 0;
|
|
|
|
|
while (nAcceptCount < 16)
|
|
|
|
|
{
|
|
|
|
|
if (arrTextBox[nAcceptCount].Text.Trim() != "")
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < nAcceptCount; i++)
|
|
|
|
|
{
|
|
|
|
|
if (Convert.ToInt32(arrTextBox[nAcceptCount].Text) == Convert.ToInt32(arrTextBox[i].Text))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(this, "存在重复地址!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
res = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (res == false)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(this, "地址不可为空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
res = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
nAcceptCount++;
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|