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.
328 lines
13 KiB
328 lines
13 KiB
5 months ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.ComponentModel;
|
||
|
using System.Data;
|
||
|
using System.Drawing;
|
||
|
using System.Text;
|
||
|
using System.Windows.Forms;
|
||
|
using DBFactory;
|
||
|
|
||
|
using Microsoft.VisualBasic;
|
||
|
namespace wcfControlMonitorClient
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// Creator:Richard.liu
|
||
|
/// �´��ֹ����������豸��������
|
||
|
/// </summary>
|
||
|
public partial class FrmHandAssociateCommand : Form
|
||
|
{
|
||
|
private static FrmHandAssociateCommand _formInstance;
|
||
|
|
||
|
public static FrmHandAssociateCommand FormInstance
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
if (_formInstance == null)
|
||
|
{
|
||
|
_formInstance = new FrmHandAssociateCommand();
|
||
|
}
|
||
|
return _formInstance;
|
||
|
}
|
||
|
set { _formInstance = value; }
|
||
|
}
|
||
|
|
||
|
DBOperator dbo = CStaticClass.dbo;
|
||
|
#region ====��������
|
||
|
|
||
|
|
||
|
#endregion
|
||
|
public FrmHandAssociateCommand()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
_formInstance = this;
|
||
|
dbo.Open();
|
||
|
}
|
||
|
|
||
|
private void FrmHandCommand_Load(object sender, EventArgs e)
|
||
|
{
|
||
|
|
||
|
DataView dv3 = dbo.ExceSQL("SELECT F_RGVGateDeviceIndex ,F_Address,F_DeviceName FROM T_Base_RGV_Gate,T_Base_Device where F_RGVGateDeviceIndex=F_DeviceIndex").Tables[0].DefaultView;
|
||
|
if (dv3.Count > 0)
|
||
|
{
|
||
|
this.cbConveyorName.DisplayMember = "F_DeviceName";
|
||
|
this.cbConveyorName.ValueMember = "F_RGVGateDeviceIndex";
|
||
|
this.cbConveyorName.DataSource = dv3;
|
||
|
}
|
||
|
|
||
|
|
||
|
DataView dv5 = dbo.ExceSQL("select F_DeviceCommandName,F_DeviceCommandIndex from T_Base_Device_Command where (F_DeviceCommandKind=1 or F_DeviceCommandKind=2) and (F_DeviceKindIndex=2)").Tables[0].DefaultView;
|
||
|
if (dv5.Count > 0)
|
||
|
{
|
||
|
this.cbConveyorCommand.DisplayMember = "F_DeviceCommandName";
|
||
|
this.cbConveyorCommand.ValueMember = "F_DeviceCommandIndex";
|
||
|
this.cbConveyorCommand.DataSource = dv5;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
int GetManageHandIdx()
|
||
|
{
|
||
|
DataSet ds = dbo.ExceSQL("SELECT F_ManageTaskKindIndex, max(FID) as mFID FROM T_Manage_Task Where F_ManageTaskKindIndex=4 group by F_ManageTaskKindIndex");
|
||
|
if (ds.Tables[0].DefaultView.Count > 0)
|
||
|
{
|
||
|
return (Convert.ToInt32(ds.Tables[0].DefaultView[0]["mFID"]) + 1);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
DataSet dss = dbo.ExceSQL("SELECT F_ManageTaskIndex FROM T_Base_Manage_Task_Index_Hand_Task");
|
||
|
if (dss.Tables[0].DefaultView.Count > 0)
|
||
|
{
|
||
|
if ((Convert.ToInt32(dss.Tables[0].DefaultView[0]["F_ManageTaskIndex"]) + 1) >= 29998)
|
||
|
{
|
||
|
return 20001;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return (Convert.ToInt32(dss.Tables[0].DefaultView[0]["F_ManageTaskIndex"]) + 1);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return 20001;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
void RecordMaxHandTaskFID(int fid)
|
||
|
{
|
||
|
DataSet ds = dbo.ExceSQL("select F_ManageTaskIndex from T_Base_Manage_Task_Index_Hand_Task");
|
||
|
DataView dv = ds.Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
if (fid == 29998)
|
||
|
{
|
||
|
dbo.ExceSQL("UPDATE T_Base_Manage_Task_Index_Hand_Task SET F_ManageTaskIndex =20001" );
|
||
|
return;
|
||
|
}
|
||
|
if (fid > Convert.ToInt32(dv[0]["F_ManageTaskIndex"]))
|
||
|
{
|
||
|
dbo.ExceSQL("UPDATE T_Base_Manage_Task_Index_Hand_Task SET F_ManageTaskIndex =" + fid);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
dbo.ExceSQL("INSERT INTO T_Base_Manage_Task_Index_Hand_Task (F_ManageTaskIndex)VALUES (" + fid + ")");
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
int GetRouteIDsub(int device)
|
||
|
{
|
||
|
DataView dv = dbo.ExceSQL("SELECT F_RouteIDSub, F_DeviceIndex, F_RouteID FROM T_Base_Route_Device where F_DeviceIndex="+device+"").Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0]["F_RouteIDSub"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
private void cbConveyorName_SelectedIndexChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
if (cbConveyorName.SelectedValue == null) return;
|
||
|
DataView dv = dbo.ExceSQL("SELECT F_IFChannelLeft,F_ChannelsIndex,F_RGVGateDeviceIndex ,F_Address,F_DeviceName FROM T_Base_RGV_Gate,T_Base_Device where F_RGVGateDeviceIndex=F_DeviceIndex and F_DeviceIndex=" + cbConveyorName.SelectedValue + "").Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
DataView dv4 = dbo.ExceSQL("select F_DeviceIndex ,F_DeviceName from T_Base_Device where F_DeviceKindIndex=4 and F_DeviceIndex ="+ dv[0]["F_ChannelsIndex"]+"").Tables[0].DefaultView;
|
||
|
if (dv4.Count > 0)
|
||
|
{
|
||
|
this.cbRGVName.DisplayMember = "F_DeviceName";
|
||
|
this.cbRGVName.ValueMember = "F_DeviceIndex";
|
||
|
this.cbRGVName.DataSource = dv4;
|
||
|
}
|
||
|
string left = "";
|
||
|
if (dv[0]["F_IFChannelLeft"].ToString() == "1")
|
||
|
{
|
||
|
left = "��";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
left = "��";
|
||
|
}
|
||
|
DataView dv6 = dbo.ExceSQL("select F_DeviceCommandName,F_DeviceCommandIndex from T_Base_Device_Command where (F_DeviceCommandKind=1 or F_DeviceCommandKind=2) and (F_DeviceKindIndex=4) and (F_DeviceCommandName like '"+left +"%')").Tables[0].DefaultView;
|
||
|
if (dv6.Count > 0)
|
||
|
{
|
||
|
this.cbRGVCommand.DisplayMember = "F_DeviceCommandName";
|
||
|
this.cbRGVCommand.ValueMember = "F_DeviceCommandIndex";
|
||
|
this.cbRGVCommand.DataSource = dv6;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void cbConveyorCommand_SelectedIndexChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
if (cbConveyorName.SelectedValue == null) return;
|
||
|
DataView dv = dbo.ExceSQL("SELECT F_IFChannelLeft,F_ChannelsIndex,F_RGVGateDeviceIndex ,F_Address,F_DeviceName"+
|
||
|
" FROM T_Base_RGV_Gate,T_Base_Device where F_RGVGateDeviceIndex=F_DeviceIndex and F_DeviceIndex=" + cbConveyorName.SelectedValue + "").Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
string send = "";
|
||
|
if (cbConveyorCommand.Text.Contains("��") == true)
|
||
|
{
|
||
|
send = "��";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
send = "��";
|
||
|
}
|
||
|
string left = "";
|
||
|
if (dv[0]["F_IFChannelLeft"].ToString() == "1")
|
||
|
{
|
||
|
left = "��";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
left = "��";
|
||
|
}
|
||
|
DataView dv6 = dbo.ExceSQL("select F_DeviceCommandName,F_DeviceCommandIndex from T_Base_Device_Command where "+
|
||
|
"(F_DeviceCommandKind=1 or F_DeviceCommandKind=2) and (F_DeviceKindIndex=4) and (F_DeviceCommandName like '" + left + "%') and (F_DeviceCommandName like '%" + send + "%')").Tables[0].DefaultView;
|
||
|
if (dv6.Count > 0)
|
||
|
{
|
||
|
this.cbRGVCommand.DisplayMember = "F_DeviceCommandName";
|
||
|
this.cbRGVCommand.ValueMember = "F_DeviceCommandIndex";
|
||
|
this.cbRGVCommand.DataSource = dv6;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void button7_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
if (MessageBox.Show("��ȷ��Ҫ�´��Խ���������", "������ʾ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
//�����������������ֹ����������ͣ���
|
||
|
//������������������������û���ֹ�������
|
||
|
//��T_Base_Manage_Task_Index_Hand_Task��ȥ�Ҹ�����Ȼ����һ��
|
||
|
try
|
||
|
{
|
||
|
if (this.cbRGVName.Text.Trim() == "")
|
||
|
{
|
||
|
MessageBox.Show("��ѡ��RGV�豸��", "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
this.cbRGVName.Focus();
|
||
|
return;
|
||
|
}
|
||
|
if (this.cbConveyorName.Text.Trim() == "")
|
||
|
{
|
||
|
MessageBox.Show("��ѡ�����ͻ��豸��", "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
this.cbConveyorName.Focus();
|
||
|
return;
|
||
|
}
|
||
|
//20090918
|
||
|
if (this.cbConveyorName.SelectedValue == null)
|
||
|
{
|
||
|
MessageBox.Show("��ѡ�����ͻ��豸��", "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
this.cbConveyorName.Focus();
|
||
|
return;
|
||
|
}
|
||
|
if (this.cbRGVCommand.Text.Trim() == "")
|
||
|
{
|
||
|
MessageBox.Show("��ѡ��RGV�豸���", "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
this.cbRGVCommand.Focus();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (this.cbConveyorCommand.Text.Trim() == "")
|
||
|
{
|
||
|
MessageBox.Show("��ѡ�����ͻ��豸���", "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
this.cbConveyorCommand.Focus();
|
||
|
return;
|
||
|
}
|
||
|
int routeRGVIDsub = GetRouteIDsub(Convert.ToInt32(cbRGVName.SelectedValue));
|
||
|
if (routeRGVIDsub == -1)
|
||
|
{
|
||
|
MessageBox.Show("��ѡ�����豸������", "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
return;
|
||
|
}
|
||
|
int routeIDsub = GetRouteIDsub(Convert.ToInt32(cbConveyorName.SelectedValue));
|
||
|
if (routeIDsub == -1)
|
||
|
{
|
||
|
MessageBox.Show("��ѡ�����豸������", "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
//DataView dv = dbo.ExceSQL("SELECT F_ManageTASKKINDINDEX, F_DeviceIndex FROM T_Monitor_Task where F_ManageTASKKINDINDEX=4 and (F_DeviceIndex=" + this.cbRGVName.SelectedValue + " or F_DeviceIndex=" + this.cbConveyorName.SelectedValue + ")").Tables[0].DefaultView;
|
||
|
//if (dv.Count > 0)
|
||
|
//{
|
||
|
// MessageBox.Show("�ڵ��ȶ������Ѿ����������豸���ֹ����", "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
|
||
|
// return;
|
||
|
//}
|
||
|
DataSet dss = dbo.ExceSQL("SELECT T_Base_Device.F_DeviceKindIndex, F_DeviceCommandName,F_DeviceCommandIndex FROM " +
|
||
|
"T_Base_Device , T_Base_Device_Command WHERE T_Base_Device.F_DeviceKindIndex" +
|
||
|
"= T_Base_Device_Command.F_DeviceKindIndex and F_DeviceIndex=" +
|
||
|
Convert.ToInt32(cbRGVName.SelectedValue) + " and F_DeviceCommandIndex=" + Convert.ToInt32(this.cbRGVCommand.SelectedValue) + " and F_DeviceCommandIndex <> -1");
|
||
|
if (dss.Tables[0].DefaultView.Count <= 0)
|
||
|
{
|
||
|
MessageBox.Show("��ѡ���豸�Ͷ�Ӧ����Ч���", "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
return;
|
||
|
}
|
||
|
dss = dbo.ExceSQL("SELECT T_Base_Device.F_DeviceKindIndex, F_DeviceCommandName,F_DeviceCommandIndex FROM " +
|
||
|
"T_Base_Device , T_Base_Device_Command WHERE T_Base_Device.F_DeviceKindIndex" +
|
||
|
"= T_Base_Device_Command.F_DeviceKindIndex and F_DeviceIndex=" +
|
||
|
Convert.ToInt32(cbConveyorName.SelectedValue) + " and F_DeviceCommandIndex=" + Convert.ToInt32(this.cbConveyorCommand.SelectedValue) + " and F_DeviceCommandIndex <> -1");
|
||
|
if (dss.Tables[0].DefaultView.Count <= 0)
|
||
|
{
|
||
|
MessageBox.Show("��ѡ���豸�Ͷ�Ӧ����Ч���", "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
CStaticClass.WcfControl.BeginBuildHandAssociateTask(Convert.ToInt32(cbConveyorName.SelectedValue), Convert.ToInt32(cbConveyorCommand.SelectedValue), Convert.ToInt32(cbRGVName.SelectedValue), Convert.ToInt32(cbRGVCommand.SelectedValue), cbRGVCommand.Text, new AsyncCallback(BuildHandTaskCallBack), null);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
private void FrmHandAssociateCommand_FormClosing(object sender, FormClosingEventArgs e)
|
||
|
{
|
||
|
_formInstance = null;
|
||
|
}
|
||
|
|
||
|
|
||
|
void BuildHandTaskCallBack(IAsyncResult ar)
|
||
|
{
|
||
|
string errtext = string.Empty;
|
||
|
|
||
|
if (CStaticClass.WcfControl.EndBuildHandAssociateTask(out errtext, ar) == false)
|
||
|
{
|
||
|
MessageBox.Show(errtext, "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|