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.
395 lines
16 KiB
395 lines
16 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 System.ServiceModel;
|
||
|
using System.Net;
|
||
|
namespace wcfControlMonitorClient
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// Creator:Richard.liu
|
||
|
/// �豸ָ�����й���
|
||
|
/// </summary>
|
||
|
public partial class FrmSeeMonitor : Form
|
||
|
{
|
||
|
string _monstatus = " F_Status>=-1 ";
|
||
|
private static FrmSeeMonitor _formInstance;
|
||
|
|
||
|
public static FrmSeeMonitor FormInstance
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
if (_formInstance == null)
|
||
|
{
|
||
|
_formInstance = new FrmSeeMonitor();
|
||
|
}
|
||
|
return _formInstance;
|
||
|
}
|
||
|
set { _formInstance = value; }
|
||
|
}
|
||
|
|
||
|
DBOperator dbo = CStaticClass.dbo;
|
||
|
DBOperator dboM = CStaticClass.dboM;
|
||
|
|
||
|
|
||
|
public FrmSeeMonitor()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
_formInstance = this;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
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 with(nolock) 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 with(nolock) 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_CheckedChanged(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(1001,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(1001,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(1001,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) >= 30)
|
||
|
{
|
||
|
DGVRow.DefaultCellStyle.BackColor = Color.Red;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
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 with(nolock) " + 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)
|
||
|
{
|
||
|
string errtext = string.Empty;
|
||
|
if ((e.RowIndex >= 0))//&&(e.Button == MouseButtons.Right)
|
||
|
{
|
||
|
dgvMonitor.ClearSelection();
|
||
|
dgvMonitor.Rows[e.RowIndex].Selected = true;
|
||
|
dgvMonitor.CurrentCell = dgvMonitor.Rows[e.RowIndex].Cells[0];
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
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();
|
||
|
}));
|
||
|
}
|
||
|
void ModifyMonitorTask1CallBack(IAsyncResult ar)
|
||
|
{
|
||
|
if (this.IsDisposed == true) return;
|
||
|
string errtext = string.Empty;
|
||
|
this.BeginInvoke(new MethodInvoker(delegate()
|
||
|
{
|
||
|
|
||
|
if (CStaticClass.WcfControl.EndModifyMonitorTask1(out errtext, ar) == false)
|
||
|
{
|
||
|
MessageBox.Show(errtext, "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
|
}
|
||
|
|
||
|
TSMMonitorRefresh_Click();
|
||
|
}));
|
||
|
}
|
||
|
private void FrmModifyMonitor_FormClosing(object sender, FormClosingEventArgs e)
|
||
|
{
|
||
|
_formInstance = null;
|
||
|
}
|
||
|
|
||
|
private void radioButton1_CheckedChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
RadioButton rb = (RadioButton)sender;
|
||
|
if (rb.Checked == true)
|
||
|
{
|
||
|
_monstatus = " ���� like'%PAT%' ";
|
||
|
}
|
||
|
TSMMonitorRefresh_Click();
|
||
|
}
|
||
|
|
||
|
private void radioButton2_CheckedChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
RadioButton rb = (RadioButton)sender;
|
||
|
if (rb.Checked == true)
|
||
|
{
|
||
|
_monstatus = " ���� like'%BOX%' ";
|
||
|
}
|
||
|
TSMMonitorRefresh_Click();
|
||
|
}
|
||
|
|
||
|
private void radioButton4_CheckedChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
RadioButton rb = (RadioButton)sender;
|
||
|
if (rb.Checked == true)
|
||
|
{
|
||
|
_monstatus = " ���� like'%PAT%' and F_Status>=1";
|
||
|
}
|
||
|
TSMMonitorRefresh_Click();
|
||
|
}
|
||
|
|
||
|
private void radioButton3_CheckedChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
RadioButton rb = (RadioButton)sender;
|
||
|
if (rb.Checked == true)
|
||
|
{
|
||
|
_monstatus = " ���� like'%BOX%' and F_Status>=1";
|
||
|
}
|
||
|
TSMMonitorRefresh_Click();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|