using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using DBFactory; namespace ControlSystem { /// /// 20101011新增加出入库站台属性定义 /// public partial class FrmIOStation : Form { DBOperator dbo = CStaticClass.dbo; DBOperator dboM = CStaticClass.dboM; private static FrmIOStation _formInstance; public static FrmIOStation FormInstance { get { if (_formInstance == null) { _formInstance = new FrmIOStation(); } return _formInstance; } set { _formInstance = value; } } public FrmIOStation() { InitializeComponent(); DataView dv = dbo.ExceSQL("select F_DeviceIndex,F_DeviceName from T_Base_Device where F_DeviceKindIndex=2").Tables[0].DefaultView; if (dv.Count > 0) { this.comboBox1.DisplayMember = "F_DeviceName"; this.comboBox1.ValueMember = "F_DeviceIndex"; this.comboBox1.DataSource = dv; } _formInstance = this; } private void button1_Click(object sender, EventArgs e) { if (this.comboBox1.SelectedValue == null) { MessageBox.Show("请选择出入库站台!","操作提示",MessageBoxButtons.OK,MessageBoxIcon.Warning); this.comboBox1.Focus(); return; } if (this.comboBox2.Text.Trim()=="") { MessageBox.Show("请选择出入库属性!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.comboBox2.Focus(); return; } if ("出库站台入库站台拣选站台".IndexOf(this.comboBox2.Text.Trim()) < 0) { MessageBox.Show("请选择出入库属性!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.comboBox2.Focus(); return; } string iotype = " (T_Base_Route.F_RouteKind <> 0) "; if (this.comboBox2.Text.Trim() == "入库站台") { iotype = " (T_Base_Route.F_RouteKind = 1) "; dbo.ExecuteSql("update t_base_route set F_Status=1,F_AutoUpdate=1 where F_StartDevice=" + this.comboBox1.SelectedValue); dboM.ExceSQL("update IO_CONTROL_ROUTE set CONTROL_ROUTE_STATUS=1 where START_DEVICE=" + this.comboBox1.SelectedValue); dbo.ExecuteSql("update t_base_route set F_Status=0,F_AutoUpdate=0 where F_EndDevice=" + this.comboBox1.SelectedValue); dboM.ExceSQL("update IO_CONTROL_ROUTE set CONTROL_ROUTE_STATUS=0 where END_DEVICE=" + this.comboBox1.SelectedValue); } else if (this.comboBox2.Text.Trim() == "出库站台") { iotype = " (T_Base_Route.F_RouteKind = 2) "; dbo.ExecuteSql("update t_base_route set F_Status=1,F_AutoUpdate=1 where F_EndDevice=" + this.comboBox1.SelectedValue); dboM.ExceSQL("update IO_CONTROL_ROUTE set CONTROL_ROUTE_STATUS=1 where END_DEVICE=" + this.comboBox1.SelectedValue); dbo.ExecuteSql("update t_base_route set F_Status=0,F_AutoUpdate=0 where F_StartDevice=" + this.comboBox1.SelectedValue); dboM.ExceSQL("update IO_CONTROL_ROUTE set CONTROL_ROUTE_STATUS=0 where START_DEVICE=" + this.comboBox1.SelectedValue); } else { iotype = " (T_Base_Route.F_RouteKind <> 0) "; dbo.ExecuteSql("update t_base_route set F_Status=1,F_AutoUpdate=1 where ((F_EndDevice=" + this.comboBox1.SelectedValue +") or (F_StartDevice=" + this.comboBox1.SelectedValue +"))"); dboM.ExceSQL("update IO_CONTROL_ROUTE set CONTROL_ROUTE_STATUS=1 where ((End_Device=" + this.comboBox1.SelectedValue + ") or (Start_Device=" + this.comboBox1.SelectedValue + "))"); } DataView dv = dbo.ExceSQL("SELECT DISTINCT T_Base_Route.F_RouteID, T_Base_Route.F_RouteKind, "+ "T_Base_Route_Device.F_DeviceIndex FROM T_Base_Route,T_Base_Route_Device where "+ "T_Base_Route.F_RouteID = T_Base_Route_Device.F_RouteID and "+iotype+ " AND (T_Base_Route_Device.F_DeviceIndex = "+this.comboBox1.SelectedValue +")").Tables[0].DefaultView; DataView dvf; for(int i=0;i