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 FrmUpdateStatus : Form
{
string _ manstatus = " F_Status=996 or F_Status=976 or F_Status=906 " ;
private static FrmUpdateStatus _f ormInstance ;
public static FrmUpdateStatus FormInstance
{
get
{
if ( _f ormInstance = = null )
{
_f ormInstance = new FrmUpdateStatus ( ) ;
}
return _f ormInstance ;
}
set { _f ormInstance = value ; }
}
Model . MDevice devinfo ;
DBOperator dbo = CStaticClass . dbo ;
DBOperator dboM = CStaticClass . dboM ;
public FrmUpdateStatus ( )
{
InitializeComponent ( ) ;
_f ormInstance = this ;
}
private void TSMrefresh_Click ( )
{
this . interfaceGridView . DataSource = dbo . ExceSQL ( "select CONTROL_APPLY_ID,CONTROL_ID,CONTROL_APPLY_TYPE,STOCK_BARCODE,APPLY_TASK_STATUS,CREATE_TIME,CONTROL_APPLY_PARAMETER,CONTROL_APPLY_REMARK from IO_CONTROL_APPLY_HIS order by CREATE_TIME desc).Tables[0].DefaultView;" ) ;
this . interfaceGridView . Columns [ "CONTROL_APPLY_ID" ] . HeaderText = "ID号" ;
this . interfaceGridView . Columns [ "CONTROL_ID" ] . HeaderText = "WMS任务号" ;
this . interfaceGridView . Columns [ "CONTROL_APPLY_TYPE" ] . HeaderText = "处理类型" ;
this . interfaceGridView . Columns [ "STOCK_BARCODE" ] . HeaderText = "条码" ;
this . interfaceGridView . Columns [ "APPLY_TASK_STATUS" ] . HeaderText = "处理状态" ;
this . interfaceGridView . Columns [ "CREATE_TIME" ] . HeaderText = "创建时间" ;
this . interfaceGridView . Columns [ "CONTROL_APPLY_PARAMETER" ] . HeaderText = "报警信息" ;
this . interfaceGridView . Columns [ "CONTROL_APPLY_REMARK" ] . HeaderText = "异常信息" ;
}
private void Button1_Click ( object sender , EventArgs e )
{
try
{
TSMrefresh_Click ( ) ;
}
catch ( Exception ex )
{
MessageBox . Show ( ex . Message , "操作提示:" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
}
}
private void Button2_Click ( object sender , EventArgs e )
{
_ manstatus = " APPLY_TASK_STATUS=996 or APPLY_TASK_STATUS=976 or APPLY_TASK_STATUS=906 " ;
}
private void FormUpdateStatus_Load ( object sender , EventArgs e )
{
rbmanRun_Click ( sender , e ) ;
}
private void rbmanRun_Click ( object sender , EventArgs e )
{
if ( rbmanRun . Checked = = true )
{
_ manstatus = " APPLY_TASK_STATUS=996 or APPLY_TASK_STATUS=976 " ;
}
TSMrefresh_Click ( ) ;
}
private void rbmanWait_Click ( object sender , EventArgs e )
{
RadioButton rb = ( RadioButton ) sender ;
if ( rb . Checked = = true )
{
_ manstatus = " APPLY_TASK_STATUS=906 " ;
}
TSMrefresh_Click ( ) ;
}
private void RbmanRun_CheckedChanged ( object sender , EventArgs e )
{
}
private void RbmanWait_CheckedChanged ( object sender , EventArgs e )
{
}
private void TSMmanagerOK_Click ( object sender , EventArgs e ) //接口再次调用
{
try
{
if ( MessageBox . Show ( "您确认任务:“" + this . interfaceGridView . CurrentRow . Cells [ "CONTROL_ID" ] . Value . ToString ( ) + "要重新调用接口吗?" , "操作提示:" , MessageBoxButtons . OKCancel , MessageBoxIcon . Question ) ! = DialogResult . OK )
{
return ;
}
int status = - 1 ;
if ( Convert . ToInt32 ( this . interfaceGridView . CurrentRow . Cells [ "CONTROL_APPLY_TYPE" ] . Value . ToString ( ) ) = = 9 9 6 )
{
status = 9 9 9 ;
}
else if ( Convert . ToInt32 ( this . interfaceGridView . CurrentRow . Cells [ "CONTROL_APPLY_TYPE" ] . Value . ToString ( ) ) = = 9 7 6 | | Convert . ToInt32 ( this . interfaceGridView . CurrentRow . Cells [ "CONTROL_APPLY_TYPE" ] . Value . ToString ( ) ) = = 9 0 6 )
{
status = Convert . ToInt32 ( this . interfaceGridView . CurrentRow . Cells [ "CONTROL_APPLY_TYPE" ] . Value . ToString ( ) ) - 6 ;
}
dbo . ExecuteSql ( string . Format ( "UPDATE IO_CONTROL_APPLY set APPLY_TASK_STATUS = {1}, CONTROL_APPLY_TYPE ={1} WHERE (CONTROL_APPLY_ID = {0})" , Convert . ToInt32 ( this . interfaceGridView . CurrentRow . Cells [ "CONTROL_APPLY_ID" ] . Value . ToString ( ) ) , status ) ) ;
TSMrefresh_Click ( ) ;
}
catch ( Exception ex )
{
MessageBox . Show ( ex . Message , "操作提示:" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
}
}
private void ToolStripMenuItem1_Click ( object sender , EventArgs e ) //接口异常删除
{
try
{
if ( MessageBox . Show ( "您确认任务:“" + this . interfaceGridView . CurrentRow . Cells [ "CONTROL_ID" ] . Value . ToString ( ) + "要删除接口异常信息吗?" , "操作提示:" , MessageBoxButtons . OKCancel , MessageBoxIcon . Question ) ! = DialogResult . OK )
{
return ;
}
dbo . ExecuteSql ( string . Format ( "DELETE FROM IO_CONTROL_APPLY WHERE (CONTROL_APPLY_ID = {0})" , Convert . ToInt32 ( this . interfaceGridView . CurrentRow . Cells [ "CONTROL_APPLY_ID" ] . Value . ToString ( ) ) ) ) ; //民航二所 删除当前条 创建触发器删除时写入历史表
TSMrefresh_Click ( ) ;
}
catch ( Exception ex )
{
MessageBox . Show ( ex . Message , "操作提示:" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
}
}
private void FrmUpdateStatus_FormClosing ( object sender , FormClosingEventArgs e )
{
_f ormInstance = null ;
}
private void RbmanRun_Click_1 ( object sender , EventArgs e )
{
if ( rbmanRun . Checked = = true )
{
_ manstatus = " APPLY_TASK_STATUS=996 or APPLY_TASK_STATUS=976 " ;
}
TSMrefresh_Click ( ) ;
}
private void RbmanWait_Click_1 ( object sender , EventArgs e )
{
RadioButton rb = ( RadioButton ) sender ;
if ( rb . Checked = = true )
{
_ manstatus = " APPLY_TASK_STATUS=906 " ;
}
TSMrefresh_Click ( ) ;
}
private void RbmanAll_Click ( object sender , EventArgs e )
{
RadioButton rb = ( RadioButton ) sender ;
if ( rb . Checked = = true )
{
_ manstatus = "APPLY_TASK_STATUS=996 or APPLY_TASK_STATUS=976 or APPLY_TASK_STATUS=906 " ;
}
TSMrefresh_Click ( ) ;
}
private void CmManager_Opening ( object sender , CancelEventArgs e )
{
if ( this . interfaceGridView . CurrentRow = = null )
{
TSMmanagerOK . Visible = false ;
toolStripSeparator1 . Visible = false ;
;
toolStripMenuItem1 . Visible = false ;
toolStripSeparator2 . Visible = false ;
return ;
}
if ( Convert . ToInt32 ( this . interfaceGridView . CurrentRow . Cells [ "CONTROL_ID" ] . Value ) > 0 )
{
TSMmanagerOK . Visible = true ;
toolStripSeparator1 . Visible = true ;
toolStripSeparator2 . Visible = true ;
//TSMmanagerDisassemble.Visible = true;
toolStripMenuItem1 . Visible = true ;
}
}
private void InterfaceGridView_CellMouseDown ( object sender , DataGridViewCellMouseEventArgs e )
{
if ( e . Button = = MouseButtons . Right )
{
if ( ( e . RowIndex > = 0 ) & & ( e . ColumnIndex > = 0 ) )
{
//若行已是选中状态就不再进行设置
if ( interfaceGridView . Rows [ e . RowIndex ] . Selected = = false )
{
interfaceGridView . ClearSelection ( ) ;
interfaceGridView . Rows [ e . RowIndex ] . Selected = true ;
}
//只选中一行时设置活动单元格
if ( interfaceGridView . SelectedRows . Count = = 1 )
{
interfaceGridView . CurrentCell = interfaceGridView . Rows [ e . RowIndex ] . Cells [ e . ColumnIndex ] ;
}
//弹出操作菜单
cmManager . Show ( MousePosition . X , MousePosition . Y ) ;
}
}
}
}
}