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; using System.Data.SqlClient; namespace wcfControlMonitorClient { public partial class FrmChangeShuttle : Form { private static FrmChangeShuttle _formInstance; public static FrmChangeShuttle FormInstance { get { if (_formInstance == null) { _formInstance = new FrmChangeShuttle(); } return _formInstance; } set { _formInstance = value; } } DBOperator dbo = CStaticClass.dbo; DataTable tableTrans = new DataTable("t_shuttle"); public FrmChangeShuttle() { InitializeComponent(); _formInstance = this; LoadInfo(); this.dataGridView1.Columns["F_DeviceIndex"].HeaderText = "穿梭板"; this.dataGridView1.Columns["F_Postion"].HeaderText = "层值"; this.dataGridView1.Columns["F_LaneOut"].HeaderText = "当前在巷道模式设置"; } private void FrmChangeShuttle_Load(object sender, EventArgs e) { } private void LoadInfo() { try { tableTrans = dbo.ExceSQL("select F_DeviceIndex, F_Postion,F_LaneOut from SHUTTLE_POSITION").Tables[0]; this.dataGridView1.DataSource = tableTrans; } catch (SqlException ex) { throw new Exception(ex.Message, ex); } } private void Button2_Click(object sender, EventArgs e) { try { if (MessageBox.Show("请务必确认是否确实要更改穿梭板离线状态,改之前请确保该穿梭板任务处理完且管理系统不再下达新任务", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (this.comboBox1.Text.Trim().Length == 0) { MessageBox.Show("穿梭板不允许为空值!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (this.comboBox2.Text.Trim().Length == 0) { MessageBox.Show("脱离巷道状态设置不允许为空!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } DataView dv = dbo.ExceSQL("select * from SHUTTLE_POSITION where F_DeviceIndex =" + Convert.ToInt32(this.comboBox1.Text.ToString().Trim())).Tables[0].DefaultView; if (dv.Count > 0) { if (dv[0]["F_LaneOut"].ToString().Trim() == this.comboBox2.Text.ToString()) { MessageBox.Show("脱离巷道状态重复设置.", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } string stra = "UPDATE SHUTTLE_POSITION SET F_LaneOut='" + this.comboBox2.Text.Trim().ToString() + "' WHERE F_DeviceIndex =" + Convert.ToInt32(this.comboBox1.Text.ToString().Trim()); dbo.ExceSQL(stra); CommonClassLib.CCarryConvert.WriteDarkCasket("手工更改穿梭板脱离巷道状态", "穿梭版:" + this.comboBox1.Text.ToString(), "离开属性", "成为" + this.comboBox2.Text.ToString()); //CommonClassLib.CCarryConvert.WriteDarkCasket("手工更改单双叉堆垛机", "堆垛机:" + this.comboBox1.Text.ToString(), "使用货叉改", "成为" + this.comboBox2.Text.ToString()); //if (this.comboBox2.Text.Trim().ToString() == "1" || this.comboBox2.Text.Trim().ToString() == "2") //{ // string strb = "UPDATE T_Base_Device SET F_IfCorrelDoubleFork='0' WHERE F_DeviceIndex =" + Convert.ToInt32(this.comboBox1.Text.ToString().Trim()); // dbo.ExceSQL(strb); // CommonClassLib.CCarryConvert.WriteDarkCasket("手工更改T_Base_Device", "堆垛机:" + this.comboBox1.Text.ToString(), "F_IfCorrelDoubleFork", "改成为0"); // Model.MDevice devinfo; // devinfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(this.comboBox1.Text.ToString().Trim())); // devinfo.IfCorrelDoubleFork = "0"; // Model.CGetInfo.SetDeviceInfo(devinfo); //} //else if (this.comboBox2.Text.Trim().ToString() == "0") //{ // string strb = "UPDATE T_Base_Device SET F_IfCorrelDoubleFork='1' WHERE F_DeviceIndex =" + Convert.ToInt32(this.comboBox1.Text.ToString().Trim()); // dbo.ExceSQL(strb); // CommonClassLib.CCarryConvert.WriteDarkCasket("手工更改T_Base_Device", "堆垛机:" + this.comboBox1.Text.ToString(), "F_IfCorrelDoubleFork", "改成为1"); // Model.MDevice devinfo; // devinfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(this.comboBox1.Text.ToString().Trim())); // devinfo.IfCorrelDoubleFork = "1"; // Model.CGetInfo.SetDeviceInfo(devinfo); //} LoadInfo(); } } catch (Exception ex) { } } private void FrmChangeShuttle_FormClosing(object sender, FormClosingEventArgs e) { _formInstance = null; } } }