You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
216 lines
11 KiB
216 lines
11 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.EnterpriseServices;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using DBFactory;
|
|
|
|
namespace wcfControlMonitorClient
|
|
{
|
|
/// <summary>
|
|
/// 20230815richard.liuWCS和电气PLC内部控制正反向控制输送机
|
|
/// </summary>
|
|
public partial class FrmRGVAreaSet : Form
|
|
{
|
|
|
|
|
|
DBOperator dbo = CStaticClass.dbo;
|
|
Model.MDevice mdev;
|
|
StringBuilder sql=new StringBuilder();
|
|
private static FrmRGVAreaSet _formInstance;
|
|
|
|
public static FrmRGVAreaSet FormInstance
|
|
{
|
|
get
|
|
{
|
|
if (_formInstance == null)
|
|
{
|
|
_formInstance = new FrmRGVAreaSet();
|
|
}
|
|
return _formInstance;
|
|
}
|
|
set { _formInstance = value; }
|
|
}
|
|
public FrmRGVAreaSet()
|
|
{
|
|
InitializeComponent();
|
|
|
|
_formInstance = this;
|
|
|
|
}
|
|
|
|
|
|
private void FrmRGVAreaSet_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
_formInstance = null;
|
|
}
|
|
|
|
|
|
private void FrmRGVAreaSet_Load(object sender, EventArgs e)
|
|
{
|
|
DataView dataView = null;
|
|
dataView = dbo.ExceSQL(string.Format("select max(f_rgvindex),min(f_rgvindex) from T_BASE_RGVINFO where f_rgvindex<>f_virtualrgv")).Tables[0].DefaultView;
|
|
if (dataView.Count > 0)
|
|
{
|
|
nud1AreaRGV.Maximum = Convert.ToInt32(dataView[0][0]);
|
|
nud1AreaRGV.Minimum = Convert.ToInt32(dataView[0][1]);
|
|
nud3AreaRGV.Maximum = Convert.ToInt32(dataView[0][0]);
|
|
nud3AreaRGV.Minimum = Convert.ToInt32(dataView[0][1]);
|
|
nud5AreaRGV.Maximum = Convert.ToInt32(dataView[0][0]);
|
|
nud5AreaRGV.Minimum = Convert.ToInt32(dataView[0][1]);
|
|
nud2AreaRGVIn.Maximum = Convert.ToInt32(dataView[0][0]);
|
|
nud2AreaRGVIn.Minimum = Convert.ToInt32(dataView[0][1]);
|
|
nud2AreaRGVOut.Maximum = Convert.ToInt32(dataView[0][0]);
|
|
nud2AreaRGVOut.Minimum = Convert.ToInt32(dataView[0][1]);
|
|
nud4AreaRGVIn.Maximum = Convert.ToInt32(dataView[0][0]);
|
|
nud4AreaRGVIn.Minimum = Convert.ToInt32(dataView[0][1]);
|
|
nud4AreaRGVOut.Maximum = Convert.ToInt32(dataView[0][0]);
|
|
nud4AreaRGVOut.Minimum = Convert.ToInt32(dataView[0][1]);
|
|
DataView dv = dbo.ExceSQL(string.Format("select distinct f_input from T_BASE_RGV_GATE where f_neargetdevice=1")).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
this.nud1AreaRGV.Value=Convert.ToInt32 (dv[0][0]);
|
|
}
|
|
dv = dbo.ExceSQL(string.Format("select distinct f_input,f_output from T_BASE_RGV_GATE where f_neargetdevice=2")).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
this.nud2AreaRGVIn.Value = Convert.ToInt32(dv[0][0]);
|
|
this.nud2AreaRGVOut.Value= Convert.ToInt32(dv[0][1]);
|
|
}
|
|
dv = dbo.ExceSQL(string.Format("select distinct f_input from T_BASE_RGV_GATE where f_neargetdevice=3")).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
this.nud3AreaRGV.Value = Convert.ToInt32(dv[0][0]);
|
|
}
|
|
dv = dbo.ExceSQL(string.Format("select distinct f_input,f_output from T_BASE_RGV_GATE where f_neargetdevice=4")).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
this.nud4AreaRGVIn.Value = Convert.ToInt32(dv[0][0]);
|
|
this.nud4AreaRGVOut.Value = Convert.ToInt32(dv[0][1]);
|
|
}
|
|
dv = dbo.ExceSQL(string.Format("select distinct f_input from T_BASE_RGV_GATE where f_neargetdevice=5")).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
this.nud5AreaRGV.Value = Convert.ToInt32(dv[0][0]);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
if(nud2AreaRGVIn.Value==nud2AreaRGVOut.Value)
|
|
{
|
|
if(nud1AreaRGV.Value!=nud3AreaRGV.Value )
|
|
{
|
|
MessageBox.Show("进区2直穿和出区2直穿相同时,区1和区3直穿必须相同!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
}
|
|
if (nud1AreaRGV.Value == nud3AreaRGV.Value)
|
|
{
|
|
if (nud2AreaRGVIn.Value != nud2AreaRGVOut.Value)
|
|
{
|
|
MessageBox.Show("区1和区3直穿相同时,进区2直穿和出区2直穿必须相同!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
}
|
|
if (nud4AreaRGVIn.Value == nud4AreaRGVOut.Value)
|
|
{
|
|
if (nud3AreaRGV.Value != nud5AreaRGV.Value)
|
|
{
|
|
MessageBox.Show("进区4直穿和出区4直穿相同时,区3和区5直穿必须相同!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
}
|
|
if (nud3AreaRGV.Value == nud5AreaRGV.Value)
|
|
{
|
|
if (nud4AreaRGVIn.Value != nud4AreaRGVOut.Value)
|
|
{
|
|
MessageBox.Show("区3和区5直穿相同时,进区4直穿和出区4直穿必须相同!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
}
|
|
if (!(nud1AreaRGV.Value == nud2AreaRGVOut.Value || nud1AreaRGV.Value == nud2AreaRGVIn.Value))
|
|
{
|
|
MessageBox.Show("进区2直穿和出区2直穿,必须有一个和区1直穿相同!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
if (!(nud3AreaRGV.Value == nud2AreaRGVOut.Value || nud3AreaRGV.Value == nud2AreaRGVIn.Value))
|
|
{
|
|
MessageBox.Show("进区2直穿和出区2直穿,必须有一个和区3直穿相同!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
if (!(nud3AreaRGV.Value == nud4AreaRGVOut.Value || nud3AreaRGV.Value == nud4AreaRGVIn.Value))
|
|
{
|
|
MessageBox.Show("进区4直穿和出区4直穿,必须有一个和区3直穿相同!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
if (!(nud5AreaRGV.Value == nud4AreaRGVOut.Value || nud5AreaRGV.Value == nud4AreaRGVIn.Value))
|
|
{
|
|
MessageBox.Show("进区4直穿和出区4直穿,必须有一个和区5直穿相同!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
|
|
DataView dvgate = dbo.ExceSQL(string.Format("select f_rgvindex from T_BASE_RGVINFO where f_rgvindex={0}",
|
|
Convert.ToInt32(nud1AreaRGV.Value))).Tables[0].DefaultView;
|
|
if (dvgate.Count<= 0)
|
|
{
|
|
MessageBox.Show("区1直穿车号不在有效范围内,请选择正确车号!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
dvgate = dbo.ExceSQL(string.Format("select f_rgvindex from T_BASE_RGVINFO where f_rgvindex={0}",
|
|
Convert.ToInt32(nud2AreaRGVIn.Value))).Tables[0].DefaultView;
|
|
if (dvgate.Count <= 0)
|
|
{
|
|
MessageBox.Show("进区2直穿车号不在有效范围内,请选择正确车号!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
dvgate = dbo.ExceSQL(string.Format("select f_rgvindex from T_BASE_RGVINFO where f_rgvindex={0}",
|
|
Convert.ToInt32(nud2AreaRGVOut.Value))).Tables[0].DefaultView;
|
|
if (dvgate.Count <= 0)
|
|
{
|
|
MessageBox.Show("出区2直穿车号不在有效范围内,请选择正确车号!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
dvgate = dbo.ExceSQL(string.Format("select f_rgvindex from T_BASE_RGVINFO where f_rgvindex={0}",
|
|
Convert.ToInt32(nud3AreaRGV.Value))).Tables[0].DefaultView;
|
|
if (dvgate.Count <= 0)
|
|
{
|
|
MessageBox.Show("区3直穿车号不在有效范围内,请选择正确车号!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
dvgate = dbo.ExceSQL(string.Format("select f_rgvindex from T_BASE_RGVINFO where f_rgvindex={0}",
|
|
Convert.ToInt32(nud5AreaRGV.Value))).Tables[0].DefaultView;
|
|
if (dvgate.Count <= 0)
|
|
{
|
|
MessageBox.Show("区5直穿车号不在有效范围内,请选择正确车号!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
dvgate = dbo.ExceSQL(string.Format("select f_rgvindex from T_BASE_RGVINFO where f_rgvindex={0}",
|
|
Convert.ToInt32(nud4AreaRGVIn.Value))).Tables[0].DefaultView;
|
|
if (dvgate.Count <= 0)
|
|
{
|
|
MessageBox.Show("进区4直穿车号不在有效范围内,请选择正确车号!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
dvgate = dbo.ExceSQL(string.Format("select f_rgvindex from T_BASE_RGVINFO where f_rgvindex={0}",
|
|
Convert.ToInt32(nud4AreaRGVOut.Value))).Tables[0].DefaultView;
|
|
if (dvgate.Count <= 0)
|
|
{
|
|
MessageBox.Show("出区4直穿车号不在有效范围内,请选择正确车号!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
dbo.ExecuteSql(string.Format("update T_BASE_RGV_GATE t set t.f_input={0},t.f_output={1} where t.f_neargetdevice=1",Convert.ToInt32(nud1AreaRGV.Value), Convert.ToInt32(nud1AreaRGV.Value)));
|
|
dbo.ExecuteSql(string.Format("update T_BASE_RGV_GATE t set t.f_input={0},t.f_output={1} where t.f_neargetdevice=2", Convert.ToInt32(nud2AreaRGVIn.Value), Convert.ToInt32(nud2AreaRGVOut.Value)));
|
|
dbo.ExecuteSql(string.Format("update T_BASE_RGV_GATE t set t.f_input={0},t.f_output={1} where t.f_neargetdevice=3", Convert.ToInt32(nud3AreaRGV.Value), Convert.ToInt32(nud3AreaRGV.Value)));
|
|
dbo.ExecuteSql(string.Format("update T_BASE_RGV_GATE t set t.f_input={0},t.f_output={1} where t.f_neargetdevice=4", Convert.ToInt32(nud4AreaRGVIn.Value), Convert.ToInt32(nud4AreaRGVOut.Value)));
|
|
dbo.ExecuteSql(string.Format("update T_BASE_RGV_GATE t set t.f_input={0},t.f_output={1} where t.f_neargetdevice=5", Convert.ToInt32(nud5AreaRGV.Value), Convert.ToInt32(nud5AreaRGV.Value)));
|
|
MessageBox.Show("直穿RGV工作区域设置成功!", "操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("系统设置", "UserID:" + CStaticClass.UserID + "的操作日志", "点击【保存】按钮", "直穿RGV工作区域设置", "");
|
|
}
|
|
}
|
|
}
|