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.Net.Sockets ;
using System.Threading ;
using System.ServiceModel ;
namespace wcfControlMonitorClient
{
/// <summary>
/// Creator:Richard.liu
/// �豸ָ�����й���
/// </summary>
public partial class FrmModifyMonitor : Form
{
string _ monstatus = " F_Status>=-1 " ;
Model . MDevice _d evice = null ;
private static FrmModifyMonitor _f ormInstance ;
public static FrmModifyMonitor FormInstance
{
get
{
if ( _f ormInstance = = null )
{
_f ormInstance = new FrmModifyMonitor ( ) ;
}
return _f ormInstance ;
}
set { _f ormInstance = value ; }
}
DBOperator dbo = CStaticClass . dbo ;
DBOperator dboM = CStaticClass . dboM ;
public FrmModifyMonitor ( )
{
InitializeComponent ( ) ;
_f ormInstance = this ;
}
private void cmMonitor_Opening ( object sender , CancelEventArgs e )
{
if ( this . dgvMonitor . CurrentRow = = null )
{
TSMonitor . Visible = false ;
TSMManager . Visible = false ;
TSMonitorinfo . Visible = false ;
TSMmonitorOK . Visible = false ;
TSMRestore . Visible = false ;
TSMmonitorDel . Visible = false ;
toolStripSeparator2 . Visible = false ;
tsmAGV . Visible = false ;
tsmAGVGet . Visible = false ;
tsmAGVSend . Visible = false ;
tsmAGVBank . Visible = false ;
tsmAGVGoods . Visible = false ;
return ;
}
if ( Convert . ToInt64 ( this . dgvMonitor . CurrentRow . Cells [ "������������" ] . Value ) > 0 )
{
TSMonitor . Visible = true ;
TSMManager . Visible = true ;
TSMonitorinfo . Visible = true ;
//TSMSimulateRun.Visible = true;
TSMmonitorOK . Visible = true ;
//TSMmonitorDel.Visible = true;
TSMRestore . Visible = true ;
toolStripSeparator2 . Visible = true ;
#region ��ʾ����Ϣ
int deviceindex = Convert . ToInt32 ( dgvMonitor . CurrentRow . Cells [ "�豸����" ] . Value ) ; //�豸����
string devicename = this . dgvMonitor . CurrentRow . Cells [ "�豸����" ] . Value . ToString ( ) ; //�豸����
int DeviceKind = 0 ; //= ccf.GetDeviceKindIdx(deviceindex);//�豸����
_d evice = Model . CGetInfo . GetDeviceInfo ( deviceindex ) ;
//20100108
if ( _d evice ! = null )
{
DeviceKind = _d evice . DeviceKind ;
}
string info = string . Empty ;
TSMManager . Text = string . Format ( "������������:{0},��������:{1},����:{2}" , this . dgvMonitor . CurrentRow . Cells [ "������������" ] . Value . ToString ( ) , this . dgvMonitor . CurrentRow . Cells [ "��������" ] . Value . ToString ( ) , dgvMonitor . CurrentRow . Cells [ "����" ] . Value . ToString ( ) ) ;
TSMonitor . Text = string . Format ( "�豸ָ��������{0}" , this . dgvMonitor . CurrentRow . Cells [ "�豸ָ������" ] . Value . ToString ( ) ) ;
int order = Convert . ToInt32 ( this . dgvMonitor . CurrentRow . Cells [ "�豸��������" ] . Value ) ; //����
string ordername = this . dgvMonitor . CurrentRow . Cells [ "�豸��������" ] . Value . ToString ( ) ; //��������
int Z = Convert . ToInt32 ( this . dgvMonitor . CurrentRow . Cells [ "����Z" ] . Value ) ; //����Z
int X = Convert . ToInt32 ( this . dgvMonitor . CurrentRow . Cells [ "����X" ] . Value ) ; //����X
int Y = Convert . ToInt32 ( this . dgvMonitor . CurrentRow . Cells [ "����Y" ] . Value ) ; //����Y
int Z1 = Convert . ToInt32 ( this . dgvMonitor . CurrentRow . Cells [ "�յ�Z" ] . Value ) ; //�յ�Z
int X1 = Convert . ToInt32 ( this . dgvMonitor . CurrentRow . Cells [ "�յ�X" ] . Value ) ; //�յ�X
int Y1 = Convert . ToInt32 ( this . dgvMonitor . CurrentRow . Cells [ "�յ�Y" ] . Value ) ; //�յ�Y
int fork = 0 ;
if ( dgvMonitor . CurrentRow . Cells [ "����" ] . Value . ToString ( ) ! = "-" )
{
fork = Convert . ToInt32 ( dgvMonitor . CurrentRow . Cells [ "����" ] . Value ) ; //��������
}
string forkuse = "������" ;
//DeviceKind+ deviceindex ordername Z/X/Y
if ( fork = = 1 )
{
forkuse = "������" ;
}
else
if ( fork = = 2 )
{
forkuse = "Զ����" ;
}
switch ( DeviceKind )
{
case 1 : //�Ѷ���
switch ( order )
{
case 1 :
info = string . Format ( "{0}��ԭ��" , deviceindex ) ;
break ;
case 2 : //��ȡ��ȡ
case 4 :
info = string . Format ( "{0}����λ{1:D2}��-{2:D2}��-{3:D2}��{4},����:{5}" , deviceindex , Z , X , Y , ordername , forkuse ) ;
break ;
case 3 :
case 5 :
info = string . Format ( "{0}����λ{1:D2}��-{2:D2}��-{3:D2}��{4},����:{5}" , deviceindex , Z1 , X1 , Y1 , ordername , forkuse ) ;
break ;
case 6 :
info = string . Format ( "{0}�ӻ�λ{1:D2}��-{2:D2}��-{3:D2}��ȡ�����ͻ���{4:D2}��-{5:D2}��-{6:D2}��,����:{7}" , deviceindex , Z , X , Y , Z1 , X1 , Y1 , forkuse ) ;
break ;
}
break ;
case 2 : //���ͻ�
switch ( order )
{
case 1 :
case 2 :
case 8 :
case 9 :
info = string . Format ( "{0}{1}" , deviceindex , ordername ) ;
break ;
case 6 :
info = string . Format ( "{0}{1}���ﵽ{2}" , deviceindex , ordername , Z1 ) ;
break ;
}
break ;
case 4 : //RGV
switch ( order )
{
case 7 :
info = string . Format ( "{0}{1}�����ͻ�{2}" , deviceindex , ordername , Z ) ;
break ;
case 8 :
case 9 :
info = string . Format ( "{0}�����ͻ�{1}{2}" , deviceindex , Z , ordername ) ;
break ;
}
break ;
}
TSMonitorinfo . Text = string . Format ( "ָ������:{0}" , info ) ;
#endregion
//TSMManager.Text = "���룺" + this.dgvMonitor.CurrentRow.Cells["����"].Value.ToString() +
// "����������������" + this.dgvMonitor.CurrentRow.Cells["������������"].Value.ToString();
//TSMonitor.Text = "�豸ָ��������" + this.dgvMonitor.CurrentRow.Cells["�豸ָ������"].Value.ToString();
////string CorrelRGV = "12008,12016,12024,32008,32016,32024,42008,42016,42024";//-1,-3
//string Upok = "32027,32040";//+2,+6
//int device=Convert.ToInt32(this.dgvMonitor.CurrentRow.Cells["�豸����"].Value);
//TSMmonitorOK.DropDownItems.Clear();
//if (CorrelRGV.IndexOf(device.ToString()) >= 0)
//{
// ToolStripMenuItem tsmi = new ToolStripMenuItem(Convert.ToInt32(device - 1).ToString());
// tsmi.Click += new EventHandler(TSMmonitorOK_Click);
// TSMmonitorOK.DropDownItems.Add(tsmi);
// ToolStripMenuItem tsmi1 = new ToolStripMenuItem(Convert.ToInt32(device - 3).ToString());
// TSMmonitorOK.DropDownItems.Add(tsmi1);
// tsmi1.Click += new EventHandler(TSMmonitorOK_Click);
//}
//else if (Upok.IndexOf(device.ToString()) >= 0)
//{
// ToolStripMenuItem tsmi = new ToolStripMenuItem(Convert.ToInt32(device +2).ToString());
// tsmi.Click += new EventHandler(TSMmonitorOK_Click);
// TSMmonitorOK.DropDownItems.Add(tsmi);
// ToolStripMenuItem tsmi1 = new ToolStripMenuItem(Convert.ToInt32(device + 6).ToString());
// tsmi1.Click += new EventHandler(TSMmonitorOK_Click);
// TSMmonitorOK.DropDownItems.Add(tsmi1);
//}
//if (this.dgvMonitor.CurrentRow.Cells[3].Value.ToString() == "1001")
//{
// TSMSimulateRun.Visible = false;
// TSMmonitorOK.Visible = false;
// TSMRestore.Visible = true;
// toolStripSeparator2.Visible = false;
// tsmAGV.Visible = true;
// tsmAGVGet.Visible = true;
// tsmAGVSend.Visible = true;
// if (this.dgvMonitor.CurrentRow.Cells[5].Value.ToString() == "2")//1219�����̻���
// {
// tsmAGVGoods.Visible = false;
// tsmAGVBank.Visible = true;
// tsmAGVSend.Visible = false;
// return;
// }
// else
// {
// tsmAGVSend.Visible = true;
// tsmAGVBank.Visible = false;
// }
// if (this.dgvMonitor.CurrentRow.Cells[5].Value.ToString() == "3")//1220�����̻���
// {
// tsmAGVBank.Visible = false;
// tsmAGVGoods.Visible = true;
// tsmAGVSend.Visible = false;
// return;
// }
// else
// {
// tsmAGVSend.Visible = true;
// tsmAGVGoods.Visible = false;
// }
//}
//else
//{
tsmAGV . Visible = false ;
tsmAGVGet . Visible = false ;
tsmAGVSend . Visible = false ;
tsmAGVBank . Visible = false ;
tsmAGVGoods . Visible = false ;
//}
}
}
private void TSMmonitorOK_Click ( object sender , EventArgs e )
{
ToolStripMenuItem tsm = sender as ToolStripMenuItem ;
if ( tsm . DropDownItems . Count > 0 ) return ;
int deviceindex = 0 ;
int . TryParse ( tsm . Text , out deviceindex ) ;
char [ ] cc = new char [ 1 ] { ' � � ' } ;
string [ ] split = TSMonitor . Text . Split ( cc ) ;
if ( split [ 1 ] = = "" ) return ;
try
{
DataView dv = dbo . ExceSQL ( "SELECT * FROM T_Monitor_Task Where F_MonitorIndex=" +
Convert . ToInt32 ( split [ 1 ] ) ) . Tables [ 0 ] . DefaultView ;
if ( dv . Count > 0 )
{
//20100108�м�ָ���������ʱ������ʾ�;���
DataView dv0 = dbo . ExceSQL ( "SELECT MIN(F_MonitorIndex) AS mmi FROM dbo.T_Monitor_Task WHERE (F_ManageTaskIndex = " + dv [ 0 ] [ "F_ManageTaskIndex" ] + ") AND (F_ManageTASKKINDINDEX = " + dv [ 0 ] [ "F_ManageTASKKINDINDEX" ] + ")" ) . Tables [ 0 ] . DefaultView ;
if ( dv0 . Count > 0 )
{
if ( ( dv0 [ 0 ] [ "mmi" ] ! = DBNull . Value ) & & ( dv0 [ 0 ] [ "mmi" ] . ToString ( ) ! = split [ 1 ] ) )
{
if ( MessageBox . Show ( "���룺" + dv [ 0 ] [ "F_TxtParam" ] . ToString ( ) + "���豸����:��" + this . dgvMonitor . CurrentRow . Cells [ "�豸����" ] . Value . ToString ( ) + ";�豸����:" + this . dgvMonitor . CurrentRow . Cells [ "�豸��������" ] . Value . ToString ( ) + "��֮ǰ����ûִ�����ɵĵ�����������ǰ���������ɡ������ɵ����������ң���ȷ��Ҫ������������" , "������ʾ��" , MessageBoxButtons . OKCancel , MessageBoxIcon . Warning ) ! = DialogResult . OK )
{
return ;
}
}
}
dv0 = null ;
//20100108������ϻ��������������
if ( MessageBox . Show ( "��ȷ�����룺" + dv [ 0 ] [ "F_TxtParam" ] . ToString ( ) + "���豸����:��" + this . dgvMonitor . CurrentRow . Cells [ "�豸����" ] . Value . ToString ( ) + ";�豸����:" + this . dgvMonitor . CurrentRow . Cells [ "�豸��������" ] . Value . ToString ( ) + "���Ѿ���������������" , "������ʾ��" , MessageBoxButtons . OKCancel , MessageBoxIcon . Question ) ! = DialogResult . OK )
{
return ;
}
string sss = "�豸����:" + dv [ 0 ] [ "F_DeviceIndex" ] . ToString ( ) + ";�豸ָ������:" + dv [ 0 ] [ "F_MonitorIndex" ] . ToString ( ) ;
//20100108������ϻ��������������
CommonClassLib . CCarryConvert . WriteDarkCasket ( "�豸ָ������" , "�ֹ���������" , "���룺" + dv [ 0 ] [ "F_TxtParam" ] . ToString ( ) , sss ) ;
string errtext = string . Empty ;
if ( deviceindex = = 0 )
{
deviceindex = Convert . ToInt32 ( dv [ 0 ] [ "F_DeviceIndex" ] ) ;
}
if ( dv [ 0 ] [ "F_NumParam4" ] . ToString ( ) ! = "0" & & CStaticClass . GetDeviceKindIdx ( deviceindex ) = = 2 & & deviceindex ! = 1 9 0 0 5 )
{ //20120906���ͻ����ͳ�ָ����յ����ͻ���Ϊ���������豸
deviceindex = Convert . ToInt32 ( dv [ 0 ] [ "F_NumParam4" ] ) ;
}
CStaticClass . WcfControl . BeginModifyMonitorTask ( deviceindex , Convert . ToInt32 ( dv [ 0 ] [ "F_MonitorIndex" ] ) , Model . CGeneralFunction . TASKFINISH , new AsyncCallback ( ModifyMonitorTaskCallBack ) , null ) ;
//{
// MessageBox.Show(errtext, "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Error);
//}
TSMMonitorRefresh_Click ( ) ;
}
}
catch ( Exception ex )
{
MessageBox . Show ( ex . Message , "������ʾ��" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
}
}
private void TSMRestore_Click ( object sender , EventArgs e )
{
char [ ] cc = new char [ 1 ] { ' � � ' } ;
string [ ] split = TSMonitor . Text . Split ( cc ) ;
if ( split [ 1 ] = = "" ) return ;
try
{
string errtext = string . Empty ;
int devKind ;
int mindex = Convert . ToInt32 ( split [ 1 ] ) ;
long fid = 0 ;
int mankind = 0 ;
//20100108��Ϊselect *
DataView dv = dbo . ExceSQL ( "select * from T_Monitor_Task where F_MonitorIndex=" + mindex ) . Tables [ 0 ] . DefaultView ;
if ( dv . Count > 0 )
{
fid = Convert . ToInt64 ( dv [ 0 ] [ "F_ManageTaskIndex" ] ) ;
mankind = Convert . ToInt32 ( dv [ 0 ] [ "F_ManageTASKKINDINDEX" ] ) ;
//20100108�м�ָ���λʱ������ʾ�;���
DataView dv0 = dbo . ExceSQL ( "SELECT MIN(F_MonitorIndex) AS mmi FROM dbo.T_Monitor_Task WHERE (F_ManageTaskIndex = " + fid + ") AND (F_ManageTASKKINDINDEX = " + mankind + ")" ) . Tables [ 0 ] . DefaultView ;
if ( dv0 . Count > 0 )
{
if ( ( dv0 [ 0 ] [ "mmi" ] ! = DBNull . Value ) & & ( dv0 [ 0 ] [ "mmi" ] . ToString ( ) ! = mindex . ToString ( ) ) )
{
if ( MessageBox . Show ( "���룺" + dv [ 0 ] [ "F_TxtParam" ] . ToString ( ) + "���豸����:��" + this . dgvMonitor . CurrentRow . Cells [ "�豸����" ] . Value . ToString ( ) + ";�豸����:" + this . dgvMonitor . CurrentRow . Cells [ "�豸��������" ] . Value . ToString ( ) + "��֮ǰ����ûִ�����ɵĵ�����������ǰ����λ�������ɵ����������ң���ȷ��Ҫ������������" , "������ʾ��" , MessageBoxButtons . OKCancel , MessageBoxIcon . Warning ) ! = DialogResult . OK )
{
return ;
}
}
}
dv0 = null ;
//20100108������ϻ��������������
if ( MessageBox . Show ( "��ȷ�����룺" + dv [ 0 ] [ "F_TxtParam" ] . ToString ( ) + "���豸����:��" + this . dgvMonitor . CurrentRow . Cells [ "�豸����" ] . Value . ToString ( ) + ";�豸����:" + this . dgvMonitor . CurrentRow . Cells [ "�豸��������" ] . Value . ToString ( ) + "����Ҫ�����·��ͺ��豸��������" , "������ʾ��" , MessageBoxButtons . OKCancel , MessageBoxIcon . Question ) ! = DialogResult . OK )
{
return ;
}
//20091107
devKind = CStaticClass . GetDeviceKindIdx ( Convert . ToInt32 ( dv [ 0 ] [ "F_DeviceIndex" ] ) ) ;
if ( ( devKind = = 6 ) & & ( dv [ 0 ] [ "F_AgvNo" ] ! = DBNull . Value ) )
{
if ( MessageBox . Show ( "��Ҫ��λ��AGV�����Ѿ�����AGV���ţ�" + dv [ 0 ] [ "F_AgvNo" ] . ToString ( ) + "��ȷ��Ҫ���������´�AGV��������" , "������ʾ��" , MessageBoxButtons . OKCancel , MessageBoxIcon . Question ) ! = DialogResult . OK )
{
return ;
}
}
string sss = "�豸����:" + dv [ 0 ] [ "F_DeviceIndex" ] . ToString ( ) + ";�豸ָ������:" + dv [ 0 ] [ "F_MonitorIndex" ] . ToString ( ) ;
//20100108������ϻ��������������
CommonClassLib . CCarryConvert . WriteDarkCasket ( "�豸ָ������" , "�ֹ���λ" , "����:" + dv [ 0 ] [ "F_TxtParam" ] . ToString ( ) , sss ) ;
CStaticClass . WcfControl . BeginModifyMonitorTask ( Convert . ToInt32 ( dv [ 0 ] [ "F_DeviceIndex" ] ) , Convert . ToInt32 ( dv [ 0 ] [ "F_MonitorIndex" ] ) , Model . CGeneralFunction . TASKRESTORE ,
new AsyncCallback ( ModifyMonitorTaskCallBack ) , null ) ;
//{
// MessageBox.Show(errtext, "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Error);
//}
TSMMonitorRefresh_Click ( ) ;
}
}
catch ( Exception ex )
{
MessageBox . Show ( ex . Message , "������ʾ��" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
}
}
private void rbmonAll_CheckedChanged ( object sender , EventArgs e )
{
RadioButton rb = ( RadioButton ) sender ;
if ( rb . Checked = = true )
{
_ monstatus = " F_Status>=-1 " ;
}
TSMMonitorRefresh_Click ( ) ;
}
private void TSMMonitorRefresh_Click ( )
{
this . dgvMonitor . DataSource = dbo . ExceSQL ( "select * from V_Monitor_Task where " + _ monstatus + " order by �豸ָ������ asc " ) . Tables [ 0 ] . DefaultView ;
}
private void rbmonRun_CheckedChanged ( object sender , EventArgs e )
{
//if (rbmonRun.Checked == true)
//{
// _monstatus = " (F_Status>=1) ";
//}
//TSMMonitorRefresh_Click();
}
private void rbmonWait_CheckedChanged ( object sender , EventArgs e )
{
RadioButton rb = ( RadioButton ) sender ;
if ( rb . Checked = = true )
{
_ monstatus = " F_Status=0 " ;
}
TSMMonitorRefresh_Click ( ) ;
}
public void button1_Click ( object sender , EventArgs e )
{ //20140218
try
{
if ( this . textBox1 . Text . Trim ( ) . Length = = 0 ) return ;
string _ manstatus = " F_Status>=-1 " ;
if ( this . comboBox1 . Text = = "����" )
{
_ monstatus = " ����='" + this . textBox1 . Text . Trim ( ) + "' " ;
_ manstatus = " ���� like '%" + this . textBox1 . Text . Trim ( ) + "%' " ;
}
if ( this . comboBox1 . Text = = "�豸ָ������" )
{
_ monstatus = " �豸ָ������='" + this . textBox1 . Text . Trim ( ) + "' " ;
_ manstatus = " ������������='" + CStaticClass . GetManageTaskIndexfromMonitor ( Convert . ToInt32 ( this . textBox1 . Text . Trim ( ) ) ) + "' " ;
}
if ( this . comboBox1 . Text = = "������������" )
{
_ monstatus = " ������������='" + this . textBox1 . Text . Trim ( ) + "' " ;
_ manstatus = " ������������='" + this . textBox1 . Text . Trim ( ) + "' " ;
}
if ( this . comboBox1 . Text = = "�豸����" ) //20130817richard
{
_ monstatus = " F_Status<>0 and �豸����='" + this . textBox1 . Text . Trim ( ) + "' " ;
int manFID = Convert . ToInt32 ( dbo . GetSingle ( "SELECT F_ManageTaskIndex,F_DeviceIndex,F_Status FROM T_Monitor_Task where F_Status<>0 and F_DeviceIndex='" + this . textBox1 . Text . Trim ( ) + "' " ) ) ;
_ manstatus = " ������������='" + manFID + "' " ;
}
TSMMonitorRefresh_Click ( ) ;
this . dgvManager . DataSource = dbo . ExceSQL ( "select * from V_Manage_Task where " + _ manstatus ) . Tables [ 0 ] . DefaultView ; // �Ϻ��ɵ�
}
catch ( Exception ex )
{
MessageBox . Show ( ex . Message , "������ʾ��" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
}
}
private void button2_Click ( object sender , EventArgs e )
{
_ monstatus = " F_Status>=-1 " ;
TSMMonitorRefresh_Click ( ) ;
}
private void dgvMonitor_DataSourceChanged ( object sender , EventArgs e )
{
dgvMonitor . Columns [ "F_Status" ] . Visible = false ;
}
private void FrmModifyMonitor_Load ( object sender , EventArgs e )
{
rbmonRun_Click ( sender , e ) ;
}
private void tsmAGVGet_Click ( object sender , EventArgs e )
{
string sql = "" ;
//��T_Monitor_Task���л���F_NumParam2�ֶ�ֵ ��������Ϣ���ص�С��������
DataTable tableMonitorTask = dbo . ExceSQL ( "SELECT F_ManageTASKKINDINDEX,F_ManageTaskIndex,F_NumParam2,F_AgvTask,F_AgvNo FROM T_MONITOR_TASK WHERE F_DeviceIndex=1001 and F_MonitorIndex=" + this . dgvMonitor . CurrentRow . Cells [ 2 ] . Value + "" ) . Tables [ 0 ] ;
if ( tableMonitorTask . Rows . Count > 0 )
{
if ( MessageBox . Show ( "��ȷ���ֹ�����AGV������������" , "������ʾ��" , MessageBoxButtons . OKCancel , MessageBoxIcon . Question ) ! = DialogResult . OK )
{
return ;
}
sql = "UPDATE T_Monitor_Task SET F_Status = 2 WHERE (F_MonitorIndex =" + this . dgvMonitor . CurrentRow . Cells [ 2 ] . Value + ")" ;
dbo . ExceSQL ( sql ) ;
//��T_Base_AGV_Gate���л���F_AGVGateDeviceIndex�ֶ�ֵ ������T_Base_AGV_Gate.F_Address = T_Monitor_Task.F_NumParam2
DataTable tableAGVGate = dbo . ExceSQL ( "SELECT F_AGVGateDeviceIndex FROM T_BASE_AGV_GATE WHERE F_ADDRESS = " + Convert . ToInt32 ( tableMonitorTask . Rows [ 0 ] [ "F_NumParam2" ] ) + "" ) . Tables [ 0 ] ;
if ( tableAGVGate . Rows . Count > 0 )
{
if ( MessageBox . Show ( "��ȷ��Ҫ���豸:" + tableAGVGate . Rows [ 0 ] [ "F_AGVGateDeviceIndex" ] + "�óɡ������̡�״̬����" , "������ʾ��" , MessageBoxButtons . OKCancel , MessageBoxIcon . Question ) ! = DialogResult . OK )
{
return ;
}
//����T_Base_Device���е�F_HaveGoods�ֶ�ֵΪ0��������T_Base_Device.F_DeviceIndex = T_Base_AGV_Gate.F_AGVGateDeviceIndex
dbo . ExecuteSql ( "UPDATE T_BASE_DEVICE SET F_PALLETBARCODE='-',F_HAVEGOODS = 0 WHERE F_DEVICEINDEX = " + Convert . ToInt32 ( tableAGVGate . Rows [ 0 ] [ "F_AGVGateDeviceIndex" ] ) + "" ) ;
string errtext = string . Empty ;
if ( tableMonitorTask . DefaultView [ 0 ] [ "F_ManageTASKKINDINDEX" ] . ToString ( ) = = "1" )
{
//20090817����������������Ϣ
dboM . ExecuteSql ( "UPDATE T_ITEMDEVICE SET devicestatus ='0' WHERE devicecode = '" + tableAGVGate . Rows [ 0 ] [ "F_AGVGateDeviceIndex" ] + "'" ) ;
}
}
string sss = "AGV����:" + tableMonitorTask . Rows [ 0 ] [ "F_AgvNo" ] . ToString ( ) + ";�豸ָ������:" + this . dgvMonitor . CurrentRow . Cells [ 2 ] . Value . ToString ( ) ;
CommonClassLib . CCarryConvert . WriteDarkCasket ( "�豸ָ������" , "�ֹ�����AGV��������" , tableMonitorTask . Rows [ 0 ] [ "F_AgvNo" ] . ToString ( ) + "�ų�" , sss ) ;
}
else
{
MessageBox . Show ( "ֻ��AGV�����ſ����ֹ�����AGV�������ɣ�" , "��������ʾ" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
return ;
}
}
private void tsmAGVSend_Click ( object sender , EventArgs e )
{
//��T_Monitor_Task���л���F_NumParam5�ֶ�ֵ ��������Ϣ���ص�С��������
DataTable tableMonitorTask = dbo . ExceSQL ( "SELECT F_TxtParam,F_NumParam5,F_AgvTask,F_AgvNo FROM T_MONITOR_TASK WHERE F_DeviceIndex=1001 and F_MonitorIndex=" + this . dgvMonitor . CurrentRow . Cells [ 2 ] . Value + "" ) . Tables [ 0 ] ;
if ( tableMonitorTask . Rows . Count > 0 )
{
if ( MessageBox . Show ( "��ȷ���ֹ�����AGVж����������" , "������ʾ��" , MessageBoxButtons . OKCancel , MessageBoxIcon . Question ) ! = DialogResult . OK )
{
return ;
}
//��T_Base_AGV_Gate���л���F_AGVGateDeviceIndex�ֶ�ֵ ������T_Base_AGV_Gate.F_Address = T_Monitor_Task.F_NumParam2
DataTable tableAGVGate = dbo . ExceSQL ( "SELECT F_AGVGateDeviceIndex FROM T_BASE_AGV_GATE WHERE F_ADDRESS = " + Convert . ToInt32 ( tableMonitorTask . Rows [ 0 ] [ "F_NumParam5" ] ) + "" ) . Tables [ 0 ] ;
if ( tableAGVGate . Rows . Count > 0 )
{
if ( MessageBox . Show ( "��ȷ��Ҫ���豸:" + tableAGVGate . Rows [ 0 ] [ "F_AGVGateDeviceIndex" ] + "�óɡ������̡�״̬����" , "������ʾ��" , MessageBoxButtons . OKCancel , MessageBoxIcon . Question ) ! = DialogResult . OK )
{
return ;
}
//����T_Base_Device���е�F_HaveGoods�ֶ�ֵΪ0��������T_Base_Device.F_DeviceIndex = T_Base_AGV_Gate.F_AGVGateDeviceIndex
dbo . ExecuteSql ( "UPDATE T_BASE_DEVICE SET F_PALLETBARCODE='" + tableMonitorTask . Rows [ 0 ] [ "F_TxtParam" ] + "',F_HAVEGOODS = 1 WHERE F_DEVICEINDEX = " + Convert . ToInt32 ( tableAGVGate . Rows [ 0 ] [ "F_AGVGateDeviceIndex" ] ) + "" ) ;
}
string sss = "AGV����:" + tableMonitorTask . Rows [ 0 ] [ "F_AgvNo" ] . ToString ( ) + ";�豸ָ������:" + this . dgvMonitor . CurrentRow . Cells [ 2 ] . Value . ToString ( ) ;
CommonClassLib . CCarryConvert . WriteDarkCasket ( "�豸ָ������" , "�ֹ�����AGVж������" , tableMonitorTask . Rows [ 0 ] [ "F_AgvNo" ] . ToString ( ) + "�ų�" , sss ) ;
CStaticClass . WcfControl . BeginModifyMonitorTask ( 1 0 0 1 , Convert . ToInt32 ( this . dgvMonitor . CurrentRow . Cells [ 2 ] . Value ) , Model . CGeneralFunction . TASKFINISH , new AsyncCallback ( ModifyMonitorTaskCallBack ) , null ) ;
}
else
{
MessageBox . Show ( "ֻ��AGV�����ſ����ֹ�����AGV�Ż����ɣ�" , "��������ʾ" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
return ;
}
}
private void tsmAGVBank_Click ( object sender , EventArgs e )
{
string errtext = string . Empty ;
CStaticClass . WcfControl . BeginModifyMonitorTask ( 1 0 0 1 , Convert . ToInt32 ( this . dgvMonitor . CurrentRow . Cells [ 2 ] . Value ) , Model . CGeneralFunction . TASKFINISH , new AsyncCallback ( ModifyMonitorTaskCallBack ) , null ) ;
}
private void tsmAGVGoods_Click ( object sender , EventArgs e )
{
string errtext = string . Empty ;
CStaticClass . WcfControl . BeginModifyMonitorTask ( 1 0 0 1 , Convert . ToInt32 ( this . dgvMonitor . CurrentRow . Cells [ 2 ] . Value ) , Model . CGeneralFunction . TASKFINISH , new AsyncCallback ( ModifyMonitorTaskCallBack ) , null ) ;
}
private void dgvMonitor_DataBindingComplete ( object sender , DataGridViewBindingCompleteEventArgs e )
{
foreach ( DataGridViewRow DGVRow in this . dgvMonitor . Rows )
{
if ( DGVRow ! = null )
{
if ( Convert . ToInt32 ( DGVRow . Cells [ "f_status" ] . Value ) > = 3 0 )
{
DGVRow . DefaultCellStyle . BackColor = Color . Red ;
}
}
}
}
private void TSMmonitorDel_Click ( object sender , EventArgs e )
{
char [ ] cc = new char [ 1 ] { ' � � ' } ;
string [ ] split = TSMonitor . Text . Split ( cc ) ;
if ( split [ 1 ] = = "" ) return ;
try
{
DataView dv = dbo . ExceSQL ( "SELECT * FROM T_Monitor_Task Where F_MonitorIndex=" +
Convert . ToInt32 ( split [ 1 ] ) ) . Tables [ 0 ] . DefaultView ;
if ( dv . Count > 0 )
{
//20100108�м�ָ���������ʱ������ʾ�;���
DataView dv0 = dbo . ExceSQL ( "SELECT MIN(F_MonitorIndex) AS mmi FROM dbo.T_Monitor_Task WHERE (F_ManageTaskIndex = " + dv [ 0 ] [ "F_ManageTaskIndex" ] + ") AND (F_ManageTASKKINDINDEX = " + dv [ 0 ] [ "F_ManageTASKKINDINDEX" ] + ")" ) . Tables [ 0 ] . DefaultView ;
if ( dv0 . Count > 0 )
{
if ( ( dv0 [ 0 ] [ "mmi" ] ! = DBNull . Value ) & & ( dv0 [ 0 ] [ "mmi" ] . ToString ( ) ! = split [ 1 ] ) )
{
if ( MessageBox . Show ( "���룺" + dv [ 0 ] [ "F_TxtParam" ] . ToString ( ) + "���豸����:��" + this . dgvMonitor . CurrentRow . Cells [ "�豸����" ] . Value . ToString ( ) + ";�豸����:" + this . dgvMonitor . CurrentRow . Cells [ "�豸��������" ] . Value . ToString ( ) + "��֮ǰ����ûִ�����ɵĵ�����������ǰ��ɾ���豸ָ������ɵ����������ң���ȷ��Ҫ������������" , "������ʾ��" , MessageBoxButtons . OKCancel , MessageBoxIcon . Warning ) ! = DialogResult . OK )
{
return ;
}
}
}
dv0 = null ;
//20100108������ϻ��������������
if ( MessageBox . Show ( "��ȷ�����룺" + dv [ 0 ] [ "F_TxtParam" ] . ToString ( ) + "���豸����:��" + this . dgvMonitor . CurrentRow . Cells [ "�豸����" ] . Value . ToString ( ) + ";�豸����:" + this . dgvMonitor . CurrentRow . Cells [ "�豸��������" ] . Value . ToString ( ) + "���Ѿ�����Ҫ�豸ִ��������" , "������ʾ��" , MessageBoxButtons . OKCancel , MessageBoxIcon . Question ) ! = DialogResult . OK )
{
return ;
}
string sss = "�豸����:" + dv [ 0 ] [ "F_DeviceIndex" ] . ToString ( ) + ";�豸ָ������:" + dv [ 0 ] [ "F_MonitorIndex" ] . ToString ( ) ;
//20100108������ϻ��������������
CommonClassLib . CCarryConvert . WriteDarkCasket ( "�豸ָ������" , "�ֹ�ɾ���豸ָ��" , "���룺" + dv [ 0 ] [ "F_TxtParam" ] . ToString ( ) , sss ) ;
CStaticClass . WcfControl . BeginModifyMonitorTask ( Convert . ToInt32 ( dv [ 0 ] [ "F_DeviceIndex" ] ) , Convert . ToInt32 ( dv [ 0 ] [ "F_MonitorIndex" ] ) , Model . CGeneralFunction . TASKDELETE , new AsyncCallback ( ModifyMonitorTaskCallBack ) , null ) ;
//{
// MessageBox.Show(sss, "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Error);
//}
TSMMonitorRefresh_Click ( ) ;
}
}
catch ( Exception ex )
{
MessageBox . Show ( ex . Message , "������ʾ��" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
}
}
private void comboBox1_SelectedIndexChanged ( object sender , EventArgs e )
{
try
{
string df = "" ;
string wherestr = " where 1=1 " ;
switch ( this . comboBox1 . Text )
{
case "����" :
df = "����" ;
break ;
case "������������" :
df = "������������" ;
break ;
case "�豸ָ������" :
df = "�豸ָ������" ;
wherestr = " where f_status<>0 " ;
break ;
case "�豸����" :
df = "�豸����" ; //20130817richard
wherestr = " where f_status<>0 " ;
break ;
default :
return ;
}
//20100208
string sql = "select distinct " + df + " from V_Monitor_Task " + wherestr ;
DataView dv = dbo . ExceSQL ( sql ) . Tables [ 0 ] . DefaultView ;
if ( dv . Count > 0 )
{
this . textBox1 . DataSource = null ;
this . textBox1 . DisplayMember = df ;
this . textBox1 . ValueMember = df ;
this . textBox1 . DataSource = dv ;
}
}
catch ( Exception ex )
{
throw ex ;
}
}
private void dgvMonitor_CellMouseDown ( object sender , DataGridViewCellMouseEventArgs e )
{
if ( e . Button = = MouseButtons . Right ) //20130402
{
if ( ( e . RowIndex > = 0 ) & & ( e . ColumnIndex > = 0 ) )
{
//��������ѡ��״̬�Ͳ��ٽ�������
if ( dgvMonitor . Rows [ e . RowIndex ] . Selected = = false )
{
dgvMonitor . ClearSelection ( ) ;
dgvMonitor . Rows [ e . RowIndex ] . Selected = true ;
}
//ֻѡ��һ��ʱ���û��Ԫ��
if ( dgvMonitor . SelectedRows . Count = = 1 )
{
dgvMonitor . CurrentCell = dgvMonitor . Rows [ e . RowIndex ] . Cells [ e . ColumnIndex ] ;
}
//���������˵�
cmMonitor . Show ( MousePosition . X , MousePosition . Y ) ;
}
}
}
void ModifyMonitorTaskCallBack ( IAsyncResult ar )
{
if ( this . IsDisposed = = true ) return ;
string errtext = string . Empty ;
this . BeginInvoke ( new MethodInvoker ( delegate ( )
{
if ( CStaticClass . WcfControl . EndModifyMonitorTask ( out errtext , ar ) = = false )
{
MessageBox . Show ( errtext , "������ʾ��" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
}
TSMMonitorRefresh_Click ( ) ;
} ) ) ;
}
private void FrmModifyMonitor_FormClosing ( object sender , FormClosingEventArgs e )
{
_f ormInstance = null ;
}
private void rbmonAll_Click ( object sender , EventArgs e )
{
RadioButton rb = ( RadioButton ) sender ;
if ( rb . Checked = = true )
{
_ monstatus = " F_Status>=-1 " ;
}
TSMMonitorRefresh_Click ( ) ;
}
private void rbmonRun_Click ( object sender , EventArgs e )
{
if ( rbmonRun . Checked = = true )
{
_ monstatus = " (F_Status>=1) " ;
}
TSMMonitorRefresh_Click ( ) ;
}
private void rbmonWait_Click ( object sender , EventArgs e )
{
RadioButton rb = ( RadioButton ) sender ;
if ( rb . Checked = = true )
{
_ monstatus = " F_Status=0 " ;
}
TSMMonitorRefresh_Click ( ) ;
}
private void radioButton1_Click ( object sender , EventArgs e )
{
RadioButton rb = ( RadioButton ) sender ;
if ( rb . Checked = = true )
{
//CStaticClass.RealRefresh = true;
_ monstatus = "(�豸ָ������ IN(SELECT MIN(�豸ָ������) FROM V_Monitor_Task GROUP BY ������������))" ;
//string sql = string.Format("SELECT * FROM V_Monitor_Task WHERE {0}", _monstatus);
//this.dgvMonitor.DataSource = dbo.ExceSQL(sql).Tables[0].DefaultView;
TSMMonitorRefresh_Click ( ) ;
}
}
}
}