using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Text ;
using Mesnac.Codd.Session ;
using System.Data ;
using System.Data.SqlClient ;
using Mesnac.Compressor.Entity ;
using Mesnac.Log ;
using System.Web.Security ;
namespace Mesnac.Compressor.Data
{
public class DbHandler
{
public DbHelper dbHelper ;
public string constr = System . Configuration . ConfigurationManager . AppSettings [ "SqlString" ] ;
public DbHandler ( )
{
initDB ( ) ;
}
public void initDB ( )
{
DbSession dbsession = new DbSession ( SqlClientFactory . Instance , constr ) ;
dbHelper = new DbHelper ( dbsession ) ;
if ( dbHelper ! = null )
{
Console . WriteLine ( "数据库初始化成功" ) ;
}
}
#region 参考
public DataTable GetStationList ( string station )
{
if ( dbHelper = = null )
{
return null ;
}
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
StringBuilder sb = new StringBuilder ( ) ;
sb . Append ( "SELECT StationID,StationCode,StationName FROM dbo.T_BD_SubStation where StationID>27 and StationID in ('28','32','37','39','41','43','44','46' ) and StationID<=" ) . Append ( station ) . Append ( " ORDER BY StationID" ) ;
dbHelper . CommandText = sb . ToString ( ) ;
Console . WriteLine ( sb . ToString ( ) ) ;
DataTable dt = dbHelper . ToDataTable ( ) ;
return dt ;
}
public DataTable GetReStartStationList ( string station )
{
if ( dbHelper = = null )
{
return null ;
}
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
StringBuilder sb = new StringBuilder ( ) ;
sb . Append ( "SELECT StationID,StationCode,StationName,TableName FROM dbo.T_BD_SubStation where 1= 1" ) ;
sb . Append ( "and StationID<=" ) ;
sb . Append ( station ) ;
sb . Append ( " ORDER BY StationID" ) ;
dbHelper . CommandText = sb . ToString ( ) ;
Console . WriteLine ( sb . ToString ( ) ) ;
DataTable dt = dbHelper . ToDataTable ( ) ;
return dt ;
}
public DataTable GetDeleteReStartStationList ( string station )
{
if ( dbHelper = = null )
{
return null ;
}
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
StringBuilder sb = new StringBuilder ( ) ;
sb . Append ( "SELECT StationID,StationCode,StationName,TableName FROM dbo.T_BD_SubStation where 1=1" ) ;
sb . Append ( "and StationID>=" ) ;
sb . Append ( station ) ;
sb . Append ( " ORDER BY StationID" ) ;
dbHelper . CommandText = sb . ToString ( ) ;
Console . WriteLine ( sb . ToString ( ) ) ;
DataTable dt = dbHelper . ToDataTable ( ) ;
return dt ;
}
public void DeleteStationData ( string tablename , string ProductBarCode )
{
try
{
if ( dbHelper = = null )
{
return ;
}
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "DELETE FROM " + tablename + " WHERE ScanBarcode=@ProductBarCode " ;
dbHelper . AddParameter ( "@ProductBarCode" , ProductBarCode ) ;
dbHelper . ExecuteNonQuery ( ) ;
}
catch ( Exception ex )
{
}
}
public bool IsHaveTraceState ( string ProductBarCode )
{
bool iflag = false ;
try
{
StringBuilder sb = new StringBuilder ( ) ;
sb . Append ( "select SemiBarcode_A from T_SY_TraceState where ProductBarcode = '" ) . Append ( ProductBarCode ) . Append ( "'" ) ;
DbHandler db = new DbHandler ( ) ;
db . dbHelper . ClearParameter ( ) ;
db . dbHelper . CommandType = CommandType . Text ;
db . dbHelper . CommandText = "" ;
db . dbHelper . CommandText = sb . ToString ( ) ;
var obj = db . dbHelper . ToScalar ( ) ;
if ( obj ! = null )
{
iflag = true ;
return iflag ;
}
else
{
return iflag ;
}
}
catch ( Exception ex )
{
return iflag ;
}
}
/// <summary>
/// 返修记录
/// </summary>
/// <param name="ISDis"></param>
/// <param name="RestartStation"></param>
/// <param name="ProductBarcode"></param>
/// <returns></returns>
public void InsertRepairInfo ( string Barcode , string ProductBarcode , string ReStartStation , string remark )
{
bool ifalg = false ;
if ( dbHelper = = null )
{
return ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
StringBuilder sb = new StringBuilder ( ) ;
sb . Append ( "INSERT INTO dbo.base_RepairInfo_Record(Barcode,ProductBarcode,ReStartStation,remark)VALUES('" ) ;
sb . Append ( Barcode ) . Append ( "','" ) . Append ( ProductBarcode ) . Append ( "','" ) . Append ( ReStartStation ) . Append ( "','" ) . Append ( remark ) . Append ( "')" ) ;
dbHelper . CommandText = sb . ToString ( ) ;
dbHelper . ExecuteNonQuery ( ) ; //没有返回值
}
catch ( Exception ex )
{
LogService . Instance . Error ( "异常:" + ex . Message ) ;
// ICSharpCode.Core.LoggingService.Info(string.Format(ex.ToString()));
}
}
public bool DeletePrintInfo ( string ProductBarcode )
{
StringBuilder sb = new StringBuilder ( ) ;
try
{
sb . Append ( " delete from base_Barcode_PrintInfo" ) . Append ( " WHERE ProductBarcode = '" ) . Append ( ProductBarcode ) . Append ( "' " ) ;
DbHandler db = new DbHandler ( ) ;
db . dbHelper . ClearParameter ( ) ;
db . dbHelper . CommandType = CommandType . Text ;
db . dbHelper . CommandText = sb . ToString ( ) ;
db . dbHelper . ExecuteNonQuery ( ) ;
return true ;
}
catch ( Exception ex )
{
LogService . Instance . Error ( "异常:" + ex . Message ) ;
return false ;
}
}
public bool UpdateTraceReStartStation ( string ISDis , string RestartStation , string ProductBarcode )
{
StringBuilder sb = new StringBuilder ( ) ;
try
{
//整机拆解,清空组件码
sb . Append ( " UPDATE dbo.T_SY_TraceState SET ISDis='" ) . Append ( ISDis ) . Append ( "',CurrentStationID ='" ) . Append ( RestartStation ) ;
sb . Append ( "' , RestartStation='" ) . Append ( RestartStation ) ;
if ( RestartStation = = "11" )
{
sb . Append ( "' ,SemiBarcode_A = '' ,SemiBarcode_B = '',SemiBarcode_C = '',SemiBarcode2 = '" ) ;
}
//控制器拆解,清控制器码
else
{
sb . Append ( "' ,SemiBarcode2 = '" ) ;
}
sb . Append ( "' WHERE ProductBarcode='" ) . Append ( ProductBarcode ) . Append ( "' " ) ;
DbHandler db = new DbHandler ( ) ;
db . dbHelper . ClearParameter ( ) ;
db . dbHelper . CommandType = CommandType . Text ;
db . dbHelper . CommandText = sb . ToString ( ) ;
db . dbHelper . ExecuteNonQuery ( ) ;
return true ;
}
catch ( Exception ex )
{
return false ;
//ICSharpCode.Core.LoggingService.Error("Trace表NG工位更新错误:" + sb.ToString() + "/r/n" + e.ToString());
}
}
/// <summary>
///
/// </summary>
/// <param name="semiBarcode"></param>
/// <returns></returns>
public string GetMainBacodeBySemiBarcode ( string semiBarcode )
{
if ( dbHelper = = null )
{
return "" ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
StringBuilder sb = new StringBuilder ( ) ;
sb . Append ( "SELECT SemiBarcode FROM dbo.T_RP_WorkTrayRealTimeInfo WHERE RFIDNum='" ) ;
sb . Append ( semiBarcode ) . Append ( "'" ) ;
dbHelper . CommandText = sb . ToString ( ) ;
return dbHelper . ToScalar ( ) . ToString ( ) ;
}
catch ( Exception ex )
{
return "" ;
}
}
/// <summary>
///
/// </summary>
/// <param name="Rfid"></param>
/// <returns></returns>
public bool GetPreWorkInfo ( string Rfid , string stationid )
{
//根据当前工位获取前一工位数据
//然后获取前一工位信息
if ( dbHelper = = null )
{
return false ;
}
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
StringBuilder sb = new StringBuilder ( ) ;
sb . Append ( "SELECT StationID FROM dbo.T_BD_SubStation a LEFT JOIN dbo.T_RP_WorkTrayRealTimeInfo b ON a.PreStationID=b.CurrentStation WHERE b.RFIDNum='" ) . Append ( Rfid ) . Append ( "'" ) ;
dbHelper . CommandText = sb . ToString ( ) ;
DataTable dt = dbHelper . ToDataTable ( ) ;
if ( dt . Rows . Count < 1 )
{
return false ;
}
string currentStation = dt . Rows [ 0 ] [ "StationID" ] . ToString ( ) ;
if ( stationid = = currentStation )
{
return true ;
}
else
{
return false ;
}
}
public void Insert ( string TableName , object [ ] objectArray )
{
if ( dbHelper = = null )
{
return ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
StringBuilder sb = new StringBuilder ( ) ;
sb . Append ( "insert into " ) . Append ( TableName ) . Append ( " values(" ) ;
//sb.Append("'',").Append();
foreach ( object ob in objectArray )
{
sb . Append ( "'" ) . Append ( ob . ToString ( ) ) . Append ( "'" ) ;
}
sb . Append ( ")" ) ;
dbHelper . CommandText = sb . ToString ( ) ;
dbHelper . ExecuteNonQuery ( ) ;
}
catch ( Exception ex )
{
}
}
public void ExecSql ( string sql )
{
if ( dbHelper = = null )
{
return ;
}
try
{
dbHelper . CommandText = sql ;
dbHelper . ExecuteNonQuery ( ) ;
}
catch ( Exception e )
{
// ICSharpCode.Core.LoggingService.Debug("Insert语句错误: " + e.ToString());
}
}
public void InsertTrace ( string barcode , string SemiACode , string ProductBarCode , string machineID )
{
if ( dbHelper = = null )
{
return ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
string sql = "EXEC SP_Pro_ChongtouInsertTraceStation @semiBarcode,@mainBarcode,@ProductBarCode,@MachineID" ;
dbHelper . AddParameter ( "@semiBarcode" , SemiACode ) ;
dbHelper . AddParameter ( "@mainBarcode" , barcode ) ;
dbHelper . AddParameter ( "@ProductBarCode" , ProductBarCode ) ;
dbHelper . AddParameter ( "@MachineID" , machineID ) ;
dbHelper . CommandText = sql ;
dbHelper . ExecuteNonQuery ( ) ;
//localDB.InsertTrace(barcode, SemiACode, 1);
}
catch ( Exception ex )
{
return ;
}
}
public string CreatNewSemibarcode ( )
{
if ( dbHelper = = null )
{
return null ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
StringBuilder sb = new StringBuilder ( ) ;
sb . Append ( "EXEC SP_Pro_GetNewSemiBarcode '" ) ;
sb . Append ( "A" ) . Append ( "','" ) . Append ( "1" ) . Append ( "'" ) ;
dbHelper . CommandText = sb . ToString ( ) ;
return dbHelper . ToScalar ( ) . ToString ( ) ;
}
catch ( Exception ex )
{
return null ;
}
}
public String GetNowProductionInfo ( )
{
if ( dbHelper = = null )
{
return null ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
string sql = " SELECT top(1) ProductId FROM dbo.T_RP_ProductChangeInfo WHERE LineName='A'" ;
dbHelper . CommandText = sql ;
return dbHelper . ToScalar ( ) . ToString ( ) ;
}
catch ( Exception ex )
{
return null ;
}
}
public string GetLastMainBarcode ( string code )
{
if ( dbHelper = = null )
{
return "NoConnect0001" ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
StringBuilder sb = new StringBuilder ( ) ;
sb . Append ( "EXEC SP_Pro_GetNewMainBarcode '" ) ;
sb . Append ( code ) . Append ( "'" ) ;
dbHelper . CommandText = sb . ToString ( ) ;
return dbHelper . ToScalar ( ) . ToString ( ) ;
}
catch ( Exception ex )
{
// ICSharpCode.Core.LoggingService.Info(string.Format(ex.ToString()));
return "Error0001" ;
}
}
public string GetLastSemiBarcode ( string code )
{
if ( dbHelper = = null )
{
return "NoConnect0001" ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
StringBuilder sb = new StringBuilder ( ) ;
sb . Append ( "EXEC SP_Pro_GetNewSemiBarcode '" ) ;
sb . Append ( code ) . Append ( "'" ) ;
dbHelper . CommandText = sb . ToString ( ) ;
return dbHelper . ToScalar ( ) . ToString ( ) ;
}
catch ( Exception ex )
{
//ICSharpCode.Core.LoggingService.Info(string.Format(ex.ToString()));
return "Error0001" ;
}
}
public bool CurrentStationHaveWork ( string stationID , string RFID )
{
if ( dbHelper = = null )
{
return false ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
string sql = "Exec SP_Pro_CurruntState @RFID,@stationID" ;
dbHelper . AddParameter ( "@RFID" , RFID ) ;
dbHelper . AddParameter ( "@stationID" , stationID ) ;
dbHelper . CommandText = sql ;
var obj = dbHelper . ToScalar ( ) ;
int result = Convert . ToInt32 ( obj ) ;
if ( result < 1 )
{
return false ;
}
else
{
return true ;
}
}
catch ( Exception ex )
{
// ICSharpCode.Core.LoggingService.Info(string.Format(ex.ToString()));
return false ;
}
}
public bool Test ( string Barcode , int state1 , int state2 , int state3 , int state4 , string restartStation , string checker )
{
if ( dbHelper = = null )
{
return false ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
string sql = "Exec SP_Pro_chaijian @Barcode,@state1,@state2,@state3,@state4,@restartStation,@checker" ;
dbHelper . AddParameter ( "@Barcode" , Barcode ) ;
dbHelper . AddParameter ( "@state1" , state1 ) ;
dbHelper . AddParameter ( "@state2" , state2 ) ;
dbHelper . AddParameter ( "@state3" , state3 ) ;
dbHelper . AddParameter ( "@state4" , state4 ) ;
dbHelper . AddParameter ( "@restartStation" , restartStation ) ;
dbHelper . AddParameter ( "@checker" , checker ) ;
dbHelper . CommandText = sql ;
Console . WriteLine ( sql ) ;
var obj = dbHelper . ToScalar ( ) ;
int result = Convert . ToInt32 ( obj ) ;
if ( result < 1 )
{
return false ;
}
else
{
return true ;
}
}
catch ( Exception ex )
{
Console . WriteLine ( "存储过程异常错误" ) ;
return false ;
}
}
public DataSet Select ( string Barcode )
{
if ( dbHelper = = null )
{
return null ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
string sql = "Exec SP_Pro_SelectBarcode @Barcode" ;
dbHelper . AddParameter ( "@Barcode" , Barcode ) ;
dbHelper . CommandText = sql ;
//var obj = dbHelper.ToDataTable();
//return null;
DataSet dt = ( DataSet ) dbHelper . ToDataSet ( ) ;
return dt ;
}
catch ( Exception ex )
{
// ICSharpCode.Core.LoggingService.Info(string.Format(ex.ToString()));
return null ;
}
}
/// <summary>
/// 重投次数超过三次返回false 不能重投
/// </summary>
/// <returns></returns>
public bool RestartCount ( string Barcode )
{
if ( dbHelper = = null )
{
return false ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
string sql = "Exec SP_Pro_RestartCount @Barcode" ;
dbHelper . AddParameter ( "@Barcode" , Barcode ) ;
dbHelper . CommandText = sql ;
//var obj = dbHelper.ToDataTable();
//return null;
object count = dbHelper . ToScalar ( ) ;
return Convert . ToInt32 ( count ) > 0 ;
}
catch ( Exception ex )
{
// ICSharpCode.Core.LoggingService.Info(string.Format(ex.ToString()));
return false ;
}
}
/// <summary>
/// 获取当前工位质量
/// </summary>
/// <param name="MainBarcode"></param>
/// <param name="SemiBarcode"></param>
/// <param name="StationName"></param>
/// <returns></returns>
public bool GetCurrentStationState ( string MainBarcode , string SemiBarcode , string StationName , string tableName )
{
if ( dbHelper = = null )
{
return false ;
}
try
{
string TableName = tableName ;
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
StringBuilder sb = new StringBuilder ( ) ;
sb . Append ( " SELECT Barcode FROM " ) . Append ( TableName ) ;
sb . Append ( " WHERE Barcode='" ) . Append ( MainBarcode ) . Append ( "' AND SemiBarcode='" ) . Append ( SemiBarcode ) . Append ( "' AND State='1'" ) ;
dbHelper . CommandText = sb . ToString ( ) ;
DataTable dt = dbHelper . ToDataTable ( ) ;
return dt . Rows . Count > 0 ;
}
catch ( Exception ex )
{
//ICSharpCode.Core.LoggingService.Info(string.Format(ex.ToString()));
return false ;
}
}
/// <summary>
/// 创建新的系统条码
/// </summary>
/// <param name="MainBarcode"></param>
/// <param name="SemiBarcode"></param>
public void CreatNewProduct ( string MainBarcode , string SemiBarcode )
{
if ( dbHelper = = null )
{
return ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
StringBuilder sb = new StringBuilder ( ) ;
sb . Append ( "INSERT INTO dbo.T_SY_TraceState(barcode,SemiBarcode_A1)VALUES('" ) ;
sb . Append ( MainBarcode ) . Append ( "','" ) . Append ( SemiBarcode ) . Append ( "')" ) ;
dbHelper . CommandText = sb . ToString ( ) ;
dbHelper . ExecuteNonQuery ( ) ; //没有返回值
}
catch ( Exception ex )
{
// ICSharpCode.Core.LoggingService.Info(string.Format(ex.ToString()));
}
}
public void UpdateTray ( string EPC , int okng , string station , string semibarcode )
{
}
//互换托盘,不是换线。
public void ChangeTray ( string RFID , int state , string SemiType , string stationID , string Semibarcode )
{
if ( dbHelper = = null )
{
return ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
string sql = "Exec SP_Pro_changeTray @RFID,@State,@stationID,@semibarcode,@semiType" ;
dbHelper . AddParameter ( "@RFID" , RFID ) ;
dbHelper . AddParameter ( "@State" , state ) ;
dbHelper . AddParameter ( "@semibarcode" , Semibarcode ) ;
dbHelper . AddParameter ( "@semiType" , SemiType ) ;
dbHelper . AddParameter ( "@stationID" , stationID ) ;
dbHelper . CommandText = sql ;
dbHelper . ExecuteNonQuery ( ) ;
}
catch ( Exception ex )
{
// ICSharpCode.Core.LoggingService.Info(string.Format(ex.ToString()));
}
}
public string GetSemiBarcode ( string RFID )
{
if ( dbHelper = = null )
{
return "" ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
StringBuilder sb = new StringBuilder ( ) ;
sb . Append ( "SELECT SemiBarcode FROM dbo.T_RP_WorkTrayRealTimeInfo WHERE RFIDNum='" ) ;
sb . Append ( RFID ) . Append ( "'" ) ;
dbHelper . CommandText = sb . ToString ( ) ;
return dbHelper . ToScalar ( ) . ToString ( ) ;
}
catch ( Exception ex )
{
//ICSharpCode.Core.LoggingService.Info(string.Format(ex.ToString()));
return "" ;
}
}
public string GetMainBarcode ( string RFID )
{
if ( dbHelper = = null )
{
return "" ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
StringBuilder sb = new StringBuilder ( ) ;
sb . Append ( "SELECT barCode FROM dbo.T_RP_WorkTrayRealTimeInfo WHERE RFIDNum='" ) ;
sb . Append ( RFID ) . Append ( "'" ) ;
dbHelper . CommandText = sb . ToString ( ) ;
return dbHelper . ToScalar ( ) . ToString ( ) ;
}
catch ( Exception ex )
{
// ICSharpCode.Core.LoggingService.Info(string.Format(ex.ToString()));
return "" ;
}
}
/// <summary>
/// 插入部件条码到部件表
/// </summary>
/// <param name="barcode"></param>
public void InsertSemiBarcode ( string barcode )
{
if ( dbHelper = = null )
{
return ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
StringBuilder sb = new StringBuilder ( ) ;
sb . Append ( "INSERT INTO [dbo].[T_RP_SemiProInfo](SemiBarcode)VALUES('" ) ;
sb . Append ( barcode ) . Append ( "')" ) ;
dbHelper . CommandText = sb . ToString ( ) ;
dbHelper . ExecuteNonQuery ( ) ;
}
catch ( Exception ex )
{
//ICSharpCode.Core.LoggingService.Info(string.Format(ex.ToString()));
return ;
}
}
public void InsertMainBacode ( string barcode , string SemiACode , string MachineID )
{
if ( dbHelper = = null )
{
return ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
StringBuilder sb = new StringBuilder ( ) ;
sb . Append ( "INSERT INTO [dbo].[T_SY_TraceState](Barcode,SemiBarcode_A,ProductID)VALUES('" ) ;
sb . Append ( barcode ) . Append ( "','" ) . Append ( SemiACode ) . Append ( "','" ) . Append ( MachineID ) . Append ( "')" ) ;
dbHelper . CommandText = sb . ToString ( ) ;
dbHelper . ExecuteNonQuery ( ) ;
}
catch ( Exception ex )
{
//ICSharpCode.Core.LoggingService.Info(string.Format(ex.ToString()));
return ;
}
}
/// <summary>
/// 更新主表,追踪
/// </summary>
public void UpdateTrace ( string Column , string MainCode , string SemiCode )
{
if ( dbHelper = = null )
{
return ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
StringBuilder sb = new StringBuilder ( ) ;
sb . Append ( "UPDATE [dbo].[T_SY_TraceState] SET " ) ;
sb . Append ( Column ) . Append ( "='" ) . Append ( SemiCode ) . Append ( "' where Barcode='" ) . Append ( MainCode ) . Append ( "'" ) ;
dbHelper . CommandText = sb . ToString ( ) ;
dbHelper . ExecuteNonQuery ( ) ;
}
catch ( Exception ex )
{
// ICSharpCode.Core.LoggingService.Info(string.Format(ex.ToString()));
return ;
}
}
public void ChangeLine ( string RFID , string Semibarcode , string stationid )
{
if ( dbHelper = = null )
{
return ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
string sql = "Exec SP_Pro_ChangeLine @RFID,@Semibarcode,@stationid" ;
dbHelper . AddParameter ( "@RFID" , RFID ) ;
dbHelper . AddParameter ( "@Semibarcode" , Semibarcode ) ;
dbHelper . AddParameter ( "@stationid" , stationid ) ;
dbHelper . CommandText = sql ;
dbHelper . ExecuteNonQuery ( ) ;
}
catch ( Exception ex )
{
// ICSharpCode.Core.LoggingService.Info(string.Format(ex.ToString()));
}
}
# endregion
public DataTable Test1 ( )
{
if ( dbHelper = = null )
{
return null ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
string sql = "select SemiBarcode_A from T_SY_TraceState where ProductBarcode = 'E34FT0M0723091805118'" ;
dbHelper . CommandText = sql ;
//var obj = dbHelper.ToDataTable();
//return null;
DataTable dt = dbHelper . ToDataTable ( ) ;
return dt ;
}
catch ( Exception ex )
{
// ICSharpCode.Core.LoggingService.Info(string.Format(ex.ToString()));
return null ;
}
}
public String GetProductionInfo ( string Acode )
{
if ( dbHelper = = null )
{
return null ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
StringBuilder sb = new StringBuilder ( ) ;
sb . Append ( "SELECT ProductBarcode FROM dbo.T_RP_BarcodeRelationShip WHERE LineID='1' and SemiBarcode ='" ) ;
sb . Append ( Acode ) . Append ( "'" ) ;
dbHelper . CommandText = sb . ToString ( ) ;
return dbHelper . ToScalar ( ) . ToString ( ) ;
}
catch ( Exception ex )
{
return null ;
}
}
public void UpdateCPM ( string CPM , string AM )
{
if ( dbHelper = = null )
{
return ;
}
try
{
dbHelper . ClearParameter ( ) ;
dbHelper . CommandType = CommandType . Text ;
dbHelper . CommandText = "" ;
StringBuilder sb = new StringBuilder ( ) ;
sb . Append ( "UPDATE [dbo].[T_SY_TraceState] SET ProductBarcode ='" ) ;
sb . Append ( CPM ) . Append ( "' where SemiBarcode_A='" ) . Append ( AM ) . Append ( "'" ) ;
dbHelper . CommandText = sb . ToString ( ) ;
dbHelper . ExecuteNonQuery ( ) ;
}
catch ( Exception ex )
{
LogService . Instance . Error ( "异常:" + ex . Message ) ;
return ;
}
}
}
}