public static string RetornaDetalleDesdePicking(string NumPicking, string DocEntry, bool SQL)
{
string Query = "";
if (!SQL)
{
Query = string.Format(@" SELECT T1.""ItemCode"",
CASE
WHEN T1.""TreeType"" = 'S' THEN T1.""Quantity""
ELSE T2.""PickQtty""
END as ""PickQty"",
T1.""LineNum"",
T1.""WhsCode"",
T1.""TaxCode"",
T1.""DiscPrcnt"",
T2.""PickEntry"",
T1.""TreeType"",
T1.""Quantity""
FROM ORDR T0
LEFT JOIN RDR1 T1
ON T0.""DocEntry"" = T1.""DocEntry""
LEFT JOIN PKL1 T2
ON T1.""DocEntry"" = T2.""OrderEntry""
AND T1.""LineNum"" = T2.""OrderLine""
AND T1.""LineStatus"" = 'O'
AND T1.""PickOty"" != 0
WHERE T1.""DocEntry"" = '{0}'
AND T2.""AbsEntry"" = '{1}'
OR T1.""DocEntry"" = '{0}'
AND T1.""TreeType"" = 'S'", DocEntry, NumPicking);
}
else
{
Query = string.Format(@" SELECT T1.ItemCode,
CASE
WHEN T1.TreeType = 'S' THEN T1.Quantity
ELSE T2.PickQtty
END as Pickqty,
T1.LineNum,
T1.WhsCode,
T1.TaxCode,
T1.DiscPrcnt,
T2.PickEntry,
T1.TreeType,
T1.Quantity
FROM ORDR T0
LEFT JOIN RDR1 T1
ON T0.DocEntry = T1.DocEntry
LEFT JOIN PKL1 T2
ON T1.DocEntry = T2.OrderEntry
AND T1.LineNum = T2.OrderLine
AND T1.LineStatus = 'O'
AND T1.PickOty != 0
WHERE T1.DocEntry = '{0}'
AND T2.AbsEntry = '{1}'
OR T1.DocEntry = '{0}'
AND T1.TreeType = 'S'", DocEntry, NumPicking);
}
return Query;
}