@ -2735,6 +2735,170 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no);
}
dtBarcode . AcceptChanges ( ) ;
try
{
if ( kp_no . StartsWith ( "MB" ) & & ! kp_no . StartsWith ( "MB_MAC" ) )
{
bool createMacCol = true ;
bool findFlag = false ;
string mac_sql = string . Format ( "select partbarcode from jhames.c_sfis_keyparts where productsn = '{0}' and parttypeid='MAC'" , part_no ) ;
using ( var esun_cmd = conn . CreateCommand ( ) )
{
esun_cmd . CommandText = mac_sql ;
esun_cmd . CommandTimeout = 0 ;
using ( var esun_reader = await esun_cmd . ExecuteReaderAsync ( ) )
{
if ( esun_reader . HasRows )
{
findFlag = true ;
List < dynamic > esun_list = new List < dynamic > ( ) ;
DataTable esun_table = new DataTable ( ) ;
esun_table = DataReaderToDataTable ( esun_reader ) ;
if ( esun_table ! = null )
{
WriteTraceLog ( "query mac by mb trace 005:esun_talbe rows qty:" + esun_table . Rows . Count ) ;
}
if ( esun_table . Rows . Count > 0 )
{
if ( createMacCol )
{
for ( int m = 0 ; m < esun_table . Rows . Count ; m + + )
{
if ( dtItem . Rows . Count = = 1 )
{
try
{
dtBarcode . Columns . Add ( "KP_" + kp_no + "#MAC" + ( m + 1 ) . ToString ( ) ) ;
}
catch { }
}
else
{
try
{
dtBarcode . Columns . Add ( "KP_" + kp_no + "#" + ( k + 1 ) . ToString ( ) + "_MAC" + ( m + 1 ) . ToString ( ) ) ;
}
catch { }
}
}
dtBarcode . AcceptChanges ( ) ;
createMacCol = false ;
}
WriteTraceLog ( "query mac by mb trace 006" ) ;
string mac = "" ;
for ( int m = 0 ; m < esun_table . Rows . Count ; m + + )
{
//mac = esun_table.Rows[m]["part_barcode"].ToString().Trim();
mac = esun_table . Rows [ m ] [ "PARTBARCODE" ] . ToString ( ) . Trim ( ) ;
if ( dtItem . Rows . Count = = 1 )
{
dtBarcode . Rows [ i ] [ "KP_" + kp_no + "#MAC" + ( m + 1 ) . ToString ( ) ] = mac ;
}
else
{
dtBarcode . Rows [ i ] [ "KP_" + kp_no + "#" + ( k + 1 ) . ToString ( ) + "_MAC" + ( m + 1 ) . ToString ( ) ] = mac ;
}
dtBarcode . AcceptChanges ( ) ;
}
WriteTraceLog ( "query mac by mb trace 007" ) ;
}
}
}
}
//从barcode_item读取结转数据
if ( ! findFlag )
{
string mac_sql2 = string . Format ( "select a.part_no from jhames.barcode_item a,jhames.barcode_info b where a.barcode_id = b.barcode_id and b.barcode_no = '{0}' and item_no like 'MAC%'" , part_no ) ;
using ( var esun_cmd = conn . CreateCommand ( ) )
{
esun_cmd . CommandText = mac_sql2 ;
esun_cmd . CommandTimeout = 0 ;
using ( var esun_reader = await esun_cmd . ExecuteReaderAsync ( ) )
{
if ( esun_reader . HasRows )
{
findFlag = true ;
List < dynamic > esun_list = new List < dynamic > ( ) ;
DataTable esun_table = new DataTable ( ) ;
esun_table = DataReaderToDataTable ( esun_reader ) ;
if ( esun_table ! = null )
{
WriteTraceLog ( "query mac by mb trace 005:esun_talbe rows qty:" + esun_table . Rows . Count ) ;
}
if ( esun_table . Rows . Count > 0 )
{
if ( createMacCol )
{
for ( int m = 0 ; m < esun_table . Rows . Count ; m + + )
{
if ( dtItem . Rows . Count = = 1 )
{
try
{
dtBarcode . Columns . Add ( "KP_" + kp_no + "#MAC" + ( m + 1 ) . ToString ( ) ) ;
}
catch { }
}
else
{
try
{
dtBarcode . Columns . Add ( "KP_" + kp_no + "#" + ( k + 1 ) . ToString ( ) + "_MAC" + ( m + 1 ) . ToString ( ) ) ;
}
catch { }
}
}
dtBarcode . AcceptChanges ( ) ;
createMacCol = false ;
}
string mac = "" ;
for ( int m = 0 ; m < esun_table . Rows . Count ; m + + )
{
//mac = esun_table.Rows[m]["part_barcode"].ToString().Trim();
mac = esun_table . Rows [ m ] [ "PART_NO" ] . ToString ( ) . Trim ( ) ;
if ( dtItem . Rows . Count = = 1 )
{
dtBarcode . Rows [ i ] [ "KP_" + kp_no + "#MAC" + ( m + 1 ) . ToString ( ) ] = mac ;
}
else
{
dtBarcode . Rows [ i ] [ "KP_" + kp_no + "#" + ( k + 1 ) . ToString ( ) + "_MAC" + ( m + 1 ) . ToString ( ) ] = mac ;
}
dtBarcode . AcceptChanges ( ) ;
}
}
}
}
}
}
}
}
catch ( Exception e1 )
{
string err = e1 . Message ;
WriteTraceLog ( "query mac by mb trace 999:" + e1 . Message ) ;
}
}
dtBarcode . AcceptChanges ( ) ;
}