吉林安睿特调度
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.

842 lines
35 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.ServiceModel;
using OPCClient;
using Opc.Ua;
using System.Net;
using System.Linq;
namespace wcfControlMonitorClient
{
/// <summary>
/// Creator:Richard.liu and Jack.Ma
/// �豸ʵʱ״̬��ʾ
/// </summary>
public partial class FrmDeviceStatus : Form
{
#region ��������
Model.MDevice _device = null;
int _deviceIndex;
DBFactory.DBOperator dboMan = CStaticClass.dboM;
DBFactory.DBOperator dbo = CStaticClass.dbo;
int count = 0;
/// <summary>
/// ����Ҫ��ʾ���豸����
/// </summary>
public int DeviceIndex
{
set { _deviceIndex = value; }
}
private static FrmDeviceStatus _formInstance;
public static FrmDeviceStatus FormInstance
{
get
{
if (_formInstance == null)
{
_formInstance = new FrmDeviceStatus();
}
return _formInstance;
}
set { _formInstance = value; }
}
#endregion
#region ���캯��/��ʼ��
public FrmDeviceStatus()
{
InitializeComponent();
_formInstance = this;
}
private void FrmDeviceStatus_Load(object sender, EventArgs e)
{
StringBuilder sql = new StringBuilder();
sql = new StringBuilder();
sql.Append("SELECT F_DeviceIndex from T_Base_PLC_Ask where F_DeviceIndex=").Append(_deviceIndex);
DataView dvlane = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
if (dvlane.Count > 0)
{
this.tbAddBarcode.Visible = true;
this.btresendbarcode.Visible = true;
}
else
{
this.tbAddBarcode.Visible = false;
this.btresendbarcode.Visible = false;
}
this.btLogicHaveGoods.Visible = true;
this.btLogicNoneGoods.Visible = true;
textBox1.Visible = true;
textBox2.Visible = false;
button1.Visible = false;
label10.Visible = false;
this.tbAddBarcode.Text = "";
if (_deviceIndex == 12014 || _deviceIndex == 12011 || _deviceIndex == 12008 || _deviceIndex == 12007)
{
button6.Visible = true;
}
else { button6.Visible = false; }
if (new int[] { 22005, 22006, 29008 }.Contains(_deviceIndex))
{
this.lab_AutomaticPlatform.Visible = true;
this.txt_AutomaticPlatform.Visible = true;
this.btn_AutomaticPlatform.Visible = true;
}
else
{
this.lab_AutomaticPlatform.Visible = false;
this.txt_AutomaticPlatform.Visible = false;
this.btn_AutomaticPlatform.Visible = false;
}
btnRefresh_Click(null, EventArgs.Empty);
}
#endregion
#region �����豸״̬
private void btnRefresh_Click(object sender, EventArgs e)
{
try
{
_device = Model.CGetInfo.GetDeviceInfo(_deviceIndex);
//20100108
if (_device == null)
{
MessageBox.Show("��ѡ�����豸�����ݿ�û�м�¼��", "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
//�豸����
this.lblDeviceIndex.Value = _device.DeviceIndex;
//�豸����
this.lblDeviceName.Text = _device.DeviceName;
//�豸ָ������
this.lblTaskIndex.Text = _device.TaskNo.ToString();
DataView dv = dbo.ExceSQL(string.Format("SELECT F_TxtParam, F_NumParam1, F_NumParam2, F_NumParam3, F_NumParam4,F_NumParam5, F_NumParam6 FROM T_Monitor_Task WHERE (F_MonitorIndex = {0})", _device.TaskNo)).Tables[0].DefaultView;
if (dv.Count > 0)
{
//������
this.lblBarcode.Text = dv[0]["F_TxtParam"].ToString();
//Ŀ��λ��
this.lblArrowLocation.Text = _device.ArrowLocation;
if (_device.DeviceKind == 1)
{
this.lblArrowLocation.Text = string.Format("{0}��{1}��{2}��", dv[0]["F_NumParam4"].ToString(), dv[0]["F_NumParam5"].ToString(), dv[0]["F_NumParam6"].ToString());
}
if (_device.DeviceKind == 4)
{
this.lblArrowLocation.Text = dv[0]["F_NumParam1"].ToString();
}
if ((_device.DeviceKind == 2) || (_device.DeviceKind == 31))
{
this.lblArrowLocation.Text = dv[0]["F_NumParam4"].ToString();
}
}
else
{
//20140109
if (_device.DeviceKind == 2)
{
if (_device.RunState == 5 && _device.SplitByte_0 == 1)
{
//������
object bcode = dbo.GetSingle(string.Format("SELECT F_PALLETBARCODE FROM T_Base_Device WHERE (F_DeviceIndex = {0})", _device.DeviceIndex));
if (bcode != null)
{
this.lblBarcode.Text = bcode.ToString();
}
else
{
this.lblBarcode.Text = "";
}
}
else
{
//������
this.lblBarcode.Text = "";
}
if ((_device.DeviceIndex == 12008 || _device.DeviceIndex == 12007 || _device.DeviceIndex == 12014 || _device.DeviceIndex == 12011))
{
//this.groupBox1.Visible = true;
//������
//object bcode = dbo.GetSingle(string.Format("SELECT SN FROM ZH_pallet WHERE (Device = {0})", _device.DeviceIndex));
//if (bcode != null)
//{
// this.groupBox1.Text = bcode.ToString();
//}
//else
//{
// this.groupBox1.Text = "";
//}
}
}
else
{
//������
this.lblBarcode.Text = "";
if (_device.DeviceKind == 43)
{
//������
object bcode = dbo.GetSingle(string.Format("SELECT F_PALLETBARCODE FROM T_Base_Device WHERE (F_DeviceIndex = {0})", 22005));
if (bcode != null)
{
this.lblBarcode.Text = bcode.ToString();
}
else
{
this.lblBarcode.Text = "";
}
}
}
//Ŀ��λ��
this.lblArrowLocation.Text = "";
}
if (_device.DeviceKind == 31)
{
this.lblTaskIndex.Text = GetMonitorTaskIndexFromBarCode(new StringBuilder(_device.Barcode)).ToString();
this.lblBarcode.Text = _device.Barcode;
this.lblBarcode.Enabled = true;
}
else
{
this.lblBarcode.Enabled = false;
}
if (_device.DeviceKind == 1)
{
button2.Visible = true;
}
else
{
button2.Visible = false;
}
DataView dvb = dbo.ExceSQL(string.Format("select * from T_Base_PLC_Ask where F_BindingDevice = {0}", _device.DeviceIndex)).Tables[0].DefaultView;
if (dvb.Count > 0 && _device.DeviceKind == 2)
{
//this.lblBarcode.Text = dvb[0]["F_BarCode"].ToString();
//------------------------------------------------------��ȡ��ǰ��������-----------------------------------------------------------------//
if (Convert.ToInt32(dvb[0]["F_PalletBarcodeReservedLength"]) == 70)
{
textBox2.Text = "";
textBox2.Visible = true;
label10.Visible = true;
button1.Visible = true;
StringBuilder barcode = new StringBuilder();
int dbbegin = Convert.ToInt32(dbo.GetSingle("select F_DBW2Address from t_base_device where f_deviceindex=" + dvb[0]["F_DeviceIndex"]));
string s7connection = dbo.GetSingle("select F_S7Connection from t_base_device where f_deviceindex=" + dvb[0]["F_DeviceIndex"]).ToString();
CCommonOPCClient.Hostname = CommonClassLib.AppSettings.GetValue("HostName");//20090922 devinfo.RemoteIP;
CCommonOPCClient.ProgID = CommonClassLib.AppSettings.GetValue("OPCProgID");
CCommonOPCClient.PlcConnectionID = s7connection;//20110216
Opc.Ua.DataValueCollection dc = new DataValueCollection();
StringBuilder[] itemnames = new StringBuilder[72];
for (int i = 0; i < 72; i++)
{
itemnames[i] = new StringBuilder("");
itemnames[i].Append(Model.CGeneralFunction.DBGet).Append(".").Append(Convert.ToString(dbbegin + i)).Append(",b");
}
dc = CCommonOPCClient.SyncReadAllItemValue(itemnames);
int PalletBarcodeLength = Convert.ToInt32(dvb[0]["F_PalletBarcodeLength"]);
int BarcodeReservedLength = Convert.ToInt32(dvb[0]["F_BarcodeReservedLength"]);
count = Convert.ToInt32(Convert.ToByte(dc[1].ToString()));
for (int i = 0; i < 6; i++)
{
StringBuilder tempparam = new StringBuilder();
for (int ii = 0; ii < PalletBarcodeLength; ii++)
{//��ת������ʱPalletBarcodeLength=0��PalletBarcodeReservedLength=0
tempparam.Append(Convert.ToChar(Convert.ToByte(dc[10 + i * BarcodeReservedLength + ii].ToString())).ToString().ToUpper());//20131106richard
}
//if (tempparam.ToString() == incompleteBarcode.ToString())//ɨ�����룬�����л���
//{//�Զ��������롰9+dvsp[0]["F_BindingDevice"]+˳���š�
// //tempparam.Clear();
// //tempparam.Append(GetErrorBarcode(dcode, devidx, BarcodeLength));
//}
if (tempparam.ToString().Trim().Length == PalletBarcodeLength)
{
barcode.Append(tempparam);
}
if (i < 5)
{
barcode.Append('|');
}
textBox2.Text = barcode.ToString().Trim('\0').Trim('|');
//if ((i == 0) && (barcode.Length == 0))
//{//���̶�����������¼��������������Ϊ��¼
// barcode = tempparam;
//}
}
}
//------------------------------------------------------��ȡ��ǰ��������-----------------------------------------------------------------//
}
else
{
lblBarcode.Enabled = false;
}
if (new int[] { 22005, 22006, 29008 }.Contains(_device.DeviceIndex))
{
DataView dvTemp = dbo.ExceSQL($"SELECT * FROM T_Base_Device WHERE F_DeviceIndex = {_device.DeviceIndex}").Tables[0].DefaultView;
if (dvTemp.Count > 0)
{
this.txt_AutomaticPlatform.Text = dvTemp[0]["F_PALLETBARCODE"].ToString();
}
}
//�豸״̬
switch (_device.RunState)
{
case 0:
lblDeviceStatus.Text = "����";
break;
case 1:
lblDeviceStatus.Text = "����";
break;
case 2:
lblDeviceStatus.Text = "����";
break;
case 3:
lblDeviceStatus.Text = "����";
break;
case 4:
lblDeviceStatus.Text = "ͣ��";
break;
case 5://20090920
lblDeviceStatus.Text = "��������";
break;
}
if (_device.ErrorCode >= 30)
{
Model.MError err = Model.CGetInfo.GetErrorInfo(Convert.ToInt32(_device.DeviceKind.ToString() + _device.ErrorCode.ToString()));
if (err != null)
{
this.lblErrorName.Text = err.ErrorName + "�����룺" + _device.ErrorCode.ToString();
}
else
{
this.lblErrorName.Text = _device.ErrorCode.ToString();
}
}
else
{
this.lblErrorName.Text = "";
}
if (_device.DeviceKind == 7 || _device.DeviceKind == 42)
{
dv = dbo.ExceSQL(string.Format("SELECT F_BarCode ,F_ErrorBarcodeSN FROM T_Base_PLC_Ask WHERE (F_DeviceIndex = {0})", _device.DeviceIndex)).Tables[0].DefaultView;
if (dv.Count > 0)
{
this.lblBarcode.Text = dv[0][0].ToString();
Model.MError err = Model.CGetInfo.GetErrorInfo(Convert.ToInt32(_device.DeviceKind.ToString() + dv[0][1].ToString()));
if (err != null)
{
this.lblErrorName.Text = err.ErrorName + "�����룺" + dv[0][1].ToString();
}
else
{
this.lblErrorName.Text = "";
}
}
//lblErrorName.Text = "";
lblDeviceStatus.Text = "";
}
if ((_device.DeviceKind == 1) || (_device.DeviceKind == 4))
{
this.lblNowX.Text = _device.XCoor.ToString();
this.lblNowY.Text = _device.YCoor.ToString();
}
else
{
this.lblNowX.Text = "";
this.lblNowY.Text = "";
}
//�Ƿ��߼�����
dv = dbo.ExceSQL("select F_DeviceIndex from T_Base_Device where F_HaveGoods >0 and F_DeviceIndex =" + this._deviceIndex).Tables[0].DefaultView;
if (dv.Count > 0)
{
lblGoods.Text = "�߼�����";
}
else
{
lblGoods.Text = "�߼�����";
}
//dv = dbo.ExceSQL("select F_DeviceIndex from T_NeedLock where F_DeviceIndex =" + this._deviceIndex).Tables[0].DefaultView;
//if (dv.Count > 0)
//{
// button5.Visible = true;
//}
//else
//{
// button5.Visible = false;
//}
//20120417��ԤԼ�ĵ�������
dv = dbo.ExceSQL(string.Format("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_ManageTaskKindIndex = 4 and F_MonitorIndex={0})", Convert.ToInt32(this.lblTaskIndex.Text))).Tables[0].DefaultView;
if (dv.Count > 0)
{
lblManTask.Text = "�ֹ�����";
}
else
{
dv = dbo.ExceSQL(string.Format("select F_ManTaskReserve from T_Base_Device where F_ManTaskReserve>0 and F_DeviceIndex ={0}", this._deviceIndex)).Tables[0].DefaultView;
if (dv.Count > 0)
{
int mankind = Convert.ToInt32(dv[0][0].ToString().Substring(0, 1));
int fid = Convert.ToInt32(dv[0][0].ToString().Substring(1));
lblManTask.Text = fid.ToString();
dv = dbo.ExceSQL(string.Format("SELECT F_TxtParam FROM T_Monitor_Task WHERE (F_ManageTaskKindIndex = {0} and F_ManageTaskIndex={1})", mankind, fid)).Tables[0].DefaultView;
if (dv.Count > 0)
{
lblBarcode.Text = dv[0][0].ToString(); ;
}
}
else
{
lblManTask.Text = "";
}
}
//dv = dbo.ExceSQL(string.Format("SELECT F_DeviceIndex,F_PalletBarcodeLength,F_BarCode FROM T_Base_PLC_Ask WHERE (F_Askkind = 4 OR F_Askkind = 14) AND (F_BindingDevice = {0})", this._deviceIndex)).Tables[0].DefaultView;
//if (dv.Count > 0)
//{
// gbBarcode.Visible = true;
// CStaticClass.WcfControl.BeginGetReadedAndReportedBarcode(this._deviceIndex, new AsyncCallback(CallbackGetReadedAndReportedBarcode), null);
//}
//else
//{
// gbBarcode.Visible = false;
//}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
void CallbackGetReadedAndReportedBarcode(IAsyncResult ar)
{
string errortext, ReadedBarcode, ReportedBarcode;
try
{
bool rt = CStaticClass.WcfControl.EndGetReadedAndReportedBarcode(out ReadedBarcode, out ReportedBarcode, out errortext, ar);
if (rt == true)
{
this.BeginInvoke(new MethodInvoker(delegate ()
{
//lblReadedBarcode.Text = ReadedBarcode;
//lblReportedBarcode.Text = ReportedBarcode;
}));
}
else
{
this.BeginInvoke(new MethodInvoker(delegate ()
{
//lblReadedBarcode.Text ="";
//lblReportedBarcode.Text = "";
}));
if (errortext != "")
{
MessageBox.Show(errortext, "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
catch
{
}
}
#endregion
#region �رմ���
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
#endregion
private void button2_Click(object sender, EventArgs e)
{
if (MessageBox.Show("��ȷ��Ҫ���豸��" + this._deviceIndex + "�����߼���������", "������ʾ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
{
return;
}
CStaticClass.WcfControl.BeginSetLogicHaveGoods(false, this._deviceIndex, new AsyncCallback(SetLogicHaveGoodsCallBack), null);
btnRefresh_Click(sender, e);
}
private void button1_Click(object sender, EventArgs e)
{
if (MessageBox.Show("��ȷ��Ҫ���豸��" + this._deviceIndex + "�����߼���������", "������ʾ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
{
return;
}
CStaticClass.WcfControl.BeginSetLogicHaveGoods(true, this._deviceIndex, new AsyncCallback(SetLogicHaveGoodsCallBack), null);
btnRefresh_Click(sender, e);
}
private void button3_Click(object sender, EventArgs e)
{
if (MessageBox.Show("��ȷ��Ҫ���豸��" + this._deviceIndex + "���͡�����Ӧ��������", "������ʾ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
{
return;
}
string errtext = string.Empty;
CStaticClass.WcfControl.BeginSendDeviceReset(this._deviceIndex, 2, new AsyncCallback(SendDeviceResetCallBack), 2);
}
void SetLogicHaveGoodsCallBack(IAsyncResult ar)
{
string errtext = string.Empty;
if (CStaticClass.WcfControl.EndSetLogicHaveGoods(out errtext, ar) == false)
{
MessageBox.Show(errtext, "������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
void SendDeviceResetCallBack(IAsyncResult ar)
{
string errtext = string.Empty;
if (CStaticClass.WcfControl.EndSendDeviceReset(out errtext, ar) == false)
{
MessageBox.Show(errtext, "������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
if (ar.AsyncState != null)
{
//if ((((int)ar.AsyncState) == 4)&&(_device.DeviceKind==4))
//{
// CStaticClass.WcfControl.BeginSendDeviceReset(_deviceIndex, 2, new AsyncCallback(SendDeviceResetCallBack), null);
//}
if (((int)ar.AsyncState) == 2)
{
CStaticClass.WcfControl.BeginSendDeviceReset(_deviceIndex, 0, new AsyncCallback(SendDeviceResetCallBack), null);
}
}
}
}
private void lblDeviceIndex_ValueChanged(object sender, EventArgs e)
{
_deviceIndex = int.Parse(lblDeviceIndex.Value.ToString());
}
private void FrmDeviceStatus_FormClosing(object sender, FormClosingEventArgs e)
{
_formInstance = null;
}
private void button4_Click(object sender, EventArgs e)
{
if (MessageBox.Show("��ȷ��Ҫ���豸��" + this._deviceIndex + "���͡��豸��λ������", "������ʾ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
{
return;
}
string errtext = string.Empty;
CStaticClass.WcfControl.BeginSendDeviceReset(this._deviceIndex, 4, new AsyncCallback(SendDeviceResetCallBack), 4);
}
int GetMonitorTaskIndexFromBarCode(StringBuilder BarCode)
{//20110216
string bc = BarCode.ToString();
DataView dv = dbo.ExceSQL(string.Format("SELECT T_Monitor_Task.F_MonitorIndex FROM T_Base_Device,T_Monitor_Task WHERE T_Base_Device.F_DeviceIndex = T_Monitor_Task.F_DeviceIndex and ((T_Base_Device.F_DeviceKindIndex = 13) OR (T_Base_Device.F_DeviceKindIndex = 31)) and (F_TxtParam = '{0}') and F_Status>0 order by F_MonitorIndex asc", bc)).Tables[0].DefaultView;
if (dv.Count > 0)
{
return Convert.ToInt32(dv[0]["F_MonitorIndex"]);
}
else
{
return -1;
}
}
void WriteDBDataCallback(IAsyncResult ar)
{
string errtext;
if (CStaticClass.WcfControl.EndWriteDBData(out errtext, ar) == false)
{
MessageBox.Show("������ʾ", errtext, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
void WriteBarcodeCallback(IAsyncResult ar)
{
if (CStaticClass.WcfControl.EndWriteBarcode(ar) == false)
{
MessageBox.Show("������ʾ", "����ʧ��", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
MessageBox.Show("������ʾ", "�����ɹ�", MessageBoxButtons.OK, MessageBoxIcon.None);
}
}
void WriteGroupBarcodeCallback(IAsyncResult ar)
{
if (CStaticClass.WcfControl.EndWriteGroupBarcode(ar) == false)
{
MessageBox.Show("������ʾ", "�޸�ʧ��", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
MessageBox.Show("������ʾ", "�޸ijɹ�", MessageBoxButtons.OK, MessageBoxIcon.None);
}
}
void ClearFireAlarmCallback(IAsyncResult ar)
{
if (CStaticClass.WcfControl.EndClearFireAlarm(ar) == false)
{
MessageBox.Show("������ʾ", "������ͣ����ʧ��", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
MessageBox.Show("������ʾ", "������ͣ�����ɹ�", MessageBoxButtons.OK, MessageBoxIcon.None);
}
}
void ClearPalletCallback(IAsyncResult ar)
{
if (CStaticClass.WcfControl.EndClearPallet(ar) == false)
{
MessageBox.Show("������ʾ", "������������ʧ��", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
MessageBox.Show("������ʾ", "�������������ɹ�", MessageBoxButtons.OK, MessageBoxIcon.None);
}
}
private void lblBarcode_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\r')
{
if (MessageBox.Show("��ȷ��Ҫ�޸��豸��" + this._deviceIndex + "����¼�ġ����롿����", "������ʾ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
{
return;
}
CStaticClass.WcfControl.BeginWriteDBData(_deviceIndex, "DB2", lblBarcode.Text, new AsyncCallback(WriteDBDataCallback), null);
}
}
private void btCancelDoubleFork_Click(object sender, EventArgs e)
{
if (MessageBox.Show("��ȷ��Ҫȡ����" + this._deviceIndex + "����˫����������", "������ʾ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
{
return;
}
StringBuilder sql = new StringBuilder();
sql.Append("update T_Base_PLC_Ask set F_TaskIndex=0,F_Remark='' where F_DeviceIndex=").Append(_deviceIndex);
dbo.ExecuteSql(sql.ToString());
}
private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
{
}
private void btresendbarcode_Click(object sender, EventArgs e)
{
int barcodelenth = Convert.ToInt32(dbo.GetSingle("select F_PalletBarcodeLength from T_Base_PLC_Ask where F_DeviceIndex=" + _deviceIndex));
//if (this.tbAddBarcode.Text.Length != barcodelenth)
//{
// MessageBox.Show("������ʾ", "����λ������ȷ", MessageBoxButtons.OK, MessageBoxIcon.Error);
// return;
//}
//OPCClient.CSendDeviceOrder sdo = new OPCClient.CSendDeviceOrder();
//sdo.WriteBarcode(_deviceIndex, tbAddBarcode.Text);
string d = Dns.GetHostEntry("localhost").HostName;
if (CStaticClass.UserID != "")
{
d = Dns.GetHostEntry("localhost").HostName + dbo.GetSingle("select f_username from T_Base_Users where f_userid='" + CStaticClass.UserID + "'").ToString();
}
CStaticClass.WcfControl.BeginWriteBarcode(d, _deviceIndex, string.Format("{0}", tbAddBarcode.Text), new AsyncCallback(WriteBarcodeCallback), null);
MessageBox.Show("�����ɹ���");
}
private void button1_Click_1(object sender, EventArgs e)
{
int barcodelenth = Convert.ToInt32(dbo.GetSingle("select F_PalletBarcodeLength from T_Base_PLC_Ask where F_BindingDevice=" + _deviceIndex));
string GroupBarcode = textBox2.Text.ToString().Trim('|');
string[] barcode = GroupBarcode.Split('|');
if (count != barcode.GetLength(0))
{
MessageBox.Show("������ʾ", "�����豸��¼�����벹������������һ��", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (barcode.GetLength(0) < 1)
{
MessageBox.Show("������ʾ", "����λ������ȷ", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
for (int i = 0; i < barcode.GetLength(0); i++)
{
if (barcode[i].Length != barcodelenth)
{
MessageBox.Show("������ʾ", "����λ������ȷ", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
string d = Dns.GetHostEntry("localhost").HostName;
if (CStaticClass.UserID != "")
{
d = Dns.GetHostEntry("localhost").HostName + dbo.GetSingle("select f_username from T_Base_Users where f_userid='" + CStaticClass.UserID + "'").ToString();
}
CStaticClass.WcfControl.BeginWriteGroupBarcode(d, _deviceIndex, GroupBarcode, new AsyncCallback(WriteGroupBarcodeCallback), null);
}
private void button2_Click_1(object sender, EventArgs e)
{
if (Convert.ToInt32(dbo.GetSingle("select F_AlarmLock from T_Base_Device where F_DeviceIndex=" + _deviceIndex)) == 0)
{
MessageBox.Show("������ʾ", "��ǰ�豸û�б�������ͣ������������", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
string lane = "18" + _deviceIndex.ToString().Substring(2, 3);
if (Convert.ToInt32(dbo.GetSingle("select count(0) from t_manage_task with(nolock) where fstartdevice=" + Convert.ToInt32(lane) + " and fenddevice like '19%'")) != 0)
{
MessageBox.Show("������ʾ", "��ǰ��������δ���ɵĻ������񣬲��ܽ���������", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (MessageBox.Show("��ȷ��Ҫ������" + this._deviceIndex + "���豸�Ļ�����ͣ����", "������ʾ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
{
return;
}
string d = Dns.GetHostEntry("localhost").HostName;
if (CStaticClass.UserID != "")
{
string purview = dbo.GetSingle("select f_purview from T_Base_Users where f_userid='" + CStaticClass.UserID + "'").ToString();
if (purview.IndexOf("MIAltMonitor") < 0)
{
MessageBox.Show("������ʾ", "���˺�û��Ȩ�ޣ�", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
d = Dns.GetHostEntry("localhost").HostName + dbo.GetSingle("select f_username from T_Base_Users where f_userid='" + CStaticClass.UserID + "'").ToString();
}
CStaticClass.WcfControl.BeginClearFireAlarm(d, _deviceIndex, new AsyncCallback(ClearFireAlarmCallback), null);
}
private void button5_Click(object sender, EventArgs e)
{
//if (Convert.ToInt32(dbo.GetSingle("select F_Lock from T_NeedLock where F_DeviceIndex=" + _deviceIndex)) == 0)
//{
// MessageBox.Show("������ʾ", "��ǰ�豸û�б���������������������", MessageBoxButtons.OK, MessageBoxIcon.Error);
// return;
//}
if (MessageBox.Show("��ȷ��Ҫ������" + this._deviceIndex + "���豸�Ĵ�����������", "������ʾ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
{
return;
}
string d = Dns.GetHostEntry("localhost").HostName;
if (CStaticClass.UserID != "")
{
string purview = dbo.GetSingle("select f_purview from T_Base_Users where f_userid='" + CStaticClass.UserID + "'").ToString();
if (purview.IndexOf("MIAltMonitor") < 0)
{
MessageBox.Show("������ʾ", "���˺�û��Ȩ�ޣ�", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
d = Dns.GetHostEntry("localhost").HostName + dbo.GetSingle("select f_username from T_Base_Users where f_userid='" + CStaticClass.UserID + "'").ToString();
}
CStaticClass.WcfControl.BeginClearPallet(d, _deviceIndex, new AsyncCallback(ClearPalletCallback), null);
}
private void button6_Click(object sender, EventArgs e)
{
//ǿ������
string dtime = DateTime.Now.ToString("u");//20101028
StringBuilder sql = new StringBuilder();
string strSQL = string.Format("update ZH_pallet set GOODS_COUNT=1 where Device={0}", _deviceIndex);
int bl = dboMan.ExecuteSql(strSQL);
if (bl == 1)
{
DataView dvTemp = dbo.ExceSQL($" select * from ZH_pallet where Device = {_deviceIndex} ").Tables[0].DefaultView;
if (dvTemp.Count > 0)
{
//������������
dtime = dtime.Substring(0, dtime.Length - 1);
sql.Remove(0, sql.Length);
sql.AppendLine(" INSERT INTO IO_CONTROL_APPLY ( ");
sql.AppendLine(" CONTROL_APPLY_TYPE, WAREHOUSE_CODE,DEVICE_CODE");//�������͡��ⷿ���롢λ�ã���ʼվ̨��
sql.AppendLine(" , STOCK_BARCODE, APPLY_TASK_STATUS, CREATE_TIME ");//�������롢��������ת̬������ʱ��
sql.AppendLine(" ,CONTROL_APPLY_REMARK,CONTROL_APPLY_PARAMETER ");//��ע��ֽ��������Ϣ/ASN��
sql.AppendLine(" ) VALUES ( ");
sql.AppendLine($" 14 , 1 , '{_deviceIndex}'");// 14 ��������
sql.AppendLine($" ,'{dvTemp[0]["STOCK_BARCODE"]}',0, '{dtime}'");
sql.AppendLine($" ,'','{dvTemp[0]["SN"]}'");
sql.AppendLine(" ) ");
dboMan.ExceSQL(sql.ToString());
}
MessageBox.Show("������ʾ", "ǿ������һ�·���", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
else
{
MessageBox.Show("û���������񣡣�");
}
}
public static implicit operator FrmDeviceStatus(FrmDeviceMS v)
{
throw new NotImplementedException();
}
private void Btn_AutomaticPlatform_Click(object sender, EventArgs e)
{
string strSQL = $"update T_Base_Device set F_PALLETBARCODE = '{this.txt_AutomaticPlatform.Text}' where F_DeviceIndex = {_deviceIndex} ";
dboMan.ExecuteSql(strSQL);
}
}
}