@ -163,7 +163,7 @@ namespace ICSSoft.DataProject
try
{
#region ERP
string sql = @ "SELECT c.VenCode+a.ToWarehouseCode+c.POCode+a.MUSER+f.DNCode AS Costre,c.VenCode,a.ToWarehouseCode AS WarehouseCode,c.POCode,f.DNCode,a.MUSER,f.Sequence AS DNSequence,ROW_NUMBER() OVER (ORDER BY c.VenCode,a.ToWarehouseCode,c.POCode,c.PODetailID,a.InvCode) AS Sequence,
string sql = @ "SELECT c.VenCode+a.ToWarehouseCode+c.POCode+a.MUSER+CASE WHEN(LEN(f.DNID)>=20) THEN '' ELSE f.DNCode END AS Costre,c.VenCode,a.ToWarehouseCode AS WarehouseCode,c.POCode,CASE WHEN(LEN( f.DNID)>=20) THEN '' ELSE f.DNCode END AS DN Code,CASE WHEN(LEN(f.DNID)>=20) THEN '1' ELSE '0' END AS HasDN, a.MUSER,CASE WHEN(LEN(f.DNID)>=20) THEN '' ELSE f.Sequence END AS DNSequence,ROW_NUMBER() OVER (ORDER BY c.VenCode,a.ToWarehouseCode,c.POCode,c.PODetailID,a.InvCode) AS Sequence,
a . InvCode , SUM ( a . Quantity ) AS Quantity , SUM ( a . Quantity * ( lot . Amount / lot . Quantity ) ) AS Amount , isnull ( ( c . UnitPrice ) , 0 ) as UnitPrice , c . Currency , c . PODetailID , con . Enable AS UpdateTodoQuantity , conn . Enable
, a . WorkPoint , ISNULL ( ext . ProjectCode , ' ' ) AS ProjectCode , CASE WHEN ( invBat . BatchEnable IS NULL AND ISNULL ( inv . BatchEnable , '0' ) = '1' ) OR ISNULL ( invBat . BatchEnable , '0' ) = '1' THEN ISNULL ( ext . BatchCode , ' ' ) ELSE ' ' END AS BatchCode , ISNULL ( ext . Version , ' ' ) AS Version , ISNULL ( ext . Brand , ' ' ) AS Brand ,
ISNULL ( ext . cFree1 , ' ' ) AS cFree1 , ISNULL ( ext . cFree2 , ' ' ) AS cFree2 , ISNULL ( ext . cFree3 , ' ' ) AS cFree3 , ISNULL ( ext . cFree4 , ' ' ) AS cFree4 , ISNULL ( ext . cFree5 , ' ' ) AS cFree5 , ISNULL ( ext . cFree6 , ' ' ) AS cFree6 , ISNULL ( ext . cFree7 , ' ' ) AS cFree7 , ISNULL ( ext . cFree8 , ' ' ) AS cFree8 , ISNULL ( ext . cFree9 , ' ' ) AS cFree9 , ISNULL ( ext . cFree10 , ' ' ) AS cFree10
@ -180,19 +180,65 @@ namespace ICSSoft.DataProject
INNER JOIN ICSConfiguration con ON con . Code = ' Stock001 ' AND a . WorkPoint = con . WorkPoint
INNER JOIN ICSConfiguration conn ON con . WorkPoint = conn . WorkPoint AND conn . Code = ' Escrow001 '
WHERE a . Identification = ' { 0 } ' AND ERPUpload = '0' AND BusinessCode = ' { 1 } '
GROUP BY c . VenCode , a . ToWarehouseCode , c . POCode , f . DNCode , a . MUSER , a . InvCode , f . Sequence , c . PODetailID , isnull ( ( c . UnitPrice ) , 0 ) , c . Currency , con . Enable , conn . Enable
GROUP BY c . VenCode , a . ToWarehouseCode , c . POCode , CASE WHEN ( LEN ( f . DNID ) > = 2 0 ) THEN ' ' ELSE f . DNCode END , f . DNID , a . MUSER , a . InvCode , CASE WHEN ( LEN ( f . DNID ) > = 2 0 ) THEN ' ' ELSE f . Sequence END , c . PODetailID , isnull ( ( c . UnitPrice ) , 0 ) , c . Currency , con . Enable , conn . Enable
, a . WorkPoint , ISNULL ( ext . ProjectCode , ' ' ) , CASE WHEN ( invBat . BatchEnable IS NULL AND ISNULL ( inv . BatchEnable , '0' ) = '1' ) OR ISNULL ( invBat . BatchEnable , '0' ) = '1' THEN ISNULL ( ext . BatchCode , ' ' ) ELSE ' ' END , ISNULL ( ext . Version , ' ' ) , ISNULL ( ext . Brand , ' ' ) ,
ISNULL ( ext . cFree1 , ' ' ) , ISNULL ( ext . cFree2 , ' ' ) , ISNULL ( ext . cFree3 , ' ' ) , ISNULL ( ext . cFree4 , ' ' ) , ISNULL ( ext . cFree5 , ' ' ) , ISNULL ( ext . cFree6 , ' ' ) , ISNULL ( ext . cFree7 , ' ' ) , ISNULL ( ext . cFree8 , ' ' ) , ISNULL ( ext . cFree9 , ' ' ) , ISNULL ( ext . cFree10 , ' ' )
SELECT DISTINCT Costre , WorkPoint , VenCode , WarehouseCode AS WHCode , POCode , DNCode , MUSER AS [ User ] , SYSDATETIME ( ) AS MTime , Enable , UpdateTodoQuantity FROM # TempERP
SELECT Costre , Sequence , DNSequence , InvCode , Quantity , Amount , PODetailID , Currency , UnitPrice , ProjectCode , BatchCode , Version , Brand , cFree1 , cFree2 , cFree3 , cFree4 , cFree5 , cFree6 , cFree7 , cFree8 , cFree9 , cFree10
FROM # TempERP
SELECT HasDN FROM # TempERP
DROP TABLE # TempERP ";
sql = string . Format ( sql , Identification , BusinessCode ) ;
DataSet ds = DBHelper . SQlReturnDataSet ( sql , cmd ) ;
string Inputstr = DataToJsonHelper . DataSetToJson ( ds , "details" , "Costre" ) ;
var IsDNCode = ds . Tables [ 2 ] ;
if ( IsDNCode = = null | | IsDNCode . Rows . Count ! = 1 )
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo463" ) ) ; //ERP到货单只能选择启用或不启用中的一种!
}
string dncode = Convert . ToString ( IsDNCode . Rows [ 0 ] [ "HasDN" ] ) ;
if ( dncode . Equals ( "" ) )
{
string resultStr = HTTPHelper . HttpPost ( TransType , ERPUrl . DeliveryNoticeURL , Inputstr ) ;
Result result = new Result ( ) ;
result = JsonConvert . DeserializeObject < Result > ( resultStr ) ;
if ( result . Success )
{
try
{
JArray res = ( JArray ) JsonConvert . DeserializeObject ( result . Data . ToString ( ) ) ;
foreach ( var item in res )
{
JObject jo = ( JObject ) item ;
JArray resdetail = ( JArray ) JsonConvert . DeserializeObject ( jo [ "details" ] . ToString ( ) ) ;
foreach ( var detail in resdetail )
{
JObject det = ( JObject ) detail ;
string allcol = jo [ "cWhCode" ] . ToString ( ) + det [ "ProjectCode" ] . ToString ( ) + det [ "cBatch" ] . ToString ( ) + det [ "version" ] . ToString ( ) + det [ "brand" ] . ToString ( ) + det [ "cFree1" ] . ToString ( ) + det [ "cFree2" ] . ToString ( ) + det [ "cFree3" ] . ToString ( ) + det [ "cFree4" ] . ToString ( ) + det [ "cFree5" ] . ToString ( )
+ det [ "cFree6" ] . ToString ( ) + det [ "cFree7" ] . ToString ( ) + det [ "cFree8" ] . ToString ( ) + det [ "cFree9" ] . ToString ( ) + det [ "cFree10" ] . ToString ( ) ;
ICSWareHouseLotInfoService . WareHouseLotInfoLogUpdate ( TransType , det [ "DNDetailID" ] . ToString ( ) , Identification , jo [ "ID" ] . ToString ( ) ,
det [ "DetailID" ] . ToString ( ) , jo [ "RCVTCode" ] . ToString ( ) , det [ "Sequence" ] . ToString ( ) , allcol , cmd , language , BusinessCode ) ;
}
}
}
catch ( Exception ex )
{
log . Debug ( ex . ToString ( ) ) ;
log . Debug ( resultStr ) ;
}
}
else
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo080" ) + result . Message ) ;
}
}
else
{
string resultStr = HTTPHelper . HttpPost ( TransType , ERPUrl . PurchaseOrderURL , Inputstr ) ;
Result result = new Result ( ) ;
result = JsonConvert . DeserializeObject < Result > ( resultStr ) ;
@ -223,8 +269,10 @@ namespace ICSSoft.DataProject
}
else
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo080" ) + result . Message ) ;
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo080" ) + result . Message ) ;
}
}
#endregion
}
catch ( Exception )
@ -298,8 +346,8 @@ namespace ICSSoft.DataProject
try
{
#region ERP
string sql = @ "SELECT c.VenCode+a.ToWarehouseCode+c.DNCode+a.MUSER AS Costre,c.VenCode,a.ToWarehouseCode AS WarehouseCode,c.DNCode,a.MUSER,ROW_NUMBER() OVER (ORDER BY c.VenCode,a.ToWarehouseCode,c.DN Code,c.DNDetailID,a.InvCode) AS Sequence,
a . InvCode , SUM ( a . Quantity ) AS Quantity , SUM ( a . Quantity * ( lot . Amount / lot . Quantity ) ) AS Amount , isnull ( ( c . UnitPrice ) , 0 ) as UnitPrice , c . Currency , c . DNDetailID , con . Enable AS UpdateTodoQuantity , conn . Enable
string sql = @ "SELECT c.VenCode+a.ToWarehouseCode+c.DNCode+a.MUSER AS Costre,c.VenCode,a.ToWarehouseCode AS WarehouseCode,c.DNCode ,a.MUSER,ROW_NUMBER() OVER (ORDER BY c.VenCode,a.ToWarehouseCode,c.DNDetailID,a.InvCode) AS Sequence,
a . InvCode , SUM ( a . Quantity ) AS Quantity , 0 AS Amount , isnull ( ( c . UnitPrice ) , 0 ) as UnitPrice , c . Currency , c . DNDetailID , Enable AS UpdateTodoQuantity
, a . WorkPoint , ISNULL ( ext . ProjectCode , ' ' ) AS ProjectCode , CASE WHEN ( invBat . BatchEnable IS NULL AND ISNULL ( inv . BatchEnable , '0' ) = '1' ) OR ISNULL ( invBat . BatchEnable , '0' ) = '1' THEN ISNULL ( ext . BatchCode , ' ' ) ELSE ' ' END AS BatchCode , ISNULL ( ext . Version , ' ' ) AS Version , ISNULL ( ext . Brand , ' ' ) AS Brand ,
ISNULL ( ext . cFree1 , ' ' ) AS cFree1 , ISNULL ( ext . cFree2 , ' ' ) AS cFree2 , ISNULL ( ext . cFree3 , ' ' ) AS cFree3 , ISNULL ( ext . cFree4 , ' ' ) AS cFree4 , ISNULL ( ext . cFree5 , ' ' ) AS cFree5 , ISNULL ( ext . cFree6 , ' ' ) AS cFree6 , ISNULL ( ext . cFree7 , ' ' ) AS cFree7 , ISNULL ( ext . cFree8 , ' ' ) AS cFree8 , ISNULL ( ext . cFree9 , ' ' ) AS cFree9 , ISNULL ( ext . cFree10 , ' ' ) AS cFree10
INTO # TempERP
@ -311,21 +359,21 @@ namespace ICSSoft.DataProject
INNER JOIN ICSInventoryLotDetail b ON a . LotNo = b . LotNo AND a . WorkPoint = b . WorkPoint
INNER JOIN ICSDeliveryNotice c ON b . TransCode = c . DNCode AND b . TransSequence = c . Sequence AND b . WorkPoint = c . WorkPoint
INNER JOIN ICSConfiguration con ON con . Code = ' Stock001 ' AND a . WorkPoint = con . WorkPoint
INNER JOIN ICSConfiguration conn ON con . WorkPoint = conn . WorkPoint AND conn . Code = ' Escrow001 '
WHERE a . Identification = ' { 0 } ' AND ERPUpload = '0' AND BusinessCode = ' { 1 } '
GROUP BY c . VenCode , a . ToWarehouseCode , c . DNCode , a . MUSER , a . InvCode , c . DNDetailID , isnull ( ( c . UnitPrice ) , 0 ) , c . Currency , con . Enable , conn . Enable
WHERE a . Identification = ' { 0 } ' AND ERPUpload = '0'
GROUP BY c . VenCode , a . ToWarehouseCode , c . DNCode , c . DNID , a . MUSER , a . InvCode , c . DNDetailID , isnull ( ( c . UnitPrice ) , 0 ) , c . Currency , Enable
, a . WorkPoint , ISNULL ( ext . ProjectCode , ' ' ) , CASE WHEN ( invBat . BatchEnable IS NULL AND ISNULL ( inv . BatchEnable , '0' ) = '1' ) OR ISNULL ( invBat . BatchEnable , '0' ) = '1' THEN ISNULL ( ext . BatchCode , ' ' ) ELSE ' ' END , ISNULL ( ext . Version , ' ' ) , ISNULL ( ext . Brand , ' ' ) ,
ISNULL ( ext . cFree1 , ' ' ) , ISNULL ( ext . cFree2 , ' ' ) , ISNULL ( ext . cFree3 , ' ' ) , ISNULL ( ext . cFree4 , ' ' ) , ISNULL ( ext . cFree5 , ' ' ) , ISNULL ( ext . cFree6 , ' ' ) , ISNULL ( ext . cFree7 , ' ' ) , ISNULL ( ext . cFree8 , ' ' ) , ISNULL ( ext . cFree9 , ' ' ) , ISNULL ( ext . cFree10 , ' ' )
SELECT DISTINCT Costre , WorkPoint , VenCode , WarehouseCode AS WHCode , DNCode , MUSER AS [ User ] , SYSDATETIME ( ) AS MTime , Enable , UpdateTodoQuantity FROM # TempERP
SELECT DISTINCT Costre , WorkPoint , VenCode , WarehouseCode AS WHCode , DNCode , MUSER AS [ User ] , SYSDATETIME ( ) AS MTime , UpdateTodoQuantity FROM # TempERP
SELECT Costre , Sequence , InvCode , Quantity , Amount , DNDetailID , Currency , UnitPrice , ProjectCode , BatchCode , Version , Brand , cFree1 , cFree2 , cFree3 , cFree4 , cFree5 , cFree6 , cFree7 , cFree8 , cFree9 , cFree10
FROM # TempERP
DROP TABLE # TempERP ";
sql = string . Format ( sql , Identification , BusinessCode ) ;
DataSet ds = DBHelper . SQlReturnDataSet ( sql , cmd ) ;
string Inputstr = DataToJsonHelper . DataSetToJson ( ds , "details" , "Costre" ) ;
string resultStr = HTTPHelper . HttpPost ( TransType , ERPUrl . DeliveryNoticeURL , Inputstr ) ;
Result result = new Result ( ) ;
result = JsonConvert . DeserializeObject < Result > ( resultStr ) ;
@ -344,7 +392,7 @@ namespace ICSSoft.DataProject
string allcol = jo [ "cWhCode" ] . ToString ( ) + det [ "ProjectCode" ] . ToString ( ) + det [ "cBatch" ] . ToString ( ) + det [ "version" ] . ToString ( ) + det [ "brand" ] . ToString ( ) + det [ "cFree1" ] . ToString ( ) + det [ "cFree2" ] . ToString ( ) + det [ "cFree3" ] . ToString ( ) + det [ "cFree4" ] . ToString ( ) + det [ "cFree5" ] . ToString ( )
+ det [ "cFree6" ] . ToString ( ) + det [ "cFree7" ] . ToString ( ) + det [ "cFree8" ] . ToString ( ) + det [ "cFree9" ] . ToString ( ) + det [ "cFree10" ] . ToString ( ) ;
ICSWareHouseLotInfoService . WareHouseLotInfoLogUpdate ( TransType , det [ "DNDetailID" ] . ToString ( ) , Identification , jo [ "ID" ] . ToString ( ) ,
det [ "DetailID" ] . ToString ( ) , jo [ "RCVTCode" ] . ToString ( ) , det [ "Sequence" ] . ToString ( ) , allcol , cmd , language , BusinessCode ) ;
det [ "DetailID" ] . ToString ( ) , jo [ "RCVTCode" ] . ToString ( ) , det [ "Sequence" ] . ToString ( ) , allcol , cmd , language , BusinessCode ) ;
}
}
}
@ -356,8 +404,11 @@ namespace ICSSoft.DataProject
}
else
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo080" ) + result . Message ) ;
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo080" ) + result . Message ) ;
}
#endregion
}
catch ( Exception )