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

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 + "�IJ�����־", "���������桿��ť", "ֱ��RGV������������", "");
}
}
}