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 System.ServiceModel ;
using Microsoft.VisualBasic ;
namespace wcfControlMonitorClient
{
/// <summary>
/// Creator:Richard.liu
/// �´��ֹ�����--��һ�豸
/// </summary>
public partial class FrmHandCommand : Form
{
Model . MDevice deviceInfo ;
private static FrmHandCommand _f ormInstance ;
public static FrmHandCommand FormInstance
{
get
{
if ( _f ormInstance = = null )
{
_f ormInstance = new FrmHandCommand ( ) ;
}
return _f ormInstance ;
}
set { _f ormInstance = value ; }
}
DBOperator dbo = CStaticClass . dbo ;
#region ====��������
CommonClassLib . UCellPanel cellPanel = null ;
#endregion
public FrmHandCommand ( )
{
InitializeComponent ( ) ;
_f ormInstance = this ;
dbo . Open ( ) ;
}
private void FrmHandCommand_Load ( object sender , EventArgs e )
{
this . cbInWorkBench . SelectedIndex = 2 ;
this . comboBox1 . SelectedIndex = 0 ;
if ( cellPanel = = null )
{
cellPanel = new CommonClassLib . UCellPanel ( this , txtCellCode , null , null , string . Empty ) ;
cellPanel . TaskType = "100" ;
cellPanel . GoodsName = "" ;
cellPanel . Dock = DockStyle . Fill ;
cellPanel . AllowWareHouseChanged = false ;
plCell . Controls . Add ( cellPanel ) ;
}
//20090910 and F_DBW1Address is not null //20190625���� and F_Commandtypekind<>'-'
DataView dv = dbo . ExceSQL ( "SELECT T_Base_Device.F_DeviceIndex, T_Base_Device.F_DeviceKindIndex," +
" T_Base_Device.F_DeviceName, T_Base_Device_Kind.F_GoodsMoveKindIndex FROM T_Base_Device,T_Base_Device_Kind " +
" where T_Base_Device.F_DeviceKindIndex = T_Base_Device_Kind.F_DeviceKindIndex and F_DBW1Address is not null and " +
" (T_Base_Device_Kind.F_GoodsMoveKindIndex = 1 OR T_Base_Device_Kind.F_GoodsMoveKindIndex = 2)" ) . Tables [ 0 ] . DefaultView ;
if ( dv . Count > 0 )
{
this . cbDeviceName . DisplayMember = "F_DeviceName" ;
this . cbDeviceName . ValueMember = "F_DeviceIndex" ;
this . cbDeviceName . DataSource = dv ;
this . cbDeviceName . Text = "" ;
this . cbDeviceName . SelectedValue = 0 ;
}
txtCellCode . Text = "" ;
}
private void cbDeviceName_SelectedIndexChanged ( object sender , EventArgs e )
{
DataView dv ;
this . cbDeviceCommand . DataSource = null ;
//���ݽ�ͨ����
string aa ;
//if ((Convert.ToInt32(cbDeviceName.SelectedValue) >= 11001) && (Convert.ToInt32(cbDeviceName.SelectedValue) <= 11020))
//{
// aa = "F_DeviceCommandIndex<>2 and F_DeviceCommandIndex<>3 and F_DeviceCommandIndex<>8";
//}
////else if (Convert.ToInt32(cbDeviceName.SelectedValue) == 11019)
////{
//// aa = "F_DeviceCommandIndex<>7 and F_DeviceCommandIndex<>8";
////}
//else
//{
// aa = "1=1";
//}
aa = "1=1" ;
DataSet ds = 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 ( cbDeviceName . SelectedValue ) + " and F_DeviceCommandIndex <> -1 and " + aa + " " ) ;
if ( ds . Tables [ 0 ] . DefaultView . Count > 0 )
{
deviceInfo = Model . CGetInfo . GetDeviceInfo ( Convert . ToInt32 ( cbDeviceName . SelectedValue ) ) ;
if ( deviceInfo . IfCorrelDoubleFork = = "1" & & deviceInfo . DeviceKind = = 1 )
{
pnDblFork . Visible = true ;
}
else
{
pnDblFork . Visible = false ;
}
if ( deviceInfo . DeviceKind = = 1 3 )
{
pnGd . Visible = true ;
}
else
{
pnGd . Visible = false ;
}
this . cbDeviceCommand . DisplayMember = "F_DeviceCommandName" ;
this . cbDeviceCommand . ValueMember = "F_DeviceCommandIndex" ;
this . cbDeviceCommand . DataSource = ds . Tables [ 0 ] . DefaultView ;
this . cbDeviceCommand . Text = "" ;
this . cbDeviceCommand . SelectedValue = 0 ;
int rgvdev = 0 ; //20130510
switch ( CStaticClass . GetDeviceKindIdx ( Convert . ToInt32 ( cbDeviceName . SelectedValue ) ) )
{
case 1 : //�Ѷ���
int devic = deviceInfo . DeviceIndex ;
if ( deviceInfo . VirtualStack > 0 )
{
devic = deviceInfo . VirtualStack ;
}
string tem = "SELECT F_DeviceIndex, F_DeviceName FROM T_Base_Lane_Gate,T_Base_LaneInfo,T_Base_Device where F_LaneIndex = F_LaneDeviceIndex and T_Base_Lane_Gate.F_LaneGateDeviceIndex=T_Base_Device.F_DeviceIndex" ;
//dv = dbo.ExceSQL("SELECT F_DeviceIndex, F_DeviceName FROM T_Base_Lane_Gate,T_Base_LaneInfo,T_Base_Device where F_LaneIndex = F_LaneDeviceIndex and T_Base_LaneInfo.F_StackIndex=" + devic + " and T_Base_Lane_Gate.F_LaneGateDeviceIndex=T_Base_Device.F_DeviceIndex").Tables[0].DefaultView;
dv = dbo . ExceSQL ( tem ) . Tables [ 0 ] . DefaultView ;
if ( dv . Count > 0 )
{
cbEndPosition . DataSource = null ;
cbEndPosition . DisplayMember = "F_DeviceName" ;
cbEndPosition . ValueMember = "F_DeviceIndex" ;
cbEndPosition . DataSource = dv ;
txtCellCode . Enabled = true ;
comboBox1 . Enabled = true ;
DataView dv1 = dbo . ExceSQL ( string . Format ( "SELECT F_ForkAmount FROM T_Base_StackInfo WHERE (F_StackIndex = {0})" , Convert . ToInt32 ( cbDeviceName . SelectedValue ) ) ) . Tables [ 0 ] . DefaultView ;
if ( dv1 . Count > 0 )
{
comboBox1 . Items . Clear ( ) ;
for ( int j = 1 ; j < = Convert . ToInt32 ( dv1 [ 0 ] [ "F_ForkAmount" ] ) ; j + + )
{
comboBox1 . Items . Add ( j ) ;
}
comboBox1 . Text = "0" ;
}
else
{
comboBox1 . Text = "0" ;
}
plCell . Enabled = true ;
cellPanel . StackDevice = devic . ToString ( ) ;
cellPanel . WareHouse = GetWarehouse ( devic ) ;
}
break ;
case 2 : //���ͻ�
dv = dbo . ExceSQL ( "SELECT F_DeviceIndex, F_DeviceName FROM T_Base_Device WHERE F_DeviceKindIndex =2 and F_DBW1Address is not null and f_s7connection='" + deviceInfo . S7Connection + "'" ) . Tables [ 0 ] . DefaultView ;
if ( dv . Count > 0 )
{
cbEndPosition . DataSource = null ;
cbEndPosition . DisplayMember = "F_DeviceName" ;
cbEndPosition . ValueMember = "F_DeviceIndex" ;
cbEndPosition . DataSource = dv ;
txtCellCode . Enabled = false ;
comboBox1 . Enabled = false ;
plCell . Enabled = false ;
}
comboBox1 . Text = "0" ;
break ;
case 1 3 : //�߶����ͻ�
comboBox1 . Text = "0" ;
dv = dbo . ExceSQL ( string . Format ( "SELECT FUCONVEYOR,F_DeviceName FROM ST_CELL,T_Base_Device WHERE FUCONVEYOR = F_DeviceIndex and (FUCODE = {0})" , Convert . ToInt32 ( this . cbDeviceName . SelectedValue ) ) ) . Tables [ 0 ] . DefaultView ;
if ( dv . Count > 0 )
{
cbBeginDev . DataSource = null ;
cbBeginDev . DisplayMember = "F_DeviceName" ;
cbBeginDev . ValueMember = "FUCONVEYOR" ;
cbBeginDev . DataSource = dv ;
DataView dv1 = dbo . ExceSQL ( string . Format ( "SELECT FUCONVEYOR,F_DeviceName FROM ST_CELL,T_Base_Device WHERE FUCONVEYOR = F_DeviceIndex and (FUCODE = {0})" , Convert . ToInt32 ( this . cbDeviceName . SelectedValue ) ) ) . Tables [ 0 ] . DefaultView ;
cbEndDev . DataSource = null ;
cbEndDev . DisplayMember = "F_DeviceName" ;
cbEndDev . ValueMember = "FUCONVEYOR" ;
cbEndDev . DataSource = dv1 ;
txtCellCode . Enabled = false ;
comboBox1 . Enabled = false ;
plCell . Enabled = false ;
}
break ;
case 4 : //RGV
comboBox1 . Text = "0" ;
//20130510
if ( Convert . ToInt32 ( cbDeviceName . SelectedValue ) = = 2 3 0 0 4 )
{
rgvdev = 2 3 0 0 2 ;
}
else if ( Convert . ToInt32 ( cbDeviceName . SelectedValue ) = = 1 3 0 0 4 )
{
rgvdev = 1 3 0 0 4 ;
}
else
{
rgvdev = Convert . ToInt32 ( cbDeviceName . SelectedValue ) ;
}
pnGd . Visible = false ;
dv = dbo . ExceSQL ( "SELECT F_RGVGateDeviceIndex,F_DeviceName FROM T_Base_Device,T_Base_RGV_Gate WHERE F_DeviceIndex=F_RGVGateDeviceIndex and F_ChannelsIndex =" + rgvdev ) . Tables [ 0 ] . DefaultView ; //20130510
if ( dv . Count > 0 )
{
cbEndPosition . DataSource = null ;
cbEndPosition . DisplayMember = "F_DeviceName" ;
cbEndPosition . ValueMember = "F_RGVGateDeviceIndex" ;
cbEndPosition . DataSource = dv ;
comboBox1 . Enabled = false ;
txtCellCode . Enabled = false ;
// plCell.Enabled = false;
plCell . Enabled = true ; //��������
}
break ;
}
this . cbEndPosition . Text = "" ;
txtCellCode . Text = "" ;
}
}
private void button1_Click ( object sender , EventArgs e )
{
if ( MessageBox . Show ( "��ȷ��Ҫ�����ֹ���������" , "������ʾ��" , MessageBoxButtons . OKCancel , MessageBoxIcon . Question ) ! = DialogResult . OK )
{
return ;
}
//�����������������ֹ����������ͣ���
//������������������������û���ֹ�������
//��T_Base_Manage_Task_Index_Hand_Task��ȥ�Ҹ�����Ȼ����һ��
try
{
//20090910
if ( cbDeviceName . SelectedValue = = null )
{
MessageBox . Show ( "��ѡ���豸��" , "������ʾ��" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
this . cbDeviceName . Focus ( ) ;
return ;
}
if ( this . cbDeviceName . Text . Trim ( ) = = "" )
{
MessageBox . Show ( "��ѡ���豸��" , "������ʾ��" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
this . cbDeviceName . Focus ( ) ;
return ;
}
if ( this . cbDeviceCommand . Text . Trim ( ) = = "" )
{
MessageBox . Show ( "��ѡ���豸���" , "������ʾ��" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
this . cbDeviceCommand . Focus ( ) ;
return ;
}
if ( ( cbDeviceCommand . Text = = "��λ" ) | | ( cbDeviceCommand . Text = = "��ԭ��" ) )
{
}
else
{
if ( this . txtCellCode . Enabled = = true )
{
DataView dv0 ;
if ( this . cbEndPosition . Text = = "������λ" )
{
int fstack = 0 ;
if ( cbDeviceName . SelectedValue . ToString ( ) = = "3500111" | | cbDeviceName . SelectedValue . ToString ( ) = = "35002111" ) //����
{
fstack = 3 5 0 0 0 ;
}
else
{
fstack = Convert . ToInt32 ( cbDeviceName . SelectedValue ) ;
}
deviceInfo = Model . CGetInfo . GetDeviceInfo ( fstack ) ; //��������
if ( deviceInfo . VirtualStack > 0 )
{
fstack = deviceInfo . VirtualStack ;
}
dv0 = dbo . ExceSQL ( string . Format ( "SELECT FCELLCODE FROM ST_CELL WHERE FStack={0} and (FCELLCODE ='{1}')" , fstack , txtCellCode . Text ) ) . Tables [ 0 ] . DefaultView ;
if ( dv0 . Count < = 0 )
{
MessageBox . Show ( "��������ѡ�����ʵĻ�λ���룡" , "������ʾ��" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
this . txtCellCode . Focus ( ) ;
return ;
}
}
else
{
int ep = - 1 ;
if ( cbEndPosition . SelectedValue = = null )
{
MessageBox . Show ( "��������ѡ�����ʵ��յ�λ�ã�" , "������ʾ��" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
this . txtCellCode . Focus ( ) ;
return ;
}
int . TryParse ( cbEndPosition . SelectedValue . ToString ( ) , out ep ) ;
if ( ep = = - 1 )
{
MessageBox . Show ( "��������ѡ�����ʵ��յ�λ�ã�" , "������ʾ��" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
this . txtCellCode . Focus ( ) ;
return ;
}
dv0 = dbo . ExceSQL ( "SELECT F_LaneGateDeviceIndex FROM T_Base_Lane_Gate where F_LaneGateDeviceIndex=" + cbEndPosition . SelectedValue + " and F_ZXY='" + txtCellCode . Text + "'" ) . Tables [ 0 ] . DefaultView ;
if ( dv0 . Count < = 0 )
{
MessageBox . Show ( "��������ѡ�����ʵĻ�λ���룡" , "������ʾ��" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
this . txtCellCode . Focus ( ) ;
return ;
}
}
}
}
int routeIDsub = GetRouteIDsub ( Convert . ToInt32 ( cbDeviceName . SelectedValue ) ) ;
deviceInfo = Model . CGetInfo . GetDeviceInfo ( Convert . ToInt32 ( cbDeviceName . SelectedValue ) ) ;
//if ((deviceInfo.IsShuttle != 1))
//{
// if ((routeIDsub == -1) && (deviceInfo.DeviceKind != 13) && (deviceInfo.DeviceKind != 31))//��������
// {
// 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.cbDeviceName.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 ( cbDeviceName . SelectedValue ) + " and F_DeviceCommandIndex=" + Convert . ToInt32 ( this . cbDeviceCommand . SelectedValue ) + " and F_DeviceCommandIndex <> -1" ) ;
if ( dss . Tables [ 0 ] . DefaultView . Count < = 0 )
{
MessageBox . Show ( "��ѡ���豸�Ͷ�Ӧ����Ч���" , "������ʾ��" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
return ;
}
//20101028
string dtime = DateTime . Now . ToString ( "u" ) ;
dtime = dtime . Substring ( 0 , dtime . Length - 1 ) ;
int beginDeviceIndex = 0 ; int Inworkbench = 2 , forkno = 0 ;
string workmode = "0" ; //�����
//2 ��ȡ,3 ����,4 ȡ��,5 �ͻ�
switch ( CStaticClass . GetDeviceKindIdx ( Convert . ToInt32 ( cbDeviceName . SelectedValue ) ) )
{
case 1 : //�Ѷ���
if ( ( cbDeviceCommand . SelectedValue . ToString ( ) = = "6" | | cbDeviceCommand . SelectedValue . ToString ( ) = = "5" ) & & ( this . cbEndPosition . Text = = "������λ" ) )
{
int fstack = 0 ;
if ( deviceInfo . VirtualStack > 0 )
{
fstack = deviceInfo . VirtualStack ;
}
else
{
fstack = Convert . ToInt32 ( cbDeviceName . SelectedValue ) ;
}
DataView dv0 = dbo . ExceSQL ( string . Format ( "SELECT FCELLCODE FROM ST_CELL WHERE fstack={0} and (FCELLCODE ='{1}')" , fstack , txtCellCode1 . Text ) ) . Tables [ 0 ] . DefaultView ;
if ( dv0 . Count < = 0 )
{
MessageBox . Show ( "��������ѡ�����ʵ��ͻ�λ���룡" , "������ʾ��" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
this . txtCellCode1 . Focus ( ) ;
return ;
}
}
if ( this . comboBox1 . Text . Trim ( ) = = "" )
{
forkno = 0 ;
}
else
{
forkno = Convert . ToInt32 ( this . comboBox1 . Text ) ;
}
break ;
case 2 : //���ͻ�
if ( cbEndPosition . Text . Trim ( ) . Length = = 0 )
{
MessageBox . Show ( "��ѡ��Ŀ��λ�ã�" , "������ʾ��" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
this . cbEndPosition . Focus ( ) ;
return ;
}
if ( cbDeviceCommand . SelectedValue . ToString ( ) ! = "6" )
{
cbEndPosition . Text = "0" ;
}
int . TryParse ( this . comboBox1 . Text , out forkno ) ;
break ;
case 4 : //RGV
if ( cbEndPosition . SelectedValue = = null )
{
MessageBox . Show ( "��ѡ��Ŀ��λ�ã�" , "������ʾ��" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
this . cbEndPosition . Focus ( ) ;
return ;
}
break ;
case 1 3 : //�߶�
if ( cbEndDev . SelectedValue = = null )
{
MessageBox . Show ( "��ѡ��Ŀ��λ�ã�" , "������ʾ��" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
this . cbEndDev . Focus ( ) ;
return ;
}
if ( cbBeginDev . SelectedValue = = null )
{
MessageBox . Show ( "��ѡ��Ŀ��λ�ã�" , "������ʾ��" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
this . cbBeginDev . Focus ( ) ;
return ;
}
beginDeviceIndex = Convert . ToInt32 ( cbBeginDev . SelectedValue ) ;
if ( int . TryParse ( cbInWorkBench . Text , out Inworkbench ) = = false )
{
MessageBox . Show ( "��ѡ���Ƿ�����λ��" , "������ʾ��" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
this . cbInWorkBench . Focus ( ) ;
return ;
}
forkno = Inworkbench ;
break ;
}
//���÷���
string errtext = string . Empty ;
string epp = string . Empty ;
if ( cbEndPosition . SelectedValue = = null )
{
epp = "0" ;
}
else
{
epp = cbEndPosition . SelectedValue . ToString ( ) ;
}
string cellcode = string . Empty ;
if ( deviceInfo . DeviceKind = = 1 3 )
{
epp = cbEndDev . SelectedValue . ToString ( ) ;
cellcode = tbFPALLETBARCODE . Text ;
}
else
{
cellcode = txtCellCode . Text ;
}
string cforks = string . Empty ;
if ( fork2 . Checked = = true )
{
cforks = ",2" ;
}
if ( fork3 . Checked = = true )
{
cforks = cforks + ",3" ;
}
if ( cforks . Length > = 2 )
{
cforks = cforks . Substring ( 1 ) ;
}
if ( cbDeviceName . Text . Contains ( "�Ѷ���" ) ) //����
{
//if (this.comboBox1.Text.Trim() == "")
//{
// MessageBox.Show("�ֹ�ָ������ѡ�����棡", "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// return;
//}
//if (this.comboBox2.Text.Trim() == "")
//{
// MessageBox.Show("��ѡ���������ͣ�", "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// this.comboBox2.Focus();
// return;
//}
//else
//{
//workmode = (Convert.ToInt32(this.comboBox2.SelectedIndex)+1).ToString();
workmode = "2" ;
//}
}
Model . HandTask ht = new Model . HandTask ( Convert . ToInt32 ( cbDeviceName . SelectedValue )
, Convert . ToInt32 ( cbDeviceCommand . SelectedValue ) , beginDeviceIndex , epp ,
cellcode , txtCellCode1 . Text , forkno , cforks , workmode ) ;
CStaticClass . WcfControl . BeginBuildHandTask ( ht , new AsyncCallback ( BuildHandTaskCallBack ) , ht ) ;
}
catch ( Exception ex )
{
throw ex ;
}
}
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 ) > = 2 9 9 9 8 )
{
return 2 0 0 0 1 ;
}
else
{
return ( Convert . ToInt32 ( dss . Tables [ 0 ] . DefaultView [ 0 ] [ "F_ManageTaskIndex" ] ) + 1 ) ;
}
}
else
{
return 2 0 0 0 1 ;
}
}
}
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 = = 2 9 9 9 8 )
{
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 ;
}
}
void BuildHandTaskCallBack ( IAsyncResult ar )
{
string errtext = string . Empty ;
if ( CStaticClass . WcfControl . EndBuildHandTask ( out errtext , ar ) = = false )
{
MessageBox . Show ( errtext , "������ʾ��" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
}
}
string GetWarehouse ( int Fstack )
{
DataView dv ;
dv = dbo . ExceSQL ( string . Format ( "SELECT DISTINCT FWAREHOUSE FROM ST_CELL WHERE (Fstack = {0})" , Fstack ) ) . Tables [ 0 ] . DefaultView ;
if ( dv . Count > 0 )
{
return dv [ 0 ] [ 0 ] . ToString ( ) ;
}
else
{
return "01" ;
}
}
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 cbDeviceCommand_SelectedIndexChanged ( object sender , EventArgs e )
{
if ( this . cbDeviceCommand . SelectedValue ! = null & & this . cbDeviceName . SelectedValue ! = null & & this . cbDeviceCommand . Text . Trim ( ) ! = "" )
{
switch ( CStaticClass . GetDeviceKindIdx ( Convert . ToInt32 ( this . cbDeviceName . SelectedValue ) ) )
{
case 1 :
if ( cbDeviceCommand . SelectedValue . ToString ( ) = = "1" )
{
txtCellCode . Text = "00-00-00" ;
txtCellCode . Enabled = true ;
txtCellCode1 . Enabled = false ;
txtCellCode1 . Text = "" ;
cbEndPosition . SelectedValue = 0 ;
}
else if ( cbDeviceCommand . SelectedValue . ToString ( ) = = "6" )
{
txtCellCode . Enabled = true ;
txtCellCode . Text = "" ;
txtCellCode1 . Enabled = true ;
txtCellCode1 . Text = "" ;
}
else if ( ( cbDeviceCommand . SelectedValue . ToString ( ) = = "2" ) | | ( cbDeviceCommand . SelectedValue . ToString ( ) = = "4" ) )
{
txtCellCode . Enabled = true ;
txtCellCode . Text = "" ;
txtCellCode1 . Enabled = false ;
txtCellCode1 . Text = "" ;
cellPanel . ControlCellCode = txtCellCode ;
}
else if ( ( cbDeviceCommand . SelectedValue . ToString ( ) = = "3" ) | | ( cbDeviceCommand . SelectedValue . ToString ( ) = = "5" ) )
{
txtCellCode . Enabled = false ;
txtCellCode . Text = "" ;
txtCellCode1 . Enabled = true ;
txtCellCode1 . Text = "" ;
cellPanel . ControlCellCode = txtCellCode1 ;
}
else if ( ( cbDeviceCommand . SelectedValue . ToString ( ) = = "7" ) ) //��������
{
txtCellCode . Enabled = true ;
txtCellCode . Text = "" ;
txtCellCode1 . Enabled = false ;
txtCellCode1 . Text = "" ;
cellPanel . ControlCellCode = txtCellCode ;
}
else
{
txtCellCode1 . Enabled = false ;
txtCellCode1 . Text = "" ;
txtCellCode . Text = "" ;
}
break ;
case 2 :
if ( cbDeviceCommand . SelectedValue . ToString ( ) ! = "6" )
{
cbEndPosition . SelectedValue = 0 ;
cbEndPosition . Text = "0" ;
}
else
{
cbEndPosition . SelectedValue = - 1 ;
cbEndPosition . Text = "" ;
}
txtCellCode . Text = "" ;
txtCellCode1 . Enabled = false ;
txtCellCode1 . Text = "" ;
break ;
case 4 : //�������� ������
//if (cbDeviceCommand.SelectedValue.ToString() == "7")//�������������
//{
// cbEndPosition.SelectedValue = -1;
// cbEndPosition.Text = "������λ";
// cbEndPosition.Enabled = false;
// txtCellCode.Enabled = true;
// txtCellCode.Text = "";
// txtCellCode1.Enabled = false;
// txtCellCode1.Text = "";
// plCell.Enabled = true;
//}
//else if (cbDeviceCommand.SelectedValue.ToString() == "8")//���������е����ͻ�
//{
// cbEndPosition.SelectedValue = -1;
// cbEndPosition.Text = "";
// cbEndPosition.Enabled = true;
// txtCellCode.Enabled = false;
// txtCellCode.Text = "";
// txtCellCode1.Enabled = false;
// txtCellCode1.Text = "";
// plCell.Enabled = false;
//}
plCell . Enabled = false ;
break ;
case 3 1 :
if ( cbDeviceCommand . SelectedValue . ToString ( ) ! = "6" )
{
cbEndPosition . SelectedValue = 0 ;
cbEndPosition . Text = "0" ;
}
else
{
cbEndPosition . SelectedValue = - 1 ;
cbEndPosition . Text = "" ;
}
txtCellCode . Text = "" ;
txtCellCode . Enabled = false ;
txtCellCode1 . Enabled = false ;
txtCellCode1 . Text = "" ;
break ;
}
}
}
private void cbEndPosition_SelectedIndexChanged ( object sender , EventArgs e )
{
int devic = 3 5 0 0 0 ;
if ( ( Convert . ToInt32 ( cbDeviceName . SelectedValue ) = = 3 5 0 0 1 1 1 1 1 ) | | ( Convert . ToInt32 ( cbDeviceName . SelectedValue ) = = 3 5 0 0 2 2 2 2 ) )
{
devic = 3 5 0 0 0 ;
}
else
{
devic = Convert . ToInt32 ( cbDeviceName . SelectedValue ) ;
}
if ( this . cbEndPosition . SelectedValue = = null ) return ;
int qq = - 1 ;
if ( int . TryParse ( this . cbEndPosition . SelectedValue . ToString ( ) , out qq ) = = true )
{
deviceInfo = Model . CGetInfo . GetDeviceInfo ( devic ) ; //��������
if ( deviceInfo . VirtualStack > 0 )
{
devic = deviceInfo . VirtualStack ;
}
DataView dv = dbo . ExceSQL ( string . Format ( "SELECT T_Base_Lane_Gate.F_ZXY FROM T_Base_LaneInfo,T_Base_Lane_Gate WHERE T_Base_LaneInfo.F_LaneDeviceIndex = T_Base_Lane_Gate.F_LaneIndex and (T_Base_LaneInfo.F_StackIndex = {0}) AND (T_Base_Lane_Gate.F_LaneGateDeviceIndex = {1})" , devic , cbEndPosition . SelectedValue ) ) . Tables [ 0 ] . DefaultView ;
if ( dv . Count > 0 )
{
if ( txtCellCode . Enabled = = true )
{
txtCellCode . Text = dv [ 0 ] [ 0 ] . ToString ( ) ;
}
else
{
txtCellCode1 . Text = dv [ 0 ] [ 0 ] . ToString ( ) ;
}
}
else
{
txtCellCode . Text = "" ;
}
}
}
private void txtCellCode_TextChanged ( object sender , EventArgs e )
{
if ( this . cbDeviceName . SelectedValue = = null ) return ;
if ( CStaticClass . GetDeviceKindIdx ( Convert . ToInt32 ( this . cbDeviceName . SelectedValue ) ) ! = 1 ) return ;
int fstack = 0 ;
if ( cbDeviceName . SelectedValue . ToString ( ) = = "35001111" | | cbDeviceName . SelectedValue . ToString ( ) = = "35002111" )
{
fstack = 3 5 0 0 0 ;
}
else
{
fstack = Convert . ToInt32 ( cbDeviceName . SelectedValue ) ;
}
DataView dv0 = dbo . ExceSQL ( "SELECT F_LaneGateDeviceIndex FROM T_Base_Lane_Gate WHERE F_ZXY='" + txtCellCode . Text + "' and F_LaneIndex=" + CStaticClass . GetLaneWay ( fstack ) + "" ) . Tables [ 0 ] . DefaultView ;
if ( dv0 . Count > 0 )
{
this . cbEndPosition . SelectedValue = dv0 [ 0 ] [ 0 ] ;
}
else
{
deviceInfo = Model . CGetInfo . GetDeviceInfo ( fstack ) ; //��������
if ( deviceInfo . VirtualStack > 0 )
{
fstack = deviceInfo . VirtualStack ;
}
dv0 = dbo . ExceSQL ( "SELECT FCELLCODE FROM ST_CELL WHERE fstack=" + fstack + " and (FCELLCODE ='" + txtCellCode . Text + "')" ) . Tables [ 0 ] . DefaultView ;
if ( dv0 . Count > 0 )
{
this . cbEndPosition . SelectedValue = 0 ;
this . cbEndPosition . Text = "������λ" ;
}
}
}
private void FrmHandCommand_FormClosing ( object sender , FormClosingEventArgs e )
{
_f ormInstance = null ;
}
private void txtCellCode1_TextChanged ( object sender , EventArgs e )
{
if ( this . cbDeviceName . SelectedValue = = null ) return ;
if ( CStaticClass . GetDeviceKindIdx ( Convert . ToInt32 ( this . cbDeviceName . SelectedValue ) ) ! = 1 ) return ;
int fstack = 0 ;
if ( cbDeviceName . SelectedValue . ToString ( ) = = "35001111" | | cbDeviceName . SelectedValue . ToString ( ) = = "350022222" )
{
fstack = 3 5 0 0 0 ;
}
else
{
fstack = Convert . ToInt32 ( cbDeviceName . SelectedValue ) ;
}
DataView dv0 = dbo . ExceSQL ( "SELECT F_LaneGateDeviceIndex FROM T_Base_Lane_Gate WHERE F_ZXY='" + txtCellCode1 . Text + "' and F_LaneIndex=" + CStaticClass . GetLaneWay ( fstack ) + "" ) . Tables [ 0 ] . DefaultView ;
if ( dv0 . Count > 0 )
{
this . cbEndPosition . SelectedValue = dv0 [ 0 ] [ 0 ] ;
}
else
{
dv0 = dbo . ExceSQL ( "SELECT FCELLCODE FROM ST_CELL WHERE fstack=" + fstack + " and (FCELLCODE ='" + txtCellCode1 . Text + "')" ) . Tables [ 0 ] . DefaultView ;
if ( dv0 . Count > 0 )
{
this . cbEndPosition . SelectedValue = 0 ;
this . cbEndPosition . Text = "������λ" ;
}
}
}
private void comboBox1_SelectedIndexChanged ( object sender , EventArgs e )
{
if ( comboBox1 . Text = = "1" )
{
fork2 . Visible = false ;
//fork3.Visible = true
}
else if ( comboBox1 . Text = = "2" )
{
fork2 . Visible = false ;
//fork3.Visible = true;
}
else if ( comboBox1 . Text = = "3" )
{
fork2 . Visible = false ;
fork3 . Visible = false ;
}
}
private void comboBox2_SelectedIndexChanged ( object sender , EventArgs e )
{
}
}
}