670 lines
29 KiB
C#
670 lines
29 KiB
C#
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 FrmModifyManage : Form
|
||
{
|
||
string _manstatus= " F_Status<>-1 ";
|
||
private static FrmModifyManage _formInstance;
|
||
|
||
public static FrmModifyManage FormInstance
|
||
{
|
||
get
|
||
{
|
||
if (_formInstance == null)
|
||
{
|
||
_formInstance = new FrmModifyManage();
|
||
}
|
||
return _formInstance;
|
||
}
|
||
set { _formInstance = value; }
|
||
}
|
||
Model.MDevice devinfo;
|
||
DBOperator dbo = CStaticClass.dbo;
|
||
DBOperator dboM = CStaticClass.dboM;
|
||
public FrmModifyManage()
|
||
{
|
||
InitializeComponent();
|
||
_formInstance = this;
|
||
}
|
||
|
||
private void rbmanAll_CheckedChanged(object sender, EventArgs e)
|
||
{
|
||
|
||
RadioButton rb = (RadioButton)sender;
|
||
if (rb.Checked == true)
|
||
{
|
||
_manstatus = " F_Status<>-1 ";
|
||
}
|
||
TSMrefresh_Click(sender, e);
|
||
}
|
||
|
||
private void TSMrefresh_Click(object sender, EventArgs e)
|
||
{
|
||
CStaticClass.RealRefresh = true;
|
||
this.dgvManager.DataSource = dbo.ExceSQL("select * from V_Manage_Task where " + _manstatus).Tables[0].DefaultView;
|
||
}
|
||
|
||
private void rbmanRun_CheckedChanged(object sender, EventArgs e)
|
||
{
|
||
if (rbmanRun.Checked == true)
|
||
{
|
||
_manstatus = " F_Status>=1 ";
|
||
}
|
||
TSMrefresh_Click(sender, e);
|
||
}
|
||
|
||
private void rbmanWait_CheckedChanged(object sender, EventArgs e)
|
||
{
|
||
RadioButton rb = (RadioButton)sender;
|
||
if (rb.Checked == true)
|
||
{
|
||
_manstatus = " F_Status=0 ";
|
||
}
|
||
TSMrefresh_Click(sender, e);
|
||
}
|
||
|
||
private void button1_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
if (this.textBox1.Text.Trim().Length == 0) return;
|
||
int index = 0;
|
||
bool isint = int.TryParse(this.textBox1.Text.Trim(), out index);
|
||
if (this.comboBox1.Text == "±íÏäÌõÂë")
|
||
{
|
||
//20091016
|
||
_manstatus = " ±íÏäÌõÂë like'%" + this.textBox1.Text.Trim() + "%' ";
|
||
}
|
||
|
||
if (this.comboBox1.Text == "µ÷¶ÈÈÎÎñË÷Òý")
|
||
{
|
||
if(isint==false)
|
||
{
|
||
//MessageBox.Show("ÇëÊäÈëÊý×Ö£¡", "Îó²Ù×÷Ìáʾ£º", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
textBox1.Text = string.Empty;
|
||
return;
|
||
}
|
||
|
||
_manstatus = " µ÷¶ÈÈÎÎñË÷Òý='" + this.textBox1.Text.Trim() + "' ";
|
||
|
||
}
|
||
TSMrefresh_Click(sender, e);
|
||
}
|
||
|
||
private void button2_Click(object sender, EventArgs e)
|
||
{
|
||
_manstatus = " F_Status<>-1 ";
|
||
|
||
TSMrefresh_Click(sender, e);
|
||
}
|
||
|
||
private void dgvManager_DataSourceChanged(object sender, EventArgs e)
|
||
{
|
||
dgvManager.Columns["F_Status"].Visible = false;
|
||
}
|
||
|
||
private void cmManager_Opening(object sender, CancelEventArgs e)
|
||
{
|
||
if (this.dgvManager.CurrentRow == null)
|
||
{
|
||
TSMmanagerOK.Visible = false;
|
||
//TSMrefresh.Visible = false;
|
||
TSManager.Visible = false;
|
||
toolStripSeparator1.Visible = false;
|
||
//TSMmanagerDisassemble.Visible = false;
|
||
toolStripMenuItem1.Visible = false;
|
||
toolStripSeparator2.Visible = false;
|
||
return;
|
||
}
|
||
if (Convert.ToInt32(this.dgvManager.CurrentRow.Cells["µ÷¶ÈÈÎÎñË÷Òý"].Value) > 0)
|
||
{
|
||
TSMmanagerOK.Visible = true;
|
||
|
||
TSManager.Visible = true;
|
||
toolStripSeparator1.Visible = true;
|
||
toolStripSeparator2.Visible = true;
|
||
//TSMmanagerDisassemble.Visible = true;
|
||
toolStripMenuItem1.Visible = true;
|
||
TSManager.Text = "ÈÎÎñÀàÐÍ£º" + this.dgvManager.CurrentRow.Cells["ÈÎÎñÀàÐÍ"].Value.ToString() +
|
||
"£»µ÷¶ÈÈÎÎñË÷Òý£º" + this.dgvManager.CurrentRow.Cells["µ÷¶ÈÈÎÎñË÷Òý"].Value.ToString();
|
||
|
||
|
||
}
|
||
}
|
||
|
||
private void TSMmanagerOK_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
|
||
char[] cc = new char[1] { '£º' };
|
||
string[] split = TSManager.Text.Split(cc);
|
||
if ((split[1] == "") || (split[2] == ""))
|
||
{
|
||
return;
|
||
}
|
||
char[] scc = new char[1] { '£»' };
|
||
string[] strsplit = split[1].Split(scc);
|
||
int mti = 0;
|
||
int fid = Convert.ToInt32(split[2]);
|
||
if (strsplit[0] == "") return;
|
||
switch (strsplit[0])
|
||
{
|
||
case "µ÷¶ÈÈÎÎñ":
|
||
mti = 1;
|
||
break;
|
||
case "×Ô¶¯ÈÎÎñ":
|
||
mti = 2;
|
||
break;
|
||
case "ÁÙʱÈÎÎñ":
|
||
mti = 3;
|
||
break;
|
||
case "ÊÖ¹¤ÈÎÎñ":
|
||
mti = 4;
|
||
break;
|
||
}
|
||
string cap = strsplit[0];
|
||
string hw = "";
|
||
if (this.dgvManager.CurrentRow.Cells["ÖÕµã»õλ"].Value.ToString() != "-")
|
||
{
|
||
hw = ",ÖÕµã»õλ:" + this.dgvManager.CurrentRow.Cells["ÖÕµã»õλ"].Value.ToString();
|
||
}
|
||
//20100108
|
||
if (MessageBox.Show("ÄúÈ·ÈϱíÏäÌõÂ룺¡°" + this.dgvManager.CurrentRow.Cells["±íÏäÌõÂë"].Value.ToString()+"¡±£¬" + cap + split[2] + "ÒѾ±»°áÔ˵½ÖÕµãÉ豸¡°" + this.dgvManager.CurrentRow.Cells["ÖÕµã"].Value.ToString() + hw + "¡±ÁËÂð£¿", "²Ù×÷Ìáʾ£º", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
||
{
|
||
return;
|
||
}
|
||
CGetState cgs = new CGetState();
|
||
dbo.ExceSQL("update T_Monitor_Task set F_STATUS=-1 where F_ManageTaskKindIndex=" + mti + " and F_ManageTaskIndex=" + fid + " and F_STATUS=0");
|
||
DataView dv = dbo.ExceSQL("SELECT F_ManageTaskKindIndex, F_ManageTaskIndex,F_DeviceIndex,F_MonitorIndex,F_Status,F_DeviceCommandIndex " +
|
||
",F_NumParam2,F_NumParam5,F_TxtParam FROM T_Monitor_Task Where F_ManageTaskIndex=" + fid + " and F_ManageTaskKindIndex= " +
|
||
mti).Tables[0].DefaultView;
|
||
if (dv.Count > 0)
|
||
{
|
||
string sss = "µ÷¶ÈÈÎÎñË÷Òý:" + fid.ToString();
|
||
//20100108
|
||
CommonClassLib.CCarryConvert.WriteDarkCasket("µ÷¶ÈÈÎÎñ¹ÜÀí", "µ÷¶ÈÈÎÎñÊÖ¹¤±¨¸æÍê³É", "±íÏäÌõÂ룺" + this.dgvManager.CurrentRow.Cells["±íÏäÌõÂë"].Value.ToString(), sss);
|
||
for (int i = 0; i < dv.Count; i++)
|
||
{
|
||
if (Convert.ToInt32(dv[i]["F_DeviceIndex"]) == 1001)
|
||
{
|
||
cgs.ActionComplete(Convert.ToInt32(dv[i]["F_DeviceIndex"]), Convert.ToInt32(dv[i]["F_MonitorIndex"]), Model.CGeneralFunction.TASKFINISH);
|
||
//1 ¸¨Áϳö¿â;2 ¿ÕÍÐÅÌ»ØÊÕ;3²ÐÍÐÅÌ»ØÊÕ
|
||
if (Convert.ToInt32(dv[i]["F_DeviceCommandIndex"]) == 1)
|
||
{
|
||
DataTable tableAGVGate = dbo.ExceSQL("SELECT F_AGVGateDeviceIndex FROM T_BASE_AGV_GATE WHERE F_ADDRESS = " + Convert.ToInt32(dv[i]["F_NumParam5"]) + "").Tables[0];
|
||
if (tableAGVGate.Rows.Count > 0)
|
||
{
|
||
|
||
dbo.ExecuteSql("UPDATE T_BASE_DEVICE SET F_PALLETBARCODE='" + dv[i]["F_TxtParam"] + "',F_HAVEGOODS = 1 WHERE F_DEVICEINDEX = " + Convert.ToInt32(tableAGVGate.Rows[0]["F_AGVGateDeviceIndex"]) + "");
|
||
|
||
}
|
||
}
|
||
if ((Convert.ToInt32(dv[i]["F_DeviceCommandIndex"]) == 2) || (Convert.ToInt32(dv[i]["F_DeviceCommandIndex"]) == 3))
|
||
{
|
||
DataTable tableAGVGate = dbo.ExceSQL("SELECT F_AGVGateDeviceIndex FROM T_BASE_AGV_GATE WHERE F_ADDRESS = " + Convert.ToInt32(dv[i]["F_NumParam2"]) + "").Tables[0];
|
||
if (tableAGVGate.Rows.Count > 0)
|
||
{
|
||
if (mti == 1)
|
||
{
|
||
//20090817¸ø¹ÜÀíÖÃÎÞÍÐÅÌÐÅÏ¢
|
||
dboM.ExecuteSql("UPDATE T_ITEMDEVICE SET devicestatus ='0' WHERE devicecode = '" + tableAGVGate.Rows[0]["F_AGVGateDeviceIndex"] + "'");
|
||
}
|
||
dbo.ExecuteSql("UPDATE T_BASE_DEVICE SET F_PALLETBARCODE='-',F_HAVEGOODS = 0 WHERE F_DEVICEINDEX = " + Convert.ToInt32(tableAGVGate.Rows[0]["F_AGVGateDeviceIndex"]) + "");
|
||
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (Convert.ToInt32(dv[i]["F_Status"]) >= 1)
|
||
{
|
||
cgs.ActionComplete(Convert.ToInt32(dv[i]["F_DeviceIndex"]), Convert.ToInt32(dv[i]["F_MonitorIndex"]), 1);
|
||
}
|
||
else
|
||
{
|
||
cgs.ActionComplete(Convert.ToInt32(dv[i]["F_DeviceIndex"]), Convert.ToInt32(dv[i]["F_MonitorIndex"]), Model.CGeneralFunction.TASKFINISH);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
|
||
if (mti == 1)
|
||
{
|
||
int startdevice= Convert.ToInt32(this.dgvManager.CurrentRow.Cells["Æðµã"].Value);
|
||
int enddevice = Convert.ToInt32(this.dgvManager.CurrentRow.Cells["ÖÕµã"].Value);
|
||
|
||
if(enddevice==18007||enddevice==12049||enddevice==12054)
|
||
{
|
||
|
||
//Ìáʾ±íÏäËùÔÚÊäËÍ»ú
|
||
// dboM.ExceSQL("update IO_Control set Control_STATUS=" + Model.CGeneralFunction.TASKPACKFINISH + " where Control_ID=" + fid);
|
||
}
|
||
else
|
||
if(startdevice==32080&&enddevice==32080)
|
||
{
|
||
//dboM.ExceSQL("update IO_Control set Control_STATUS=" + Model.CGeneralFunction.TASKUNPACKFINISH + " where Control_ID=" + fid);
|
||
|
||
}
|
||
else
|
||
{
|
||
|
||
dboM.ExceSQL("update IO_Control set Control_STATUS=" + Model.CGeneralFunction.TASKFINISH + " where Control_ID=" + fid);
|
||
}
|
||
}
|
||
//»ØÐ´¹ÜÀí±í
|
||
cgs.ReturnManageInfo(fid, mti, cap, true);
|
||
}
|
||
this.dgvManager.DataSource = dbo.ExceSQL("select * from V_Manage_Task where " + _manstatus).Tables[0].DefaultView;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//throw ex;
|
||
if (FrmControlMonitor.FormInstance.GetObjectText("tsStatus").IndexOf("µ÷¶ÈÈÎÎñÊÖ¹¤Íê³Éʱ£º" + ex.Message) < 0)
|
||
{
|
||
|
||
FrmControlMonitor.FormInstance.FlashPanit("tsStatus", "µ÷¶ÈÈÎÎñÊÖ¹¤Íê³Éʱ£º" + ex.Message, true);
|
||
}
|
||
}
|
||
}
|
||
|
||
private void TSMmanagerDisassemble_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
char[] cc = new char[1] { '£º' };
|
||
string[] split = TSManager.Text.Split(cc);
|
||
if ((split[1] == "") || (split[2] == ""))
|
||
{
|
||
return;
|
||
}
|
||
char[] scc = new char[1] { '£»' };
|
||
string[] strsplit = split[1].Split(scc);
|
||
int mti = 0;
|
||
int fid = Convert.ToInt32(split[2]);
|
||
if (strsplit[0] == "") return;
|
||
switch (strsplit[0])
|
||
{
|
||
case "µ÷¶ÈÈÎÎñ":
|
||
mti = 1;
|
||
break;
|
||
case "×Ô¶¯ÈÎÎñ":
|
||
mti = 2;
|
||
break;
|
||
case "ÁÙʱÈÎÎñ":
|
||
mti = 3;
|
||
break;
|
||
case "ÊÖ¹¤ÈÎÎñ":
|
||
mti = 4;
|
||
break;
|
||
}
|
||
if (mti == 1)
|
||
{
|
||
dbo.ExceSQL("update T_Manage_Task set FIntoStepOK='0' where FID=" + fid + " and FIntoStepOK='-' ");
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//throw ex;
|
||
if (FrmControlMonitor.FormInstance.GetObjectText("tsStatus").IndexOf("ÊÖ¹¤²ð·Öµ÷¶ÈÈÎÎñʱ£º" + ex.Message) < 0)
|
||
{
|
||
|
||
FrmControlMonitor.FormInstance.FlashPanit("tsStatus", "ÊÖ¹¤²ð·Öµ÷¶ÈÈÎÎñʱ£º" + ex.Message, true);
|
||
}
|
||
}
|
||
}
|
||
|
||
private void FrmModifyManage_Load(object sender, EventArgs e)
|
||
{
|
||
rbmanRun_CheckedChanged(sender, e);
|
||
}
|
||
|
||
private void toolStripMenuItem1_Click(object sender, EventArgs e)
|
||
{
|
||
//ɾ³ýµ÷¶ÈÈÎÎñ900
|
||
try
|
||
{
|
||
char[] cc = new char[1] { '£º' };
|
||
string[] split = TSManager.Text.Split(cc);
|
||
if ((split[1] == "") || (split[2] == ""))
|
||
{
|
||
return;
|
||
}
|
||
char[] scc = new char[1] { '£»' };
|
||
string[] strsplit = split[1].Split(scc);
|
||
int mti = 0;
|
||
int fid = Convert.ToInt32(split[2]);
|
||
if (strsplit[0] == "") return;
|
||
switch (strsplit[0])
|
||
{
|
||
case "µ÷¶ÈÈÎÎñ":
|
||
mti = 1;
|
||
break;
|
||
case "×Ô¶¯ÈÎÎñ":
|
||
mti = 2;
|
||
break;
|
||
case "ÁÙʱÈÎÎñ":
|
||
mti = 3;
|
||
break;
|
||
case "ÊÖ¹¤ÈÎÎñ":
|
||
mti = 4;
|
||
break;
|
||
}
|
||
string hw = "";
|
||
if (this.dgvManager.CurrentRow.Cells["Æðµã»õλ"].Value.ToString() != "-")
|
||
{
|
||
hw = ",Æðµã»õλ:" + this.dgvManager.CurrentRow.Cells["Æðµã»õλ"].Value.ToString();
|
||
}
|
||
string cap = strsplit[0];
|
||
if (MessageBox.Show("ÄúÈ·ÈϱíÏäÌõÂ룺¡°" + this.dgvManager.CurrentRow.Cells["±íÏäÌõÂë"].Value.ToString() + "¡±£¬" + cap + split[2] + "ÒѾ±»È¡Ïû²Ù×÷£¬¶øÇÒÈ˹¤°áÔËÍÐÅÌÍ˻ص½ÆðµãÉ豸¡°" + this.dgvManager.CurrentRow.Cells["Æðµã"].Value.ToString() + hw + "¡±ÁËÂð£¿", "²Ù×÷Ìáʾ£º", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
||
{
|
||
return;
|
||
}
|
||
CGetState cgs = new CGetState();
|
||
//20090902
|
||
dbo.ExceSQL("update T_Manage_Task set FExceptionNO=" + Model.CGeneralFunction.TASKDELETE + " where (F_ManageTaskKindIndex = " + mti + ") AND (FID = " + fid + ")");
|
||
|
||
dbo.ExceSQL("update T_Monitor_Task set F_STATUS=-1 where F_ManageTaskKindIndex=" + mti + " and F_ManageTaskIndex=" + fid + " and F_STATUS=0");
|
||
DataView dv = dbo.ExceSQL("SELECT F_ManageTaskKindIndex, F_ManageTaskIndex,F_DeviceIndex,F_MonitorIndex,F_Status,F_DeviceCommandIndex " +
|
||
",F_NumParam2,F_NumParam5,F_TxtParam FROM T_Monitor_Task Where F_ManageTaskIndex=" + fid + " and F_ManageTaskKindIndex= " +
|
||
mti).Tables[0].DefaultView;
|
||
if (dv.Count > 0)
|
||
{
|
||
string sss = "µ÷¶ÈÈÎÎñË÷Òý:" + fid.ToString();
|
||
//20100108
|
||
CommonClassLib.CCarryConvert.WriteDarkCasket("µ÷¶ÈÈÎÎñ¹ÜÀí", "µ÷¶ÈÈÎÎñ±»ÊÖ¹¤É¾³ý£¡", "±íÏäÌõÂ룺" + this.dgvManager.CurrentRow.Cells["±íÏäÌõÂë"].Value.ToString(), sss);
|
||
for (int i = 0; i < dv.Count; i++)
|
||
{
|
||
if (Convert.ToInt32(dv[i]["F_DeviceIndex"]) == 1001)
|
||
{
|
||
cgs.ActionComplete(Convert.ToInt32(dv[i]["F_DeviceIndex"]), Convert.ToInt32(dv[i]["F_MonitorIndex"]), Model.CGeneralFunction.TASKDELETE);
|
||
//1 ¸¨Áϳö¿â;2 ¿ÕÍÐÅÌ»ØÊÕ;3²ÐÍÐÅÌ»ØÊÕ
|
||
|
||
if ((Convert.ToInt32(dv[i]["F_DeviceCommandIndex"]) == 2) || (Convert.ToInt32(dv[i]["F_DeviceCommandIndex"]) == 3))
|
||
{
|
||
DataTable tableAGVGate = dbo.ExceSQL("SELECT F_AGVGateDeviceIndex FROM T_BASE_AGV_GATE WHERE F_ADDRESS = " + Convert.ToInt32(dv[i]["F_NumParam2"]) + "").Tables[0];
|
||
if (tableAGVGate.Rows.Count > 0)
|
||
{
|
||
|
||
dbo.ExecuteSql("UPDATE T_BASE_DEVICE SET F_PALLETBARCODE='" + dv[i]["F_TxtParam"] + "',F_HAVEGOODS = 1 WHERE F_DEVICEINDEX = " + Convert.ToInt32(tableAGVGate.Rows[0]["F_AGVGateDeviceIndex"]) + "");
|
||
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (Convert.ToInt32(dv[i]["F_Status"]) >= 1)
|
||
{
|
||
cgs.ActionComplete(Convert.ToInt32(dv[i]["F_DeviceIndex"]), Convert.ToInt32(dv[i]["F_MonitorIndex"]), 1);
|
||
}
|
||
else
|
||
{
|
||
cgs.ActionComplete(Convert.ToInt32(dv[i]["F_DeviceIndex"]), Convert.ToInt32(dv[i]["F_MonitorIndex"]), Model.CGeneralFunction.TASKDELETE);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{//20091107
|
||
if (this.dgvManager.CurrentRow.Cells["ÖÕµã"].Value.ToString() == "2240")
|
||
{
|
||
dbo.ExceSQL("update T_Base_Device set F_CreateLock='0' where F_DeviceIndex=" + this.dgvManager.CurrentRow.Cells["ÖÕµã"].Value);
|
||
}
|
||
if (mti == 1)
|
||
{
|
||
dboM.ExceSQL("update IO_Control set Control_STATUS=" + Model.CGeneralFunction.TASKDELETE + " where Control_ID=" + fid);
|
||
}
|
||
//»ØÐ´¹ÜÀí±í
|
||
cgs.ReturnManageInfo(fid, mti, cap, false);
|
||
}
|
||
this.dgvManager.DataSource = dbo.ExceSQL("select * from V_Manage_Task where " + _manstatus).Tables[0].DefaultView;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//throw ex;
|
||
if (FrmControlMonitor.FormInstance.GetObjectText("tsStatus").IndexOf("µ÷¶ÈÈÎÎñÊÖ¹¤Íê³Éʱ£º" + ex.Message) < 0)
|
||
{
|
||
|
||
FrmControlMonitor.FormInstance.FlashPanit("tsStatus", "µ÷¶ÈÈÎÎñÊÖ¹¤Íê³Éʱ£º" + ex.Message, true);
|
||
}
|
||
}
|
||
}
|
||
|
||
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;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
private void dgvManager_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
|
||
{
|
||
if ((e.RowIndex >= 0) && (e.Button == MouseButtons.Right) && (e.ColumnIndex>=0))
|
||
{
|
||
dgvManager.ClearSelection();
|
||
dgvManager.Rows[e.RowIndex].Selected = true;
|
||
dgvManager.CurrentCell = dgvManager.Rows[e.RowIndex].Cells[e.ColumnIndex];
|
||
|
||
}
|
||
}
|
||
|
||
private void TSMIMANAGEEXCEPTION_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
|
||
char[] cc = new char[1] { '£º' };
|
||
string[] split = TSManager.Text.Split(cc);
|
||
if ((split[1] == "") || (split[2] == ""))
|
||
{
|
||
return;
|
||
}
|
||
char[] scc = new char[1] { '£»' };
|
||
string[] strsplit = split[1].Split(scc);
|
||
int mti = 0;
|
||
int fid = Convert.ToInt32(split[2]);
|
||
if (strsplit[0] == "") return;
|
||
switch (strsplit[0])
|
||
{
|
||
case "µ÷¶ÈÈÎÎñ":
|
||
mti = 1;
|
||
break;
|
||
case "×Ô¶¯ÈÎÎñ":
|
||
mti = 2;
|
||
break;
|
||
case "ÁÙʱÈÎÎñ":
|
||
mti = 3;
|
||
break;
|
||
case "ÊÖ¹¤ÈÎÎñ":
|
||
mti = 4;
|
||
break;
|
||
}
|
||
string cap = strsplit[0];
|
||
string hw = "";
|
||
if (this.dgvManager.CurrentRow.Cells["ÖÕµã»õλ"].Value.ToString() != "-")
|
||
{
|
||
hw = ",ÖÕµã»õλ:" + this.dgvManager.CurrentRow.Cells["ÖÕµã»õλ"].Value.ToString();
|
||
}
|
||
//20100108
|
||
if (MessageBox.Show("ÄúÈ·ÈϽ«±íÏäÌõÂ룺¡°" + this.dgvManager.CurrentRow.Cells["±íÏäÌõÂë"].Value.ToString() + "µÄÈÎÎñÒì³£Íê³ÉÂð£¿", "²Ù×÷Ìáʾ£º", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
||
{
|
||
return;
|
||
}
|
||
CGetState cgs = new CGetState();
|
||
dbo.ExceSQL("update T_Manage_Task set FExceptionNO=" + Model.CGeneralFunction.TASKABEND + ",FERRORCODE= 'ÊÖ¹¤±¨Òì³£Íê³É' where (F_ManageTaskKindIndex = " + mti + ") AND (FID = " + fid + ")");
|
||
dbo.ExceSQL("update T_Monitor_Task set F_STATUS=-1 where F_ManageTaskKindIndex=" + mti + " and F_ManageTaskIndex=" + fid + " and F_STATUS=0");
|
||
DataView dv = dbo.ExceSQL("SELECT F_ManageTaskKindIndex, F_ManageTaskIndex,F_DeviceIndex,F_MonitorIndex,F_Status,F_DeviceCommandIndex " +
|
||
",F_NumParam2,F_NumParam5,F_TxtParam FROM T_Monitor_Task Where F_ManageTaskIndex=" + fid + " and F_ManageTaskKindIndex= " +
|
||
mti).Tables[0].DefaultView;
|
||
if (dv.Count > 0)
|
||
{
|
||
string sss = "µ÷¶ÈÈÎÎñË÷Òý:" + fid.ToString();
|
||
//20100108
|
||
CommonClassLib.CCarryConvert.WriteDarkCasket("µ÷¶ÈÈÎÎñ¹ÜÀí", "µ÷¶ÈÈÎÎñÊÖ¹¤±¨¸æÒì³£Íê³É", "±íÏäÌõÂ룺" + this.dgvManager.CurrentRow.Cells["±íÏäÌõÂë"].Value.ToString(), sss);
|
||
for (int i = 0; i < dv.Count; i++)
|
||
{
|
||
if (Convert.ToInt32(dv[i]["F_DeviceIndex"]) == 1001)
|
||
{
|
||
cgs.ActionComplete(Convert.ToInt32(dv[i]["F_DeviceIndex"]), Convert.ToInt32(dv[i]["F_MonitorIndex"]), Model.CGeneralFunction.TASKFINISH);
|
||
//1 ¸¨Áϳö¿â;2 ¿ÕÍÐÅÌ»ØÊÕ;3²ÐÍÐÅÌ»ØÊÕ
|
||
if (Convert.ToInt32(dv[i]["F_DeviceCommandIndex"]) == 1)
|
||
{
|
||
DataTable tableAGVGate = dbo.ExceSQL("SELECT F_AGVGateDeviceIndex FROM T_BASE_AGV_GATE WHERE F_ADDRESS = " + Convert.ToInt32(dv[i]["F_NumParam5"]) + "").Tables[0];
|
||
if (tableAGVGate.Rows.Count > 0)
|
||
{
|
||
|
||
dbo.ExecuteSql("UPDATE T_BASE_DEVICE SET F_PALLETBARCODE='" + dv[i]["F_TxtParam"] + "',F_HAVEGOODS = 1 WHERE F_DEVICEINDEX = " + Convert.ToInt32(tableAGVGate.Rows[0]["F_AGVGateDeviceIndex"]) + "");
|
||
|
||
}
|
||
}
|
||
if ((Convert.ToInt32(dv[i]["F_DeviceCommandIndex"]) == 2) || (Convert.ToInt32(dv[i]["F_DeviceCommandIndex"]) == 3))
|
||
{
|
||
DataTable tableAGVGate = dbo.ExceSQL("SELECT F_AGVGateDeviceIndex FROM T_BASE_AGV_GATE WHERE F_ADDRESS = " + Convert.ToInt32(dv[i]["F_NumParam2"]) + "").Tables[0];
|
||
if (tableAGVGate.Rows.Count > 0)
|
||
{
|
||
if (mti == 1)
|
||
{
|
||
//20090817¸ø¹ÜÀíÖÃÎÞÍÐÅÌÐÅÏ¢
|
||
dboM.ExecuteSql("UPDATE T_ITEMDEVICE SET devicestatus ='0' WHERE devicecode = '" + tableAGVGate.Rows[0]["F_AGVGateDeviceIndex"] + "'");
|
||
}
|
||
dbo.ExecuteSql("UPDATE T_BASE_DEVICE SET F_PALLETBARCODE='-',F_HAVEGOODS = 0 WHERE F_DEVICEINDEX = " + Convert.ToInt32(tableAGVGate.Rows[0]["F_AGVGateDeviceIndex"]) + "");
|
||
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (Convert.ToInt32(dv[i]["F_Status"]) >= 1)
|
||
{
|
||
cgs.ActionComplete(Convert.ToInt32(dv[i]["F_DeviceIndex"]), Convert.ToInt32(dv[i]["F_MonitorIndex"]), 1);
|
||
}
|
||
else
|
||
{
|
||
cgs.ActionComplete(Convert.ToInt32(dv[i]["F_DeviceIndex"]), Convert.ToInt32(dv[i]["F_MonitorIndex"]), Model.CGeneralFunction.TASKABEND);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
|
||
if (mti == 1)
|
||
{
|
||
int startdevice = Convert.ToInt32(this.dgvManager.CurrentRow.Cells["Æðµã"].Value);
|
||
int enddevice = Convert.ToInt32(this.dgvManager.CurrentRow.Cells["ÖÕµã"].Value);
|
||
|
||
if (enddevice == 18007 || enddevice == 12049 || enddevice == 12054)
|
||
{
|
||
|
||
//Ìáʾ±íÏäËùÔÚÊäËÍ»ú
|
||
dboM.ExceSQL("update IO_Control set Control_STATUS=" + Model.CGeneralFunction.TASKPACKFINISH + " where Control_ID=" + fid);
|
||
}
|
||
else
|
||
if (startdevice == 32080 && enddevice == 32080)
|
||
{
|
||
dboM.ExceSQL("update IO_Control set Control_STATUS=" + Model.CGeneralFunction.TASKUNPACKFINISH + " where Control_ID=" + fid);
|
||
|
||
}
|
||
else
|
||
{
|
||
|
||
dboM.ExceSQL("update IO_Control set Control_STATUS=" + Model.CGeneralFunction.TASKABEND + " where Control_ID=" + fid);
|
||
}
|
||
}
|
||
//»ØÐ´¹ÜÀí±í
|
||
cgs.ReturnManageInfo(fid, mti, cap, true);
|
||
}
|
||
this.dgvManager.DataSource = dbo.ExceSQL("select * from V_Manage_Task where " + _manstatus).Tables[0].DefaultView;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//throw ex;
|
||
if (FrmControlMonitor.FormInstance.GetObjectText("tsStatus").IndexOf("µ÷¶ÈÈÎÎñÊÖ¹¤±¨Òì³£Íê³Éʱ£º" + ex.Message) < 0)
|
||
{
|
||
|
||
FrmControlMonitor.FormInstance.FlashPanit("tsStatus", "µ÷¶ÈÈÎÎñÊÖ¹¤±¨Òì³£Íê³Éʱ£º" + ex.Message, true);
|
||
}
|
||
}
|
||
}
|
||
|
||
private void dgvManager_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
|
||
}
|
||
} |