2230173_宁德吉利极片库WCS代码
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.

151 lines
5.8 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DBFactory;
namespace wcfControlMonitorClient
{
public partial class FrmStackForkControl : Form
{
private static FrmStackForkControl _formInstance;
//2220173-时代吉利 增加货叉禁用功能
public static FrmStackForkControl FormInstance
{
get
{
if (_formInstance == null)
{
_formInstance = new FrmStackForkControl();
isFirstShow = false;
}
return _formInstance;
}
set { _formInstance = value; }
}
DBOperator dbo = CStaticClass.dbo;
static bool isFirstShow = false;//20130117
DataSet ds = new DataSet();//20161121
StringBuilder sql = new StringBuilder();
public FrmStackForkControl()
{
InitializeComponent();
_formInstance = this;//20101028
}
private void FrmStackForkControl_Load(object sender, EventArgs e)
{
//DataView dvs = dbo.ExceSQL("select distinct(F_stackindex) as 堆垛机编号,F_ENABLEUSED as 禁用货叉编号 from T_BASE_STACKINFO where F_forkamount>1 order by F_stackindex").Tables[0].DefaultView;
//dataGridView1.DataSource = dvs;
BindingData();
cmbFork.Items.Add(0);
cmbFork.Items.Add(1);
cmbFork.Items.Add(2);
cmbFork.SelectedIndex = -1;
}
public void BindingData()
{
DataView dvs = dbo.ExceSQL("select distinct(F_stackindex) as 堆垛机编号,F_ENABLEUSED as 禁用货叉编号 from T_BASE_STACKINFO where F_forkamount>1 and F_stackindex=10003 order by F_stackindex").Tables[0].DefaultView;
dataGridView1.DataSource = dvs;
}
private void tsmEdit_Click(object sender, EventArgs e)
{
if (dataGridView1.RowCount <= 0)
{
return;
}
this.txtStackIndex.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
this.cmbFork.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString();
}
private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
if ((e.ColumnIndex >= 0) && (e.RowIndex >= 0) && (e.Button == MouseButtons.Right))//20110309
{
dataGridView1.ClearSelection();
dataGridView1.Rows[e.RowIndex].Selected = true;
dataGridView1.CurrentCell = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
}
}
private void Button1_Click(object sender, EventArgs e)
{
if (CStaticClass.WCFOK == false)
{
MessageBox.Show("与服务端连接失败!");
return;
}
//if (CStaticClass.Order == false)
//{
// MessageBox.Show("请打开命令开关!");
// return;
//}
if (txtStackIndex.Text == "")
{
MessageBox.Show("堆垛机编号不能为空!");
return;
}
if (cmbFork.Text == "")
{
MessageBox.Show("货叉编号不能为空!");
return;
}
else
{
int stackIndex = Convert.ToInt32(txtStackIndex.Text);
int forkIndex = 0;
forkIndex = Convert.ToInt32(cmbFork.Text);
try
{
//新增加的接口 给电气在第18字节上发送标志
//更新接口WcfControlMonitor服务 配置服务里面改IP 同时运行生成异步类
//在堆垛机发送的时候 也做修改了 重新根据禁用货叉情况 来定义货叉 替换检测条件
CStaticClass.WcfControl.BeginSendStackForkStatus(stackIndex, forkIndex, new AsyncCallback(SendStackForkStatusCallBack), forkIndex);
sql.Remove(0, sql.Length);
sql.Append("update T_BASE_STACKINFO set F_ENABLEUSED=").Append(forkIndex).Append(" where F_Stackindex=").Append(stackIndex);
int a=dbo.ExecuteSql(sql.ToString());
if (a > 0 && forkIndex != 0)
{
MessageBox.Show("禁用成功!", "操作提示:", MessageBoxButtons.OK, MessageBoxIcon.None);
}
else if (a > 0 && forkIndex == 0)
{
MessageBox.Show("解禁成功!", "操作提示:", MessageBoxButtons.OK, MessageBoxIcon.None);
}
else
{
MessageBox.Show("操作失败!", "操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
BindingData();
}
catch (Exception ex)
{
throw ex;
}
}
}
void SendStackForkStatusCallBack(IAsyncResult ar)
{
string errtext = string.Empty;
this.BeginInvoke(new MethodInvoker(delegate ()
{
if (CStaticClass.WcfControl.EndSendStackForkStatus(out errtext, ar) == false)
{
MessageBox.Show(errtext, "操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}));
}
private void FrmStackForkControl_FormClosing(object sender, FormClosingEventArgs e)
{
_formInstance = null;
}
}
}