@ -200,37 +200,46 @@ namespace ICSSoft.DataProject
/// <param name="Quantity"></param>
/// <param name="WorkPoint"></param>
/// <param name="cmd"></param>
public static void MOApply ( string TransCode , string TransSequence , string Quantity , string WorkPoint , SqlCommand cmd , Dictionary < string , string > language )
public static void MOApply ( string TransCode , string TransSequence , string Quantity , string WorkPoint , string userCode , SqlCommand cmd , Dictionary < string , string > language )
{
try
{
string sql = @ "DECLARE @Status VARCHAR(10)
SELECT @Status = a . Status FROM ICSMOApply a
WHERE a . ApplyCode = ' { 0 } ' AND a . Sequence = ' { 3 } ' AND a . WorkPoint = ' { 1 } '
//string sql = @ "DECLARE @Status VARCHAR(10)
// SELECT @Status=a.Status FROM ICSMOApply a
// WHERE a .ApplyCode= '{0}' AND a .Sequence= '{3}' AND a .WorkPoint= '{1}'
IF ( @Status IS NULL )
BEGIN
RAISERROR ( ' " + language.GetNameByCode(" WMSAPIInfo128 ") + @" ' , 1 6 , 1 ) ;
RETURN
END
ELSE IF ( @Status ! = '2' )
BEGIN
RAISERROR ( ' " + language.GetNameByCode(" WMSAPIInfo129 ") + @" ' , 1 6 , 1 ) ;
RETURN
END
UPDATE a SET IssueQuantity = ISNULL ( IssueQuantity , 0 ) + ' { 2 } '
FROM ICSMOApply a
WHERE a . ApplyCode = ' { 0 } ' AND a . Sequence = ' { 3 } ' AND a . WorkPoint = ' { 1 } '
// IF (@Status IS NULL)
// BEGIN
// RAISERROR('" + language.GetNameByCode("WMSAPIInfo128") + @"',16,1);
// RETURN
// END
// ELSE IF (@Status!='2')
// BEGIN
// RAISERROR('" + language.GetNameByCode("WMSAPIInfo129") + @"',16,1);
// RETURN
// END
// UPDATE a SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
// FROM ICSMOApply a
// WHERE a.ApplyCode='{0}' AND a.Sequence='{3}' AND a.WorkPoint='{1}'
// IF EXISTS(SELECT a.ID FROM ICSMOApply a
// WHERE a.ApplyCode='{0}' AND a.Sequence='{3}' and a.WorkPoint='{1}' AND a.Quantity<a.IssueQuantity)
// BEGIN
// RAISERROR('" + language.GetNameByCode("WMSAPIInfo091") + @"',16,1);
// RETURN
// END";
//sql = string.Format(sql, TransCode, WorkPoint, Quantity, TransSequence,userCode);
string sql = $ @ "UPDATE ICSMOApply SET IssueQuantity=ISNULL(IssueQuantity,0)+'{Quantity}',ReceiverNumber='{userCode}',ReceiverName=(SELECT top 1 F_RealName FROM Sys_SRM_User WHERE F_Account='{userCode}' )
WHERE ApplyCode = ' { TransCode } ' AND Sequence = ' { TransSequence } ' AND WorkPoint = ' { WorkPoint } ' ;
IF EXISTS ( SELECT a . ID FROM ICSMOApply a
WHERE a . ApplyCode = ' { 0 } ' AND a . Sequence = ' { 3 } ' and a . WorkPoint = ' { 1 } ' AND a . Quantity < a . IssueQuantity )
WHERE a . ApplyCode = ' { TransCode } ' AND a . Sequence = ' { TransSequence } ' and a . WorkPoint = ' { WorkPoint } ' AND a . Quantity < a . IssueQuantity )
BEGIN
RAISERROR ( ' " + language.GetNameByCode(" WMSAPIInfo091 ") + @" ' , 1 6 , 1 ) ;
RAISERROR ( ' { language . GetNameByCode ( "WMSAPIInfo091" ) } ' , 1 6 , 1 ) ;
RETURN
END ";
sql = string . Format ( sql , TransCode , WorkPoint , Quantity , TransSequence ) ;
if ( ! DBHelper . ExecuteNonQuery ( sql , cmd ) )
{
throw new Exception ( language . GetNameByCode ( "WMSAPIInfo130" ) ) ; //"领料申请单更新失败!");