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 ;
using System.ServiceModel ;
namespace wcfControlMonitorClient
{
/// <summary>
/// Creator:Richard.liu
/// ģ�¹����´��Զ�����
/// </summary>
public partial class FrmAutoCommand : Form
{
DBOperator dbo = CStaticClass . dbo ;
public DataView dataStart = new DataView ( ) ;
public DataView dataEnd = new DataView ( ) ;
public int IOtype = 0 ;
int AutoManageIdx = 0 ;
#region ====��������
CommonClassLib . UCellPanel cellPanel = null ;
#endregion
private static FrmAutoCommand _f ormInstance ;
public static FrmAutoCommand FormInstance
{
get
{
if ( _f ormInstance = = null )
{
_f ormInstance = new FrmAutoCommand ( ) ;
}
return _f ormInstance ;
}
set { _f ormInstance = value ; }
}
public FrmAutoCommand ( )
{
dbo . Open ( ) ;
InitializeComponent ( ) ;
_f ormInstance = this ;
////��������:�Ѷ���ȡ����001��������002�������ȶ�003�����ػش�004��
////����ľ������005(һ��������ľ�������ֳɶ�����һ��������)
//this.cbKind.Items.Add("");
//this.cbKind.Items.Add("�����ȶ�");
//this.cbKind.Items.Add("���ػش�");
////this.cbKind.Items.Add("����������");
//this.cbKind.Text="�����ȶ�";
////cbtasktype
DataSet ds = dbo . ExceSQL ( "select * from T_ITEMTASKTYPE where FCODE !='-'" ) ;
if ( ds . Tables [ 0 ] . DefaultView . Count > 0 )
{
cbtasktype . ValueMember = "FCODE" ;
cbtasktype . DisplayMember = "FNAME" ;
cbtasktype . DataSource = ds . Tables [ 0 ] . DefaultView ;
}
}
private void button1_Click ( object sender , EventArgs e )
{
if ( MessageBox . Show ( "��ȷ��Ҫ�����Զ������������´�����ʱ���˹�ȷ�Ϻ���������״̬�Լ���������������������ע�������ȷ�������Ƿ�����" , "������ʾ��" , MessageBoxButtons . OKCancel , MessageBoxIcon . Question ) ! = DialogResult . OK )
{
return ;
}
//if (tbFPALLETBARCODE.Text.Trim().Length <6)
//{
// MessageBox.Show("���벻��6λ�ַ���", "��������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// return;
//}
if ( ( this . cbtasktype . Text . Trim ( ) . Length = = 0 ) | | ( this . cbstartposition . Text . Trim ( ) . Length = = 0 ) | | ( this . cbendposition . Text . Trim ( ) . Length = = 0 ) )
{
MessageBox . Show ( "�����������͡�����λ�á��յ�λ�ö����������ֿ�ֵ��" , "��������ʾ" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
return ;
}
if ( ( tbstartsite . Enabled = = true ) & & ( tbstartsite . Text . Trim ( ) . Length = = 0 ) )
{
MessageBox . Show ( "����λ�������������Ա���ָ������λ�ã�" , "��������ʾ" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
return ;
}
if ( ( tbendsite . Enabled = = true ) & & ( tbendsite . Text . Trim ( ) . Length = = 0 ) )
{
MessageBox . Show ( "�յ�λ�������������Ա���ָ������λ�ã�" , "��������ʾ" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
return ;
}
if ( ( cbKind . Text . Trim ( ) . Length > 0 ) & & ( txtparm . Text . Trim ( ) . Length = = 0 ) )
{
MessageBox . Show ( "���������������ǿ�ֵ������ָ������������" , "��������ʾ" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
return ;
}
if ( ( cbInWorkBench . Text . Trim ( ) . Length > 0 ) & & ( cbInWorkBench . Text . Trim ( ) . Length = = 0 ) )
{
MessageBox . Show ( "�Ƿ�����λ����ѡ����" , "��������ʾ" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
return ;
}
//���÷���
string errtext = string . Empty ;
string startcell = string . Empty , endcell = string . Empty ;
if ( tbstartsite . SelectedValue ! = null )
{
startcell = tbstartsite . SelectedValue . ToString ( ) ;
}
else
{
startcell = tbstartsite . Text ;
}
if ( tbendsite . SelectedValue ! = null )
{
endcell = tbendsite . SelectedValue . ToString ( ) ;
}
else
{
endcell = tbendsite . Text ;
}
if ( cbtasktype . Text = = "�ƿ�" ) //ɽ��
{
if ( cbstartposition . Text ! = cbendposition . Text )
{
MessageBox . Show ( "�´��ƿ�����ʱ��������ͬ��" , "��������ʾ" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
return ;
}
}
//if (cbtasktype.Text == "��������")//�ɵ�
//{
// if (startcell.Substring(6, 2) == endcell.Substring(6, 2))
// {
// MessageBox.Show("�´ﻻ������ʱ��ֵ��ͬ��", "��������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// return;
// }
//}
Model . AutoTask at = new Model . AutoTask ( Convert . ToInt32 ( this . cbtasktype . SelectedValue ) , tbFPALLETBARCODE . Text , cbstartposition . SelectedValue . ToString ( ) , startcell , cbendposition . SelectedValue . ToString ( ) , endcell , this . tbstartsite . Enabled , this . tbendsite . Enabled , Convert . ToInt32 ( this . cbInWorkBench . Text ) ) ;
CStaticClass . WcfControl . BeginBuildAutoTask ( at , new AsyncCallback ( BuildAutoTaskCallBack ) , at ) ;
{
//MessageBox.Show("�·��ɹ�", "������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
//return;
}
}
private void button2_Click ( object sender , EventArgs e )
{
string Sql , _ kind , _ txtparm ;
DataSet ds ;
//dbo.TransBegin();
try
{
//����IO_CONTROLDETAIL
//��������:�Ѷ���ȡ����001��������002�������ȶ�003�����ػش�004��
switch ( this . cbKind . Text . Trim ( ) )
{
case "�����ȶ�" :
_ kind = "003" ;
break ;
case "���ػش�" :
_ kind = "004" ;
break ;
//case "����������":
// _kind = "005";
// break;
default :
_ kind = "003" ;
break ;
}
_ txtparm = this . txtparm . Text . Trim ( ) ;
if ( _ kind = = "005" )
{
}
else
{
int fid = GetIOControlDetailFid ( 1 , AutoManageIdx ) ;
Sql = "insert into IO_CONTROLDETAIL(FID,FCONTROLID,F_ManageTaskKindIndex,FKIND,FINDEX,FVALUE) " +
"values(" + fid + "," + AutoManageIdx + ",1,'" + _ kind + "',0,'" + _ txtparm + "')" ;
ds = dbo . ExceSQL ( Sql ) ;
}
//dbo.TransCommit();
}
catch ( Exception ex )
{
//dbo.TransRollback();
throw ex ;
}
}
private void FrmAutoCommand_Load ( object sender , EventArgs e )
{
cbInWorkBench . SelectedIndex = 2 ;
if ( cellPanel = = null )
{
cellPanel = new CommonClassLib . UCellPanel ( this , tbstartsite , null , tbFPALLETBARCODE , string . Empty ) ;
cellPanel . TaskType = "100" ;
cellPanel . GoodsName = "" ;
cellPanel . Dock = DockStyle . Fill ;
cellPanel . AllowWareHouseChanged = false ;
plCell . Controls . Add ( cellPanel ) ;
}
cellPanel . Visible = true ;
}
private void cbtasktype_SelectedIndexChanged ( object sender , EventArgs e )
{
this . tbFPALLETBARCODE . Enabled = true ;
this . tbFPALLETBARCODE . Text = "" ;
IOtype = Convert . ToInt32 ( this . cbtasktype . SelectedValue . ToString ( ) ) ;
dataStart = dbo . ExceSQL ( "SELECT DISTINCT F_StartDevice,F_DeviceName FROM T_Base_Route,T_Base_Device where F_StartDevice = F_DeviceIndex and T_Base_Route.F_RouteKind = " + IOtype ) . Tables [ 0 ] . DefaultView ;
//cbstartposition
cbstartposition . ValueMember = "F_StartDevice" ;
cbstartposition . DisplayMember = "F_DeviceName" ;
cbstartposition . DataSource = dataStart ;
dataEnd = dbo . ExceSQL ( "SELECT DISTINCT F_EndDevice,F_DeviceName FROM T_Base_Route,T_Base_Device where F_EndDevice = F_DeviceIndex and T_Base_Route.F_RouteKind = " + IOtype ) . Tables [ 0 ] . DefaultView ;
//cbendposition
cbendposition . ValueMember = "F_EndDevice" ;
cbendposition . DisplayMember = "F_DeviceName" ;
cbendposition . DataSource = dataEnd ;
}
private void cbstartposition_SelectedIndexChanged ( object sender , EventArgs e )
{
tbstartsite . DataSource = null ;
tbstartsite . Text = "" ;
//�����������豸tbstartsite.enable=true
DataSet ds = dbo . ExceSQL ( "select FLaneWay from ST_CELL where FLaneWay=" + Convert . ToInt32 ( cbstartposition . SelectedValue ) + "" ) ;
//DataSet ds = dbo.ExceSQL("select F_DeviceIndex,F_DeviceKindIndex from T_Base_Device where F_DeviceKindIndex=10 and F_DeviceIndex=" + Convert.ToInt32(cbstartposition.SelectedValue) + "");
if ( ds . Tables [ 0 ] . DefaultView . Count > 0 ) //����
{
tbstartsite . Enabled = true ;
plCell . Enabled = true ;
if ( cellPanel = = null )
{
cellPanel = new CommonClassLib . UCellPanel ( this , tbstartsite , null , null , string . Empty ) ;
cellPanel . TaskType = "100" ;
cellPanel . GoodsName = "" ;
cellPanel . Dock = DockStyle . Fill ;
cellPanel . AllowWareHouseChanged = false ;
plCell . Controls . Add ( cellPanel ) ;
}
cellPanel . ControlCellCode = tbstartsite ;
cellPanel . Laneway = this . cbstartposition . SelectedValue . ToString ( ) ;
cellPanel . WareHouse = GetWarehouse ( Convert . ToInt32 ( this . cbstartposition . SelectedValue ) ) ;
cellPanel . Visible = plCell . Visible ;
}
else //������
{
tbstartsite . Enabled = true ;
DataView dv1 = dbo . ExceSQL ( "SELECT T_Base_Device.F_DeviceName, T_Base_Device.F_DeviceIndex FROM T_Base_Lane_Gate,T_Base_Device WHERE T_Base_Lane_Gate.F_LaneGateDeviceIndex = T_Base_Device.F_DeviceIndex and F_DeviceKindIndex=9 and F_LaneIndex=" + cbstartposition . SelectedValue + "" ) . Tables [ 0 ] . DefaultView ;
if ( dv1 . Count > 0 )
{
tbstartsite . DisplayMember = "F_DeviceName" ;
tbstartsite . ValueMember = "F_DeviceIndex" ;
tbstartsite . DataSource = dv1 ;
}
else
{
plCell . Enabled = false ;
tbstartsite . Enabled = false ;
}
}
DataView dv = dbo . ExceSQL ( "select F_DeviceIndex,F_DeviceKindIndex from T_Base_Device where F_DeviceKindIndex=11 and F_DeviceIndex=" + Convert . ToInt32 ( cbstartposition . SelectedValue ) + "" ) . Tables [ 0 ] . DefaultView ;
if ( dv . Count > 0 )
{
tbstartsite . Enabled = true ;
dv = dbo . ExceSQL ( "SELECT T_Base_Device.F_DeviceName, T_Base_Device.F_DeviceIndex FROM T_Base_AGV_Gate,T_Base_Device WHERE T_Base_AGV_Gate.F_AGVGateDeviceIndex = T_Base_Device.F_DeviceIndex and F_ChannelsIndex=" + cbstartposition . SelectedValue + "" ) . Tables [ 0 ] . DefaultView ;
tbstartsite . DisplayMember = "F_DeviceName" ;
tbstartsite . ValueMember = "F_DeviceIndex" ;
tbstartsite . DataSource = dv ;
}
DataView dv2 = dbo . ExceSQL ( $"SELECT DISTINCT F_EndDevice,F_DeviceName FROM T_Base_Route,T_Base_Device where F_EndDevice = F_DeviceIndex and T_Base_Route.F_RouteKind = {IOtype} and T_Base_Route.F_StartDevice={cbstartposition.SelectedValue}" ) . Tables [ 0 ] . DefaultView ;
//cbendposition
// DataView dv2 = dbo.ExceSQL("SELECT F_EndDevice FROM T_Base_Route WHERE F_StartDevice=" + cbstartposition.SelectedValue + "").Tables[0].DefaultView;
if ( dv2 . Count > 0 )
{
cbendposition . ValueMember = "F_EndDevice" ;
cbendposition . DisplayMember = "F_DeviceName" ;
cbendposition . DataSource = dv2 ;
//tbstartsite.Enabled = true;
//dv2 = dbo.ExceSQL("SELECT F_EndDevice FROM T_Base_Route WHERE F_ChannelsIndex=" + cbstartposition.SelectedValue + "").Tables[0].DefaultView;
//tbstartsite.DisplayMember = "F_DeviceName";
//tbstartsite.ValueMember = "F_DeviceIndex";
//tbstartsite.DataSource = dv;
}
//labelCount.Visible = false;
//textBoxCount.Visible = false;
//int type = Convert.ToInt32(this.cbtasktype.SelectedValue);
//int startdevice = Convert.ToInt32(this.cbstartposition.SelectedValue);
//int enddevice = Convert.ToInt32(this.cbendposition.SelectedValue);
//if ((startdevice >= 18001 && startdevice <= 18004) || (enddevice >= 18001 && enddevice <= 18004))
//{
// panelType.Visible = true;
//}
//else
//{
// panelType.Visible = false;
//}
//comboBoxType.SelectedIndex = -1;
//comboBoxType.Text = "";
}
private void cbendposition_SelectedIndexChanged ( object sender , EventArgs e )
{
tbendsite . DataSource = null ;
tbendsite . Text = "" ;
//�����������豸tbstartsite.enable=true
DataSet ds = dbo . ExceSQL ( "select FLaneWay from ST_CELL where FLaneWay=" + Convert . ToInt32 ( cbendposition . SelectedValue ) + "" ) ;
//DataSet ds = dbo.ExceSQL("select F_DeviceIndex,F_DeviceKindIndex from T_Base_Device where F_DeviceKindIndex=10 and F_DeviceIndex= " +Convert.ToInt32( cbendposition.SelectedValue) + "");
if ( ds . Tables [ 0 ] . DefaultView . Count > 0 )
{
tbendsite . Enabled = true ;
//�������
plCell . Enabled = true ;
if ( cellPanel = = null )
{
cellPanel = new CommonClassLib . UCellPanel ( this , tbendsite , null , null , string . Empty ) ;
cellPanel . TaskType = "100" ;
cellPanel . GoodsName = "" ;
cellPanel . Dock = DockStyle . Fill ;
cellPanel . AllowWareHouseChanged = false ;
plCell . Controls . Add ( cellPanel ) ;
}
cellPanel . ControlCellCode = tbendsite ;
cellPanel . Laneway = this . cbendposition . SelectedValue . ToString ( ) ;
cellPanel . WareHouse = GetWarehouse ( Convert . ToInt32 ( this . cbendposition . SelectedValue ) ) ;
cellPanel . Visible = plCell . Visible ;
}
else
{
tbendsite . Enabled = true ;
DataView dv1 = dbo . ExceSQL ( "SELECT T_Base_Device.F_DeviceName, T_Base_Device.F_DeviceIndex FROM T_Base_Lane_Gate,T_Base_Device WHERE T_Base_Lane_Gate.F_LaneGateDeviceIndex = T_Base_Device.F_DeviceIndex and F_DeviceKindIndex=9 and F_LaneIndex=" + cbendposition . SelectedValue + "" ) . Tables [ 0 ] . DefaultView ;
if ( dv1 . Count > 0 )
{
tbendsite . DisplayMember = "F_DeviceName" ;
tbendsite . ValueMember = "F_DeviceIndex" ;
tbendsite . DataSource = dv1 ;
}
else
{
plCell . Enabled = false ;
tbendsite . Enabled = false ;
}
}
DataView dv = dbo . ExceSQL ( "select F_DeviceIndex,F_DeviceKindIndex from T_Base_Device where F_DeviceKindIndex=11 and F_DeviceIndex=" + Convert . ToInt32 ( cbendposition . SelectedValue ) + "" ) . Tables [ 0 ] . DefaultView ;
if ( dv . Count > 0 )
{
tbendsite . Enabled = true ;
dv = dbo . ExceSQL ( "SELECT T_Base_Device.F_DeviceName, T_Base_Device.F_DeviceIndex FROM T_Base_AGV_Gate,T_Base_Device WHERE T_Base_AGV_Gate.F_AGVGateDeviceIndex = T_Base_Device.F_DeviceIndex and F_ChannelsIndex=" + cbendposition . SelectedValue + "" ) . Tables [ 0 ] . DefaultView ;
tbendsite . DisplayMember = "F_DeviceName" ;
tbendsite . ValueMember = "F_DeviceIndex" ;
tbendsite . DataSource = dv ;
}
//int startdevice = Convert.ToInt32(this.cbstartposition.SelectedValue);
//int enddevice = Convert.ToInt32(this.cbendposition.SelectedValue);
//if ((startdevice >= 18001 && startdevice <= 18004) || (enddevice >= 18001 && enddevice <= 18004))
//{
// panelType.Visible = true;
//}
//else
//{
// panelType.Visible = false;
//}
}
//private void cbstartposition_SelectedIndexChanged(object sender, EventArgs e)
//{
// tbstartsite.DataSource = null;
// tbstartsite.Text = "";
// //�����������豸tbstartsite.enable=true
// DataSet ds = dbo.ExceSQL("select F_DeviceIndex,F_DeviceKindIndex from T_Base_Device where F_DeviceKindIndex=10 and F_DeviceIndex=" +Convert.ToInt32( cbstartposition.SelectedValue )+ "");
// if (ds.Tables[0].DefaultView.Count > 0 || cbtasktype.Text == "��������")
// {
// tbstartsite.Enabled = true;
// plCell.Enabled = true;
// if (cellPanel == null)
// {
// cellPanel = new CommonClassLib.UCellPanel(this, tbstartsite, null,null, string.Empty);
// cellPanel.TaskType = "100";
// cellPanel.GoodsName = "";
// cellPanel.Dock = DockStyle.Fill;
// cellPanel.AllowWareHouseChanged = false ;
// plCell.Controls.Add(cellPanel);
// }
// cellPanel.ControlCellCode = tbstartsite;
// cellPanel.Laneway = 18001.ToString();
// cellPanel.WareHouse = GetWarehouse(Convert.ToInt32(18001));
// cellPanel.Visible = plCell.Visible;
// }
// else
// {
// plCell.Enabled = false;
// tbstartsite.Enabled = false;
// }
// DataView dv = dbo.ExceSQL("select F_DeviceIndex,F_DeviceKindIndex from T_Base_Device where F_DeviceKindIndex=11 and F_DeviceIndex=" + Convert.ToInt32(cbstartposition.SelectedValue) + "").Tables[0].DefaultView;
// if (dv.Count > 0)
// {
// tbstartsite.Enabled = true;
// dv = dbo.ExceSQL("SELECT T_Base_Device.F_DeviceName, T_Base_Device.F_DeviceIndex FROM T_Base_AGV_Gate,T_Base_Device WHERE T_Base_AGV_Gate.F_AGVGateDeviceIndex = T_Base_Device.F_DeviceIndex and F_ChannelsIndex=" + cbstartposition.SelectedValue + "").Tables[0].DefaultView;
// tbstartsite.DisplayMember = "F_DeviceName";
// tbstartsite.ValueMember = "F_DeviceIndex";
// tbstartsite.DataSource = dv;
// }
//}
//private void cbendposition_SelectedIndexChanged(object sender, EventArgs e)
//{
// tbendsite.DataSource = null;
// tbendsite.Text = "";
// //�����������豸tbstartsite.enable=true
// DataSet ds = dbo.ExceSQL("select F_DeviceIndex,F_DeviceKindIndex from T_Base_Device where F_DeviceKindIndex=10 and F_DeviceIndex= " +Convert.ToInt32( cbendposition.SelectedValue) + "");
// if (ds.Tables[0].DefaultView.Count > 0 || cbtasktype.Text == "��������")
// {
// tbendsite.Enabled = true;
// plCell.Enabled = true;
// if (cellPanel == null)
// {
// cellPanel = new CommonClassLib.UCellPanel(this, tbendsite, null, null,string.Empty);
// cellPanel.TaskType = "100";
// cellPanel.GoodsName = "";
// cellPanel.Dock = DockStyle.Fill;
// cellPanel.AllowWareHouseChanged = false;
// plCell.Controls.Add(cellPanel);
// }
// cellPanel.ControlCellCode = tbendsite;
// cellPanel.Laneway = 18001.ToString();
// cellPanel.WareHouse = GetWarehouse(Convert.ToInt32(18001));
// cellPanel.Visible = plCell.Visible;
// }
// else
// {
// plCell.Enabled = false;
// tbendsite.Enabled = false;
// }
// DataView dv = dbo.ExceSQL("select F_DeviceIndex,F_DeviceKindIndex from T_Base_Device where F_DeviceKindIndex=11 and F_DeviceIndex=" + Convert.ToInt32(cbendposition.SelectedValue) + "").Tables[0].DefaultView;
// if (dv.Count > 0)
// {
// tbendsite.Enabled = true;
// dv = dbo.ExceSQL("SELECT T_Base_Device.F_DeviceName, T_Base_Device.F_DeviceIndex FROM T_Base_AGV_Gate,T_Base_Device WHERE T_Base_AGV_Gate.F_AGVGateDeviceIndex = T_Base_Device.F_DeviceIndex and F_ChannelsIndex=" + cbendposition.SelectedValue + "").Tables[0].DefaultView;
// tbendsite.DisplayMember = "F_DeviceName";
// tbendsite.ValueMember = "F_DeviceIndex";
// tbendsite.DataSource = dv;
// }
//}
int GetIOControlDetailFid ( int ManageTaskKindIndex , int FCONTROLID )
{
DataSet ds = dbo . ExceSQL ( "SELECT MAX(FID) AS MaxFID FROM IO_CONTROLDETAIL GROUP BY F_ManageTaskKindIndex, FCONTROLID HAVING (F_ManageTaskKindIndex = " + ManageTaskKindIndex + ") AND (FCONTROLID = " + FCONTROLID + ")" ) ;
if ( ds . Tables [ 0 ] . DefaultView . Count > 0 )
{
return ( Convert . ToInt32 ( ds . Tables [ 0 ] . DefaultView [ 0 ] [ "MaxFID" ] ) + 1 ) ;
}
else
{
return 1 ;
}
}
void BuildAutoTaskCallBack ( IAsyncResult ar )
{
string errtext = string . Empty ;
if ( CStaticClass . WcfControl . EndBuildAutoTask ( out errtext , ar ) = = false )
{
MessageBox . Show ( errtext , "������ʾ" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
}
}
private void FrmAutoCommand_FormClosing ( object sender , FormClosingEventArgs e )
{
_f ormInstance = null ;
}
string GetWarehouse ( int laneway )
{
DataView dv = dbo . ExceSQL ( string . Format ( "SELECT DISTINCT FWAREHOUSE FROM ST_CELL WHERE (FLaneWay = {0})" , laneway ) ) . Tables [ 0 ] . DefaultView ;
if ( dv . Count > 0 )
{
return dv [ 0 ] [ 0 ] . ToString ( ) ;
}
else
{
return "01" ;
}
}
StringBuilder sql = new StringBuilder ( ) ;
public bool IFExitTempManageIndex ( int fid )
{
//20100108
DataView dv = new DataView ( ) ;
try
{
//20101124
sql . Remove ( 0 , sql . Length ) ;
sql . Append ( "SELECT fid FROM T_Manage_Task WHERE (F_ManageTaskKindIndex=2 and fid = " ) . Append ( fid ) . Append ( ")" ) ;
dv = dbo . ExceSQL ( sql . ToString ( ) ) . Tables [ 0 ] . DefaultView ;
if ( dv . Count > 0 )
{
return true ;
}
else
{
return false ;
}
}
catch ( Exception ex )
{ //20100108
throw ex ;
}
finally
{ //20100108
dv . Dispose ( ) ;
}
}
/// <summary>
/// ��¼�������ɵĵ�������������������ֵ
/// </summary>
/// <param name="fid">�������ɵĵ�������������</param>
public void RecordMaxTempManageTaskFID ( int fid )
{ //20100108
DataView dv = new DataView ( ) ;
try
{ //20100108
dv = dbo . ExceSQL ( "select F_ManageTaskIndex from T_Base_Manage_Task_Index_Temp_Task" ) . Tables [ 0 ] . DefaultView ;
if ( dv . Count > 0 )
{
//if (fid == 19998)
//{
// dbo.ExceSQL("UPDATE T_Base_Manage_Task_Index_Temp_Task SET F_ManageTaskIndex =10001");
// return;
//}
//if (fid > Convert.ToInt32(dv[0]["F_ManageTaskIndex"]))
//{
//20101124
sql . Remove ( 0 , sql . Length ) ;
sql . Append ( "UPDATE T_Base_Manage_Task_Index_Temp_Task SET F_ManageTaskIndex =" ) . Append ( fid ) ;
dbo . ExceSQL ( sql . ToString ( ) ) ;
return ;
//}
}
else
{
//20101124
sql . Remove ( 0 , sql . Length ) ;
sql . Append ( "INSERT INTO T_Base_Manage_Task_Index_Temp_Task (F_ManageTaskIndex)VALUES (" ) . Append ( fid ) . Append ( ")" ) ;
dbo . ExceSQL ( sql . ToString ( ) ) ;
return ;
}
}
catch ( Exception ex )
{ //20100108
// _DisassembleTaskError = "���ü�¼��������������������ʧ�ܣ�" + ex.Message;
throw ex ;
//return 0;
}
finally
{ //20100108
dv . Dispose ( ) ;
}
}
public int GetTempManageIdx ( )
{
//20100108
DataSet ds = new DataSet ( ) ;
try
{
int maxIdx = 1 0 0 0 1 ;
ds = dbo . ExceSQL ( "SELECT F_ManageTaskIndex FROM T_Base_Manage_Task_Index_Temp_Task" ) ;
if ( ds . Tables [ 0 ] . DefaultView . Count > 0 )
{
if ( ( Convert . ToInt32 ( ds . Tables [ 0 ] . DefaultView [ 0 ] [ "F_ManageTaskIndex" ] ) + 1 ) > = 1 9 9 9 8 )
{
maxIdx = 1 0 0 0 1 ;
}
else
{
maxIdx = ( Convert . ToInt32 ( ds . Tables [ 0 ] . DefaultView [ 0 ] [ "F_ManageTaskIndex" ] ) + 1 ) ;
}
}
else
{
maxIdx = 1 0 0 0 1 ;
}
//�ж���ʱ�����������Ƿ����ظ�ֵ
if ( IFExitTempManageIndex ( maxIdx ) = = true )
{
RecordMaxTempManageTaskFID ( maxIdx ) ;
maxIdx = GetTempManageIdx ( ) ;
return maxIdx ;
}
RecordMaxTempManageTaskFID ( maxIdx ) ;
return maxIdx ;
}
catch ( Exception ex )
{ //20100108
throw ex ;
//return 0;
}
finally
{ //20100108
ds . Dispose ( ) ;
}
}
private void button3_Click ( object sender , EventArgs e )
{
if ( comboBox_Z . SelectedIndex < 0 | | comboBox_Y . SelectedIndex < 0 )
{
MessageBox . Show ( "��ѡ���Ż���!" ) ;
return ;
}
int Z = comboBox_Z . SelectedIndex + 9 ;
int Y = comboBox_Y . SelectedIndex + 1 ;
DataView dv = new DataView ( ) ;
try
{
int enddevice ;
int startdevice = 1 8 0 0 5 ;
string sql = string . Format ( "select * from ST_CELL where F_Z={0} and F_Y={1} and FCELLSTATUS=1 and FRUNSTATUS=0" , Z , Y ) ;
dv = dbo . ExceSQL ( sql . ToString ( ) ) . Tables [ 0 ] . DefaultView ;
if ( dv . Count > 0 )
{
int count = dv . Count ;
for ( int i = 0 ; i < count ; i + + )
{
string CellCode = Convert . ToString ( dv [ i ] [ "FCELLCODE" ] ) ;
string barcodes = Convert . ToString ( dv [ i ] [ "FPALLETBARCODE" ] ) ; //��������
string dtimes = DateTime . Now . ToString ( "u" ) ; //20101028
dtimes = dtimes . Substring ( 0 , dtimes . Length - 1 ) ; //20101028
int Laneindex = 1 8 0 0 5 ;
enddevice = 1 2 0 3 5 ;
int AutoManageIdx = GetTempManageIdx ( ) ; //������������
string stack = "0" ; //�Ѷ���FSTACK
int controltype = 2 ; //����
string sqlstr = string . Format ( "insert into T_Manage_Task(FID,FPALLETBARCODE,FCONTROLTASKTYPE,F_ManageTaskKindIndex,FSTARTWAREHOUSE,FSTARTDEVICE,FSTARTCELL,FENDWAREHOUSE,FENDDEVICE,FENDCELL,FLANEWAY,FSTACK,FUseAwayFork,FBEGTIME,FStartCol,FStartLayer,FLOGIC_AREA) values ({0},'{1}',{2},{3},{4},{5},'{6}',{7},{8},'{9}',{10},{11},'{12}','{13}',{14},{15},{16})" , AutoManageIdx , barcodes , controltype , 2 , 1 , startdevice , CellCode , 1 , enddevice , "-" , Laneindex , stack , "-" , dtimes , 0 , 0 , enddevice ) ;
dbo . ExceSQL ( sqlstr ) ;
sqlstr = string . Format ( "update ST_CELL set FRunStatus = 1 where FLaneWay= {0} and fcellcode = '{1}'" , Laneindex , CellCode ) ;
dbo . ExceSQL ( sqlstr ) ;
// CommonClassLib.CCarryConvert.WriteDarkCasket("OPCClient", "�Զ�������������", startdevice.ToString(), AutoManageIdx.ToString());
}
string mes = string . Format ( "�ɹ�����{0}����������" , count ) ;
MessageBox . Show ( mes ) ;
}
else
{
MessageBox . Show ( "�����������Ļ�λ!" ) ;
}
}
catch ( Exception ex )
{
throw ;
}
}
}
}