@ -968,7 +968,7 @@ namespace ICSSoft.DataProject
public static DataTable WareHouseLotInfoTransfer ( string Identification , string TransCode , string TransSequence , string WarehouseCode , string LocationCode ,
string LotNo , string Quantity , string User , string WorkPoint , string TransType , string BusinessCode , SqlCommand cmd , Dictionary < string , string > language , string MergeID )
{
String LotEnable = "" ;
bool? LotEnable = null ;
String PrintEnable = "" ;
string lotstr = "" ;
int result = 0 ;
@ -977,6 +977,25 @@ namespace ICSSoft.DataProject
List < string > NewBarCodeList = new List < string > ( ) ;
try
{
var tranferWorkpoint = string . Empty ;
var checksql = $ @ "SELECT
top 1 a . EATTRIBUTE1
FROM
ICSTransfer a
WHERE
TransferNO = ' { TransCode } '
AND Sequence = ' { TransSequence } '
AND WorkPoint = ' { WorkPoint } '
AND Type = ' { TransType } ' ";
var workPoint = DBHelper . ExecuteScalar ( checksql , cmd ) ;
if ( workPoint = = null )
{
tranferWorkpoint = WorkPoint ;
}
else
{
tranferWorkpoint = workPoint . ToString ( ) ;
}
//检验是否分批
string sql = @ "SELECT b.LotEnable,b.PrintEnable FROM ICSInventoryLot a
LEFT JOIN ICSInventory b ON a . InvCode = b . InvCode AND a . WorkPoint = b . WorkPoint
@ -990,26 +1009,12 @@ namespace ICSSoft.DataProject
}
else
{
LotEnable = dt . Rows [ 0 ] [ "LotEnable" ] . ToString ( ) ;
LotEnable = dt . Rows [ 0 ] [ "LotEnable" ] as bool? ;
PrintEnable = dt . Rows [ 0 ] [ "PrintEnable" ] . ToString ( ) ;
}
if ( ! LotEnable . Equals ( "False" ) )
if ( LotEnable = = true )
{
///更新库存
sql = @ "UPDATE ICSWareHouseLotInfo SET Quantity=ISNULL(Quantity,0)-'{2}' WHERE LotNo='{0}' AND WorkPoint='{1}'
IF EXISTS ( SELECT a . LotNo FROM ICSWareHouseLotInfo a WHERE a . LotNo = ' { 0 } ' AND a . WorkPoint = ' { 1 } ' AND Quantity < 0 )
BEGIN
RAISERROR ( ' " + language.GetNameByCode(" WMSAPIInfo167 ") + @" ' , 1 6 , 1 ) ;
RETURN
END ";
sql = string . Format ( sql , LotNo , WorkPoint , Quantity ) ;
if ( ! DBHelper . ExecuteNonQuery ( sql , cmd ) )
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo168" ) ) ; //"库存更新失败!");
}
///分批前添加日志
sql = @ "IF NOT EXISTS(SELECT F_Account FROM Sys_SRM_User WHERE F_Account='{2}' AND F_Location='{1}')
@ -1027,23 +1032,41 @@ namespace ICSSoft.DataProject
c . WarehouseCode , c . LocationCode , ' ',' ' , c . Quantity + { 6 } ,
' ',' 0 ',' { 4 } ',' 3 1 ',' 0 ',' ' ,
' ',' ',' ' , f . F_Account , f . F_RealName ,
SYSDATETIME ( ) , a . WorkPoint , ' '
SYSDATETIME ( ) , ' { 9 } ' , ' '
FROM ICSInventoryLot a
INNER JOIN ICSInventoryLotDetail b ON a . LotNo = b . LotNo AND a . WorkPoint = b . WorkPoint
INNER JOIN ICSWareHouseLotInfo c ON a . LotNo = c . LotNo AND a . WorkPoint = c . WorkPoint
INNER JOIN Sys_SRM_User f ON f . F_Account = ' { 2 } ' AND a . WorkPoint = f . F_Location
WHERE a . LotNo = ' { 0 } ' AND a . WorkPoint = ' { 1 } '
";
sql = string . Format ( sql , LotNo , WorkPoint , User , Identification , TransType , BusinessCode , Quantity , TransCode , TransSequence ) ;
sql = string . Format ( sql , LotNo , WorkPoint , User , Identification , TransType , BusinessCode , Quantity , TransCode , TransSequence , tranferWorkpoint ) ;
if ( ! DBHelper . ExecuteNonQuery ( sql , cmd ) )
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo166" ) ) ;
}
///更新库存
sql = @ "UPDATE ICSWareHouseLotInfo SET Quantity=ISNULL(Quantity,0)-'{2}',LocationCode = '{3}',
WorkPoint = ' { 4 } ' WHERE LotNo = ' { 0 } ' AND WorkPoint = ' { 1 } ' ;
UPDATE ICSInventoryLot SET WorkPoint = ' { 4 } ' WHERE LotNo = ' { 0 } ' AND WorkPoint = ' { 1 } ' ;
IF EXISTS ( SELECT a . LotNo FROM ICSWareHouseLotInfo a WHERE a . LotNo = ' { 0 } ' AND a . WorkPoint = ' { 1 } ' AND Quantity < 0 )
BEGIN
RAISERROR ( ' " + language.GetNameByCode(" WMSAPIInfo167 ") + @" ' , 1 6 , 1 ) ;
RETURN
END ";
sql = string . Format ( sql , LotNo , WorkPoint , Quantity , LocationCode , tranferWorkpoint ) ;
if ( ! DBHelper . ExecuteNonQuery ( sql , cmd ) )
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo168" ) ) ; //"库存更新失败!");
}
#region 获取分批后的条码(lotstr)
sql = @ "SELECT TOP 1 LotNO FROM ICSInventoryLot WHERE EATTRIBUTE1='{0}' AND WorkPoint='{1}'
ORDER BY CAST ( SUBSTRING ( LotNO , ( LEN ( LotNO ) - CHARINDEX ( '-' , REVERSE ( LotNO ) ) + 1 ) + 1 , CHARINDEX ( '-' , REVERSE ( LotNO ) ) - 1 ) AS INT ) DESC ";
sql = string . Format ( sql , LotNo , WorkPoint ) ;
sql = string . Format ( sql , LotNo , tranferWorkp oint) ;
dt = DBHelper . SQlReturnData ( sql , cmd ) ;
if ( dt . Rows . Count = = 0 )
{
@ -1064,10 +1087,10 @@ namespace ICSSoft.DataProject
SELECT TOP 1 NEWID ( ) , ' { 0 } ' , a . InvCode , a . ProductDate , a . ExpirationDate ,
' { 2 } ' , a . Amount , a . ExtensionID , a . Type , a . PrintTimes ,
a . LastPrintUser , a . LastPrintTime , a . MUSER , a . MUSERName , GETDATE ( ) ,
a . WorkPoint , ' { 1 } '
' { 3 } ' , ' { 1 } '
From ICSInventoryLot a
where a . LotNo = ' { 1 } ' and a . WorkPoint = ' { 3 } ' ";
sql = string . Format ( sql , lotstr , LotNo , Quantity , WorkP oint) ;
sql = string . Format ( sql , lotstr , LotNo , Quantity , tranferWorkp oint) ;
cmd . CommandText = sql ;
result = cmd . ExecuteNonQuery ( ) ;
if ( result < = 0 )
@ -1076,11 +1099,11 @@ namespace ICSSoft.DataProject
}
#endregion
sql = @ "INSERT INTO ICSWareHouseLotInfo(ID,LotNO,WarehouseCode,LocationCode,InvCode,Quantity,InDate,LockQuantity,MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1)
select NEWID ( ) , ' { 0 } ',' { 4 } ',' { 5 } ' , InvCode , ' { 2 } ' , InDate , LockQuantity
select NEWID ( ) , ' { 0 } ',' { 4 } ',' { 3 } ' , InvCode , ' { 2 } ' , InDate , LockQuantity
, MUSER , MUSERName , GETDATE ( ) , ' { 3 } ',' '
from ICSWareHouseLotInfo
where LotNO = ' { 1 } ' AND WorkPoint = ' { 3 } ' ";
sql = string . Format ( sql , lotstr , LotNo , Quantity , WorkPoint , WarehouseCode , LocationCode ) ;
sql = string . Format ( sql , lotstr , LotNo , Quantity , tranferWorkpoint , WarehouseCode , LocationCode ) ;
cmd . CommandText = sql ;
result = cmd . ExecuteNonQuery ( ) ;
if ( result < = 0 )
@ -1089,12 +1112,12 @@ namespace ICSSoft.DataProject
}
//插入条码单据表
sql = @ "INSERT INTO ICSInventoryLotDetail(LotNo,TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
SELECT ' { 3 } ' , b . TransCode , b . TransSequence , f . F_Account , f . F_RealName , SYSDATETIME ( ) , a . WorkPoint
SELECT ' { 0 } ' , b . TransCode , b . TransSequence , f . F_Account , f . F_RealName , SYSDATETIME ( ) , ' { 1 } '
FROM ICSInventoryLot a
INNER JOIN ICSInventoryLotDetail b ON a . LotNo = b . LotNo AND a . WorkPoint = b . WorkPoint
INNER JOIN Sys_SRM_User f ON f . F_Account = ' { 2 } ' AND a . WorkPoint = f . F_Location
WHERE a . LotNo = ' { 0 } ' AND a . WorkPoint = ' { 1 } ' ";
sql = string . Format ( sql , LotNo , WorkP oint, User , lotst r ) ;
sql = string . Format ( sql , lotstr , tranferWorkp oint, User ) ;
if ( ! DBHelper . ExecuteNonQuery ( sql , cmd ) )
{
@ -1109,13 +1132,13 @@ namespace ICSSoft.DataProject
c . WarehouseCode , c . LocationCode , ' { 1 1 } ',' { 1 2 } ',' { 6 } ' ,
' ',' 0 ',' { 7 } ',' { 8 } ',' 0 ',' ' ,
' ',' ',' ' , f . F_Account , f . F_RealName ,
SYSDATETIME ( ) , a . WorkPoint , ' ',' { 9 } '
SYSDATETIME ( ) , ' { 1 } ' , ' ',' { 9 } '
FROM ICSInventoryLot a
INNER JOIN ICSWareHouseLotInfo c ON a . LotNo = c . LotNo AND a . WorkPoint = c . WorkPoint
INNER JOIN Sys_SRM_User f ON f . F_Account = ' { 2 } ' AND a . WorkPoint = f . F_Location
WHERE a . LotNo = ' { 0 } ' AND a . WorkPoint = ' { 1 } '
";
sql = string . Format ( sql , LotNo , WorkP oint, User , Identification , TransCode , TransSequence , Quantity , TransType , BusinessCode , MergeID , lotstr , WarehouseCode , LocationCode ) ;
sql = string . Format ( sql , LotNo , tranferWorkp oint, User , Identification , TransCode , TransSequence , Quantity , TransType , BusinessCode , MergeID , lotstr , WarehouseCode , LocationCode ) ;
cmd . CommandText = sql ;
result = cmd . ExecuteNonQuery ( ) ;
if ( result < = 0 )
@ -1138,13 +1161,13 @@ namespace ICSSoft.DataProject
c . WarehouseCode , c . LocationCode , ' ',' ' , c . Quantity ,
' ',' 0 ',' { 7 } ',' 3 2 ',' 0 ',' ' ,
' ',' ',' ' , f . F_Account , f . F_RealName ,
SYSDATETIME ( ) , a . WorkPoint , ' ',' { 9 } '
SYSDATETIME ( ) , ' { 1 0 } ' , ' ',' { 9 } '
FROM ICSInventoryLot a
INNER JOIN ICSWareHouseLotInfo c ON a . LotNo = c . LotNo AND a . WorkPoint = c . WorkPoint
INNER JOIN Sys_SRM_User f ON f . F_Account = ' { 2 } ' AND a . WorkPoint = f . F_Location
WHERE a . LotNo = ' { 0 } ' AND a . WorkPoint = ' { 1 } '
";
sql = string . Format ( sql , LotNo , WorkP oint, User , Identification , TransCode , TransSequence , Quantity , TransType , BusinessCode , MergeID ) ;
sql = string . Format ( sql , LotNo , tranferWorkp oint, User , Identification , TransCode , TransSequence , Quantity , TransType , BusinessCode , MergeID , tranferWorkpoint ) ;
if ( ! DBHelper . ExecuteNonQuery ( sql , cmd ) )
{
@ -1160,7 +1183,7 @@ namespace ICSSoft.DataProject
where a . BusinessCode = ' 1 0 5 '
and A . lotno like ' { 0 } % ' and a . workpoint = ' { 1 } '
";
sql = string . Format ( sql , LotNo , WorkP oint) ;
sql = string . Format ( sql , LotNo , tranferWorkp oint) ;
dtLotno = DBHelper . SQlReturnData ( sql , cmd ) ;
lstDt = dtLotno ;
}
@ -1189,13 +1212,13 @@ namespace ICSSoft.DataProject
c . WarehouseCode , c . LocationCode , ' { 9 } ',' { 1 0 } ' , { 6 } ,
' ',' 0 ',' { 7 } ',' { 8 } ',' 0 ',' ' ,
' ',' ',' ' , f . F_Account , f . F_RealName ,
SYSDATETIME ( ) , a . WorkPoint , ' ',' { 1 1 } '
SYSDATETIME ( ) , ' { 1 2 } ' , ' ',' { 1 1 } '
FROM ICSInventoryLot a
INNER JOIN ICSWareHouseLotInfo c ON a . LotNo = c . LotNo AND a . WorkPoint = c . WorkPoint
INNER JOIN Sys_SRM_User f ON f . F_Account = ' { 2 } ' AND a . WorkPoint = f . F_Location
WHERE a . LotNo = ' { 0 } ' AND a . WorkPoint = ' { 1 } '
";
sql = string . Format ( sql , LotNo , WorkPoint , User , Identification , TransCode , TransSequence , Quantity , TransType , BusinessCode , WarehouseCode , LocationCode , MergeID ) ;
sql = string . Format ( sql , LotNo , WorkPoint , User , Identification , TransCode , TransSequence , Quantity , TransType , BusinessCode , WarehouseCode , LocationCode , MergeID , tranferWorkpoint ) ;
if ( ! DBHelper . ExecuteNonQuery ( sql , cmd ) )
{
@ -1210,48 +1233,18 @@ namespace ICSSoft.DataProject
// RAISERROR('" + language.GetNameByCode("WMSAPIInfo167") + @"',16,1);
// RETURN
// END";
sql = $ @ "DECLARE @EATTRIBUTE INT;
SELECT
@EATTRIBUTE = a . EATTRIBUTE1
FROM
ICSTransfer a
WHERE
TransferNO = ' { TransCode } '
AND Sequence = ' { TransSequence } '
AND WorkPoint = ' { WorkPoint } '
AND Type = ' { TransType } ' ;
IF
@EATTRIBUTE IS NULL BEGIN
UPDATE ICSWareHouseLotInfo
SET WareHouseCode = ' { WarehouseCode } ' ,
LocationCode = ' { LocationCode } '
WHERE
LotNo = ' { LotNo } '
AND WorkPoint = ' { WorkPoint } ' ;
END
ELSE IF @EATTRIBUTE = ' '
BEGIN
UPDATE ICSWareHouseLotInfo
SET WareHouseCode = ' { WarehouseCode } ' ,
LocationCode = ' { LocationCode } '
WHERE
LotNo = ' { LotNo } '
AND WorkPoint = ' { WorkPoint } ' ;
END
ELSE BEGIN
UPDATE ICSWareHouseLotInfo
sql = $ @ "UPDATE ICSWareHouseLotInfo
SET WareHouseCode = ' { WarehouseCode } ' ,
LocationCode = ' { LocationCode } ' ,
WorkPoint = @EATTRIBUTE
WorkPoint = ' { tranferWorkpoint } '
WHERE
LotNo = ' { LotNo } '
AND WorkPoint = ' { WorkPoint } ' ;
END
UPDATE ICSInventoryLot SET WorkPoint = ' { tranferWorkpoint } ' WHERE LotNo = ' { LotNo } ' AND WorkPoint = ' { WorkPoint } ' ;
IF EXISTS ( SELECT a . LotNo FROM ICSWareHouseLotInfo a WHERE a . LotNo = ' { LotNo } ' AND a . WorkPoint = ' { WorkPoint } ' AND Quantity < 0 ) BEGIN
RAISERROR ( ' { language . GetNameByCode ( "WMSAPIInfo167" ) } ' , 1 6 , 1 ) ;
RETURN END ; ";
sql = string . Format ( sql , LotNo , WorkPoint , WarehouseCode , LocationCode , TransCode , TransSequence , TransType ) ;
//sql = string.Format(sql, LotNo, WorkPoint, WarehouseCode, LocationCode, TransCode, TransSequence, TransType);
if ( ! DBHelper . ExecuteNonQuery ( sql , cmd ) )
{