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.
910 lines
44 KiB
910 lines
44 KiB
3 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 System.Net.Sockets;
|
||
|
using System.Threading;
|
||
|
using ICommLayer;
|
||
|
using CommLayerFactory;
|
||
|
using Microsoft.VisualBasic;
|
||
|
namespace ControlSystem
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// Creator:Richard.liu
|
||
|
/// �豸ָ�����й���
|
||
|
/// </summary>
|
||
|
public partial class FrmModifyMonitor : Form
|
||
|
{
|
||
|
string _monstatus = " F_Status<>-1 ";
|
||
|
private static FrmModifyMonitor _formInstance;
|
||
|
|
||
|
public static FrmModifyMonitor FormInstance
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
if (_formInstance == null)
|
||
|
{
|
||
|
_formInstance = new FrmModifyMonitor();
|
||
|
}
|
||
|
return _formInstance;
|
||
|
}
|
||
|
set { _formInstance = value; }
|
||
|
}
|
||
|
CGetState gs = new CGetState();
|
||
|
DBOperator dbo = CStaticClass.dbo;
|
||
|
DBOperator dboM = CStaticClass.dboM;
|
||
|
CCommonFunction ccf = new CCommonFunction();
|
||
|
Model.MDevice devinfo;
|
||
|
public FrmModifyMonitor()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
_formInstance = this;
|
||
|
}
|
||
|
|
||
|
private void cmMonitor_Opening(object sender, CancelEventArgs e)
|
||
|
{
|
||
|
if (this.dgvMonitor.CurrentRow == null)
|
||
|
{
|
||
|
TSMonitor.Visible = false;
|
||
|
TSMManager.Visible = false;
|
||
|
TSMSimulateRun.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.ToInt32(this.dgvMonitor.CurrentRow.Cells[0].Value) > 0)
|
||
|
{
|
||
|
TSMonitor.Visible = true;
|
||
|
TSMManager.Visible = true;
|
||
|
//TSMSimulateRun.Visible = true;
|
||
|
TSMmonitorOK.Visible = true;
|
||
|
TSMmonitorDel.Visible = true;
|
||
|
TSMRestore.Visible = true;
|
||
|
toolStripSeparator2.Visible = true;
|
||
|
|
||
|
TSMManager.Text = "�������ͣ�" + this.dgvMonitor.CurrentRow.Cells[1].Value.ToString() +
|
||
|
"����������������" + this.dgvMonitor.CurrentRow.Cells[0].Value.ToString();
|
||
|
TSMonitor.Text = "�豸ָ��������" + this.dgvMonitor.CurrentRow.Cells[2].Value.ToString();
|
||
|
//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)
|
||
|
{
|
||
|
char[] cc = new char[1] { '��' };
|
||
|
string[] split = TSMonitor.Text.Split(cc);
|
||
|
if (split[1] == "") return;
|
||
|
|
||
|
|
||
|
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);
|
||
|
|
||
|
AssociateComplete(Convert.ToInt32(dv[0]["F_DeviceIndex"]), Convert.ToInt32(dv[0]["F_MonitorIndex"]), Convert.ToInt32(dv[0]["F_Status"]));
|
||
|
FrmControlMonitor.FormInstance.MonitorRefresh();//20110222
|
||
|
this.dgvMonitor.DataSource = dbo.ExceSQL("select * from V_Monitor_Task where " + _monstatus + " order by �豸ָ������ asc ").Tables[0].DefaultView;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void TSMRestore_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
|
||
|
char[] cc = new char[1] { '��' };
|
||
|
string[] split = TSMonitor.Text.Split(cc);
|
||
|
if (split[1] == "") return;
|
||
|
|
||
|
|
||
|
ISendDeviceOrder sdo;
|
||
|
int DeviceIdx;
|
||
|
int devKind;
|
||
|
int mindex = Convert.ToInt32(split[1]);
|
||
|
int fid = ccf.GetManageTaskIndexfromMonitor(mindex);
|
||
|
int mankind = ccf.GetManageTaskKindIndexFromMonitor(mindex);
|
||
|
|
||
|
|
||
|
//20100108��Ϊselect *
|
||
|
DataView dv = dbo.ExceSQL("select * from T_Monitor_Task where F_MonitorIndex=" + mindex).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 = " + 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 = ccf.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);
|
||
|
//������������һ����λ
|
||
|
//����mindex������������f_associatemonitor�����ݣ����ȸ�λ����������������mindex�DZ����������ȸ�λ�Լ����ٸ�λ����������
|
||
|
DataView dv1 = dbo.ExceSQL("select F_DeviceIndex,F_Associate from T_Monitor_Task where F_Associate IS NOT NULL and F_MonitorIndex=" + mindex).Tables[0].DefaultView;
|
||
|
if (dv1.Count > 0)
|
||
|
{
|
||
|
DataView dv2 = dbo.ExceSQL("select F_DeviceIndex,F_MonitorIndex from T_Monitor_Task where F_MonitorIndex=" + Convert.ToInt32(dv1[0]["F_Associate"])).Tables[0].DefaultView;
|
||
|
if (dv2.Count > 0)//�й�������ȸ�λ��������
|
||
|
{
|
||
|
|
||
|
DeviceIdx = Convert.ToInt32(dv2[0]["F_DeviceIndex"]);
|
||
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
if ((devKind == 2) || (devKind == 4))
|
||
|
{//���ͻ���RGV����
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0);
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
devinfo.SendMessage = null;
|
||
|
Model.CGetInfo.SetDeviceInfo(devinfo);
|
||
|
}
|
||
|
if ((devKind == 1)) //�Ѷ���
|
||
|
{
|
||
|
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
||
|
}
|
||
|
|
||
|
dbo.ExceSQL("update T_Base_Device set F_LockedState=0 where F_DeviceIndex=" + Convert.ToInt32(dv2[0]["F_DeviceIndex"]));
|
||
|
dbo.ExceSQL("update T_Monitor_Task set F_SendCount=0,F_Status=0 where F_MonitorIndex=" + Convert.ToInt32(dv2[0]["F_MonitorIndex"]));
|
||
|
}
|
||
|
//�ٸ�λ�Լ�
|
||
|
DeviceIdx = Convert.ToInt32(dv[0]["F_DeviceIndex"]);
|
||
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
if ((devKind == 2) || (devKind == 4))
|
||
|
{//���ͻ���RGV����
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0);
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
devinfo.SendMessage = null;
|
||
|
Model.CGetInfo.SetDeviceInfo(devinfo);
|
||
|
}
|
||
|
if ((devKind == 1)) //�Ѷ���
|
||
|
{
|
||
|
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
||
|
}
|
||
|
//if ((devKind == 6)) //AGV
|
||
|
//{
|
||
|
// int agvtask = ccf.GetAGVTask(mindex);
|
||
|
// if (agvtask != -1)
|
||
|
// {
|
||
|
// sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
// sdo.SendDeviceOrder(1, agvtask, 65, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
||
|
|
||
|
// }
|
||
|
//}
|
||
|
dbo.ExceSQL("update T_Base_Device set F_LockedState=0 where F_DeviceIndex=" + Convert.ToInt32(dv[0]["F_DeviceIndex"]));
|
||
|
dbo.ExceSQL("update T_Monitor_Task set F_SendCount=0,F_Status=0 where F_MonitorIndex=" + Convert.ToInt32(dv[0]["F_MonitorIndex"]));
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
|
||
|
//�Լ��Ƿ���,�ȸ�λ�Լ����ٸ�λ������
|
||
|
DataView dv3 = dbo.ExceSQL("select F_DeviceIndex,F_MonitorIndex from T_Monitor_Task where F_Associate ='" + mindex + "'").Tables[0].DefaultView;
|
||
|
if (dv3.Count > 0)
|
||
|
{ //�ȸ�λ�Լ�
|
||
|
DeviceIdx = Convert.ToInt32(dv[0]["F_DeviceIndex"]);
|
||
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
if ((devKind == 2) || (devKind == 4))
|
||
|
{//���ͻ���RGV����
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0);
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
devinfo.SendMessage = null;
|
||
|
Model.CGetInfo.SetDeviceInfo(devinfo);
|
||
|
}
|
||
|
if ((devKind == 1)) //�Ѷ���
|
||
|
{
|
||
|
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
||
|
}
|
||
|
//if ((devKind == 6)) //AGV
|
||
|
//{
|
||
|
// int agvtask = ccf.GetAGVTask(mindex);
|
||
|
// if (agvtask != -1)
|
||
|
// {
|
||
|
// sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
// sdo.SendDeviceOrder(1, agvtask, 65, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
||
|
|
||
|
// }
|
||
|
//}
|
||
|
dbo.ExceSQL("update T_Base_Device set F_LockedState=0 where F_DeviceIndex=" + Convert.ToInt32(dv[0]["F_DeviceIndex"]));
|
||
|
dbo.ExceSQL("update T_Monitor_Task set F_SendCount=0,F_Status=0 where F_MonitorIndex=" + mindex);
|
||
|
//�ٸ�λ������
|
||
|
DeviceIdx = Convert.ToInt32(dv3[0]["F_DeviceIndex"]);
|
||
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
if ((devKind == 2) || (devKind == 4))
|
||
|
{//���ͻ���RGV����
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0);
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
devinfo.SendMessage = null;
|
||
|
Model.CGetInfo.SetDeviceInfo(devinfo);
|
||
|
}
|
||
|
if ((devKind == 1)) //�Ѷ���
|
||
|
{
|
||
|
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
||
|
}
|
||
|
dbo.ExceSQL("update T_Base_Device set F_LockedState=0 where F_DeviceIndex=" + Convert.ToInt32(dv3[0]["F_DeviceIndex"]));
|
||
|
dbo.ExceSQL("update T_Monitor_Task set F_SendCount=0,F_Status=0 where F_MonitorIndex=" + Convert.ToInt32(dv3[0]["F_MonitorIndex"]));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//����������ֻ��λ�Լ�
|
||
|
DeviceIdx = Convert.ToInt32(dv[0]["F_DeviceIndex"]);
|
||
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
if ((devKind == 2) || (devKind == 4))
|
||
|
{//���ͻ���RGV����
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0);
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
||
|
devinfo.SendMessage = null;
|
||
|
Model.CGetInfo.SetDeviceInfo(devinfo);
|
||
|
}
|
||
|
if ((devKind == 1)) //�Ѷ���
|
||
|
{
|
||
|
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
||
|
}
|
||
|
//if ((devKind == 6)) //AGV
|
||
|
//{
|
||
|
// int agvtask = ccf.GetAGVTask(mindex);
|
||
|
// if (agvtask != -1)
|
||
|
// {
|
||
|
// sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
||
|
// sdo.SendDeviceOrder(1, agvtask, 65, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
||
|
|
||
|
// }
|
||
|
//}
|
||
|
dbo.ExceSQL("update T_Base_Device set F_LockedState=0 where F_DeviceIndex=" + Convert.ToInt32(dv[0]["F_DeviceIndex"]));
|
||
|
dbo.ExceSQL("update T_Monitor_Task set F_SendCount=0,F_Status=0 where F_MonitorIndex=" + mindex);
|
||
|
}
|
||
|
}
|
||
|
//������FERRORCODE����
|
||
|
if (mankind == 1)
|
||
|
{
|
||
|
dboM.ExceSQL("UPDATE IO_CONTROL SET ERROR_TEXT ='' WHERE CONTROL_ID=" + fid + "");
|
||
|
}
|
||
|
dbo.ExceSQL("UPDATE T_Manage_Task SET FERRORCODE ='' WHERE FID=" + fid + " and F_ManageTaskKindIndex=" + mankind + "");
|
||
|
|
||
|
}
|
||
|
|
||
|
FrmControlMonitor.FormInstance.MonitorRefresh();//20110222
|
||
|
FrmControlMonitor.FormInstance.ManagerRefresh();//20110222
|
||
|
|
||
|
this.dgvMonitor.DataSource = dbo.ExceSQL("select * from V_Monitor_Task where " + _monstatus + " order by �豸ָ������ asc ").Tables[0].DefaultView;
|
||
|
}
|
||
|
|
||
|
private void TSMSimulateRun_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
char[] cc1 = new char[1] { '��' };
|
||
|
string[] split = TSMonitor.Text.Split(cc1);
|
||
|
if (split[1] == "") return;
|
||
|
|
||
|
CCommonFunction ccf = new CCommonFunction();
|
||
|
DataSet ds = dbo.ExceSQL("SELECT F_ManageTaskIndex, F_ManageTaskKindIndex," +
|
||
|
" F_MonitorIndex, F_DeviceIndex,F_NumParam2,F_NumParam3 FROM T_Monitor_Task Where F_MonitorIndex=" +
|
||
|
Convert.ToInt32(split[1]));
|
||
|
DataView dv = ds.Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
ccf.SendOrderSuccess(Convert.ToInt32(dv[0]["F_ManageTaskKindIndex"]),
|
||
|
Convert.ToInt32(dv[0]["F_ManageTaskIndex"]), Convert.ToInt32(dv[0]["F_MonitorIndex"]),
|
||
|
Convert.ToInt32(dv[0]["F_DeviceIndex"]), 0);
|
||
|
CGetState cg = new CGetState();
|
||
|
cg._States = new int[14];
|
||
|
cg._States[1] = 2;//������
|
||
|
cg._States[2] = Convert.ToInt32(dv[0]["F_MonitorIndex"]);//������
|
||
|
cg._States[3] = Convert.ToInt32(dv[0]["F_NumParam2"]);//X���꣨ˮƽ��
|
||
|
cg._States[4] = Convert.ToInt32(dv[0]["F_NumParam3"]);//Y���꣨��ֱ��
|
||
|
cg._States[5] = Convert.ToInt32(dv[0]["F_DeviceIndex"]);//�豸��
|
||
|
FrmControlMonitor.FormInstance.MonitorRefresh();//20110222
|
||
|
FrmControlMonitor.FormInstance.ManagerRefresh();//20110222
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
private void rbmonAll_CheckedChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
RadioButton rb = (RadioButton)sender;
|
||
|
if (rb.Checked == true)
|
||
|
{
|
||
|
_monstatus = " F_Status<>-1 ";
|
||
|
}
|
||
|
TSMMonitorRefresh_Click(sender, e);
|
||
|
}
|
||
|
private void TSMMonitorRefresh_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
CStaticClass.RealRefresh = true;
|
||
|
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(sender, e);
|
||
|
}
|
||
|
|
||
|
private void rbmonWait_CheckedChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
RadioButton rb = (RadioButton)sender;
|
||
|
if (rb.Checked == true)
|
||
|
{
|
||
|
_monstatus = " F_Status=0 ";
|
||
|
}
|
||
|
TSMMonitorRefresh_Click(sender, e);
|
||
|
}
|
||
|
|
||
|
private void button1_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
if (this.textBox1.Text.Trim().Length == 0) return;
|
||
|
if (this.comboBox1.Text == "��������")
|
||
|
{
|
||
|
_monstatus = " ������Ϣ='" + this.textBox1.Text.Trim() + "' ";
|
||
|
}
|
||
|
if (this.comboBox1.Text == "�豸ָ������")
|
||
|
{
|
||
|
_monstatus = " �豸ָ������='" + this.textBox1.Text.Trim() + "' ";
|
||
|
}
|
||
|
if (this.comboBox1.Text == "������������")
|
||
|
{
|
||
|
_monstatus = " ������������='" + this.textBox1.Text.Trim() + "' ";
|
||
|
}
|
||
|
TSMMonitorRefresh_Click(sender, e);
|
||
|
}
|
||
|
|
||
|
private void button2_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
_monstatus = " F_Status<>-1 ";
|
||
|
|
||
|
TSMMonitorRefresh_Click(sender, e);
|
||
|
}
|
||
|
|
||
|
private void dgvMonitor_DataSourceChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
dgvMonitor.Columns["F_Status"].Visible = false;
|
||
|
}
|
||
|
|
||
|
private void FrmModifyMonitor_Load(object sender, EventArgs e)
|
||
|
{
|
||
|
rbmonRun_CheckedChanged(sender, e);
|
||
|
}
|
||
|
|
||
|
private void tsmAGVGet_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
string sql = "";
|
||
|
//��T_Monitor_Task���л���F_NumParam2�ֶ�ֵ ��������Ϣ���ص�С��������
|
||
|
DataTable tableMonitorTask = dbo.ExceSQL("SELECT 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"]) + "");
|
||
|
if (ccf.GetManageTaskKindIndexFromMonitor(Convert.ToInt32(this.dgvMonitor.CurrentRow.Cells[2].Value)) == 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;
|
||
|
}
|
||
|
FrmControlMonitor.FormInstance.MonitorRefresh();//20110222
|
||
|
FrmControlMonitor.FormInstance.ManagerRefresh();//20110222
|
||
|
}
|
||
|
|
||
|
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);
|
||
|
gs.ActionComplete(1001, Convert.ToInt32(this.dgvMonitor.CurrentRow.Cells[2].Value), Model.CGeneralFunction.TASKFINISH);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageBox.Show("ֻ��AGV�����ſ����ֹ�����AGV�Ż����ɣ�", "��������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void tsmAGVBank_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
FrmControlMonitor.FormInstance.MonitorRefresh();//20110222
|
||
|
FrmControlMonitor.FormInstance.ManagerRefresh();//20110222
|
||
|
gs.ActionComplete(1001, Convert.ToInt32(this.dgvMonitor.CurrentRow.Cells[2].Value), Model.CGeneralFunction.TASKFINISH);
|
||
|
}
|
||
|
|
||
|
private void tsmAGVGoods_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
gs.ActionComplete(1001, Convert.ToInt32(this.dgvMonitor.CurrentRow.Cells[2].Value), Model.CGeneralFunction.TASKFINISH);
|
||
|
FrmControlMonitor.FormInstance.MonitorRefresh();//20110222
|
||
|
FrmControlMonitor.FormInstance.ManagerRefresh();//20110222
|
||
|
}
|
||
|
|
||
|
//private void button3_Click(object sender, EventArgs e)
|
||
|
//{
|
||
|
// if (this.dgvMonitor.CurrentRow == null)
|
||
|
// {
|
||
|
|
||
|
// return;
|
||
|
// }
|
||
|
// if (Convert.ToInt32(this.dgvMonitor.CurrentRow.Cells[0].Value) > 0)
|
||
|
// {
|
||
|
|
||
|
// if (this.dgvMonitor.CurrentRow.Cells[3].Value.ToString() == "1001")
|
||
|
// {
|
||
|
// if (MessageBox.Show("��ȷ���ֹ�ǿ�Ʒ���ѡ�ж��е�AGV����������", "������ʾ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
||
|
// {
|
||
|
// return;
|
||
|
// }
|
||
|
// dbo.ExceSQL("UPDATE T_Monitor_Task SET F_AgvNo = " + this.nudAGVtask.Value + " WHERE (F_MonitorIndex =" + this.dgvMonitor.CurrentRow.Cells[2].Value + ")");
|
||
|
// DataView dv = dbo.ExceSQL("SELECT * FROM T_Monitor_Task (F_MonitorIndex =" + this.dgvMonitor.CurrentRow.Cells[2].Value + ") and (F_AGVNextTask IS NOT NULL)").Tables[0].DefaultView;
|
||
|
// if (dv.Count > 0)
|
||
|
// {
|
||
|
// dbo.ExceSQL("UPDATE T_Monitor_Task SET F_AgvNo = " + this.nudAGVtask.Value + " WHERE (F_MonitorIndex =" + dv[0]["F_AGVNextTask"] + ")");
|
||
|
|
||
|
// }
|
||
|
// dv = dbo.ExceSQL("SELECT * FROM T_Monitor_Task (F_AGVNextTask =" + this.dgvMonitor.CurrentRow.Cells[2].Value + ")").Tables[0].DefaultView;
|
||
|
// if (dv.Count > 0)
|
||
|
// {
|
||
|
// dbo.ExceSQL("UPDATE T_Monitor_Task SET F_AgvNo = " + this.nudAGVtask.Value + " WHERE (F_MonitorIndex =" + dv[0]["F_MonitorIndex"] + ")");
|
||
|
|
||
|
// }
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// MessageBox.Show("ֻ��AGV�����ſ����ֹ�ǿ�Ʒ���ѡ�ж��е�AGV�����ţ�", "��������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||
|
// return;
|
||
|
// }
|
||
|
|
||
|
// }
|
||
|
//}
|
||
|
|
||
|
int GetDeviceKindIdx(int devIdx)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
devinfo = Model.CGetInfo.GetDeviceInfo(devIdx);
|
||
|
return devinfo.DeviceKind;
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
int GetManageTaskIndexfromMonitor(int monitorIdx)
|
||
|
{
|
||
|
DataView dv = dbo.ExceSQL("SELECT F_ManageTaskIndex FROM T_Monitor_Task WHERE (F_MonitorIndex = " + monitorIdx + ")").Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0]["F_ManageTaskIndex"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
int GetManageTaskKindIndexFromMonitor(int monitorIdx)
|
||
|
{
|
||
|
DataView dv = dbo.ExceSQL("SELECT F_ManageTaskKindIndex FROM T_Monitor_Task WHERE (F_MonitorIndex = " + monitorIdx + ")").Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0]["F_ManageTaskKindIndex"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
int GetDeviceOrderFromMonitor(int MonitorIndex)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string sql = "select F_DeviceCommandIndex from T_Monitor_Task where (F_DeviceCommandIndex IS NOT NULL) and F_MonitorIndex=" + MonitorIndex;
|
||
|
DataView dv = dbo.ExceSQL(sql).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0]["F_DeviceCommandIndex"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void AssociateComplete(int deviceIdx, int mindex, int status)
|
||
|
{
|
||
|
int ClearZero = 0;
|
||
|
if (status >= 1)
|
||
|
{
|
||
|
ClearZero = 1;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
ClearZero = Model.CGeneralFunction.TASKFINISH;
|
||
|
}
|
||
|
int DeviceIdx = deviceIdx;
|
||
|
int devKind;
|
||
|
//20091107
|
||
|
DataView dv = dbo.ExceSQL("select F_MonitorIndex,F_Status,F_DeviceIndex,F_DeviceCommandIndex,F_NumParam4 from T_Monitor_Task where F_MonitorIndex=" + mindex).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
//������������һ�𱨸�����
|
||
|
//����mindex������������f_associatemonitor�����ݣ����ȱ������ɱ���������������mindex�DZ����������ȱ��������Լ����ٱ�����������������
|
||
|
DataView dv1 = dbo.ExceSQL("select F_DeviceIndex,F_Associate from T_Monitor_Task where F_Associate IS NOT NULL and F_MonitorIndex=" + mindex).Tables[0].DefaultView;
|
||
|
if (dv1.Count > 0)
|
||
|
{
|
||
|
DataView dv2 = dbo.ExceSQL("select F_DeviceIndex,F_MonitorIndex from T_Monitor_Task where F_MonitorIndex=" + Convert.ToInt32(dv1[0]["F_Associate"])).Tables[0].DefaultView;
|
||
|
if (dv2.Count > 0)//�й�������ȱ������ɹ�������
|
||
|
{
|
||
|
|
||
|
DeviceIdx = Convert.ToInt32(dv2[0]["F_DeviceIndex"]);
|
||
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
|
||
|
gs.ActionComplete(DeviceIdx, Convert.ToInt32(dv2[0]["F_MonitorIndex"]), ClearZero);
|
||
|
}
|
||
|
//�ٱ��������Լ�
|
||
|
DeviceIdx = Convert.ToInt32(dv[0]["F_DeviceIndex"]);
|
||
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
|
||
|
gs.ActionComplete(DeviceIdx, mindex, ClearZero);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//�Լ��Ƿ���,�ȱ��������Լ����ٱ�������������
|
||
|
DataView dv3 = dbo.ExceSQL("select F_DeviceIndex,F_MonitorIndex from T_Monitor_Task where F_Associate ='" + mindex + "'").Tables[0].DefaultView;
|
||
|
if (dv3.Count > 0)
|
||
|
{ //�ȱ��������Լ�
|
||
|
DeviceIdx = Convert.ToInt32(dv[0]["F_DeviceIndex"]);
|
||
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
|
||
|
gs.ActionComplete(DeviceIdx, mindex, ClearZero);
|
||
|
//�ٱ�������������
|
||
|
DeviceIdx = Convert.ToInt32(dv3[0]["F_DeviceIndex"]);
|
||
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
gs.ActionComplete(DeviceIdx, Convert.ToInt32(dv3[0]["F_MonitorIndex"]), ClearZero);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//����������ֻ���������Լ�
|
||
|
DeviceIdx = Convert.ToInt32(dv[0]["F_DeviceIndex"]);
|
||
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
||
|
//20101219����״̬�ij����ͻ�����Ҫ������һ���������ɵ�����
|
||
|
if ((devKind == 2) && (Convert.ToInt32(dv[0]["F_NumParam4"]) > 0) && (dv[0]["F_DeviceCommandIndex"].ToString() == "6") && (Convert.ToInt32( dv[0]["F_Status"]) > 0))
|
||
|
{
|
||
|
DeviceIdx = Convert.ToInt32(dv[0]["F_NumParam4"]);
|
||
|
}
|
||
|
gs.ActionComplete(DeviceIdx, mindex, ClearZero);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
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) >= 30)
|
||
|
{
|
||
|
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;
|
||
|
|
||
|
|
||
|
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);
|
||
|
gs.ActionComplete(Convert.ToInt32(dv[0]["F_DeviceIndex"]), Convert.ToInt32(dv[0]["F_MonitorIndex"]), Model.CGeneralFunction.TASKDELETE);//20100905
|
||
|
FrmControlMonitor.FormInstance.MonitorRefresh();//20110222
|
||
|
this.dgvMonitor.DataSource = dbo.ExceSQL("select * from V_Monitor_Task where " + _monstatus + " order by �豸ָ������ asc ").Tables[0].DefaultView;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string df = "";
|
||
|
|
||
|
switch (this.comboBox1.Text)
|
||
|
{
|
||
|
case "��������":
|
||
|
df = "������Ϣ";
|
||
|
break;
|
||
|
case "������������":
|
||
|
df = "������������";
|
||
|
break;
|
||
|
case "�豸ָ������":
|
||
|
df = "�豸ָ������";
|
||
|
break;
|
||
|
|
||
|
|
||
|
default:
|
||
|
return;
|
||
|
}
|
||
|
//20100208
|
||
|
string sql = "select distinct " + df + " from V_Monitor_Task ";
|
||
|
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.RowIndex >= 0))//&&(e.Button == MouseButtons.Right)
|
||
|
{
|
||
|
dgvMonitor.ClearSelection();
|
||
|
dgvMonitor.Rows[e.RowIndex].Selected = true;
|
||
|
dgvMonitor.CurrentCell = dgvMonitor.Rows[e.RowIndex].Cells[0];
|
||
|
|
||
|
}
|
||
|
if (e.RowIndex >= 0)
|
||
|
{
|
||
|
if (this.dgvMonitor.CurrentRow.Cells[3].Value.ToString() == "1001")
|
||
|
{
|
||
|
this.groupBox1.Visible = true;
|
||
|
int fid =ccf.GetManageTaskIndexfromMonitor(Convert.ToInt32( this.dgvMonitor.CurrentRow.Cells[2].Value));
|
||
|
int mti =ccf.GetManageTaskKindIndexFromMonitor( Convert.ToInt32(this.dgvMonitor.CurrentRow.Cells[2].Value));
|
||
|
DataView dv = dbo.ExceSQL("SELECT FSTARTDEVICE FROM T_Manage_Task WHERE (F_ManageTaskKindIndex = "+
|
||
|
mti+") AND (FID = "+fid+") and ((FSTARTDEVICE = '3801') or (FENDDEVICE = '3801'))").Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
cobAGVno.Items.Clear();
|
||
|
cobAGVno.Items.Add(3);
|
||
|
cobAGVno.Items.Add(4);
|
||
|
cobAGVno.Text = "3";
|
||
|
}
|
||
|
dv = dbo.ExceSQL("SELECT FSTARTDEVICE FROM T_Manage_Task WHERE (F_ManageTaskKindIndex = " +
|
||
|
mti + ") AND (FID = " + fid + ") and ((FSTARTDEVICE = '2801') or (FENDDEVICE = '2801'))").Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
cobAGVno.Items.Clear();
|
||
|
cobAGVno.Items.Add(1);
|
||
|
cobAGVno.Items.Add(2);
|
||
|
cobAGVno.Text = "1";
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
this.groupBox1.Visible = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void btAGVNO_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
|
||
|
if (dgvMonitor.CurrentCell == null) return;
|
||
|
int agvno=0;
|
||
|
if (int.TryParse(cobAGVno.Text, out agvno) == true)
|
||
|
{
|
||
|
int fid =ccf.GetManageTaskIndexfromMonitor( Convert.ToInt32(this.dgvMonitor.CurrentRow.Cells[2].Value));
|
||
|
int mti =ccf.GetManageTaskKindIndexFromMonitor( Convert.ToInt32(this.dgvMonitor.CurrentRow.Cells[2].Value));
|
||
|
if (MessageBox.Show("��ȷ��Ҫ�ġ�" + this.dgvMonitor.CurrentRow.Cells[1].Value.ToString() + ",��������������" + fid.ToString() + "����AGV��������", "������ʾ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
object ob = dbo.GetSingle("SELECT FID FROM T_Manage_Task WHERE (F_ManageTaskKindIndex = "+mti+") AND (F_RELATIVECONTORLID = "+fid+")");
|
||
|
int rfid = 0;
|
||
|
if (ob == null) rfid = 0;
|
||
|
else
|
||
|
{
|
||
|
int.TryParse(ob.ToString(), out rfid);
|
||
|
}
|
||
|
dbo.ExecuteSql("update T_Monitor_Task set F_AgvNo=" + agvno + " where (F_DeviceIndex=1001) and (F_ManageTASKKINDINDEX=" + mti + ") and (F_ManageTaskIndex=" + fid + " or F_ManageTaskIndex=" + rfid + ") ");
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageBox.Show("AGV����ֻ�������֣�", "��������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
|
return;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|