You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

570 lines
30 KiB

using NFine.Data.Extensions;
using System;
using NFine.Repository;
using NFine.Domain._03_Entity.SRM;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace NFine.Application.WMS
{
public class RevokeBusinessApp : RepositoryFactory<ICSVendor>
{
//采购入库撤销
public string RevocationPurchase(string keyValue)
{
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
string msg = "";
string sql = string.Empty;
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
foreach (var item in res)
{
JObject jo = (JObject)item;
sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}' ", jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@"update ICSPurchaseOrder set InQuantity =InQuantity-'{0}' where POCode='{1}' and Sequence='{2}' and WorkPoint='{3}'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
}
try
{
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
{
}
}
catch (Exception ex)
{
msg = ex.Message;
}
return msg;
}
//采购入库-采购到货单撤销
public string RevocationDeliveryNotice(string keyValue)
{
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
string msg = "";
string sql = string.Empty;
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
foreach (var item in res)
{
JObject jo = (JObject)item;
sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}' ", jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@"update ICSDeliveryNotice set RCVQuantity =RCVQuantity-'{0}' where DNCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and DNType='1'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
}
try
{
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
{
}
}
catch (Exception ex)
{
msg = ex.Message;
}
return msg;
}
//生产订单备料表
public string RevocationPicking(string keyValue)
{
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
string msg = "";
string sql = string.Empty;
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
foreach (var item in res)
{
JObject jo = (JObject)item;
sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@"update a set IssueQuantity =IssueQuantity-'{0}' from ICSMOPick a left join ICSMO b on a.MODetailID=b.MODetailID and a.WorkPoint=b.WorkPoint
where b.MOCode='{1}' and b.Sequence+'~'+a.Sequence='{2}' and a.WorkPoint='{3}'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
}
try
{
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
{
}
}
catch (Exception ex)
{
msg = ex.Message;
}
return msg;
}
//领料申请单
public string RevocationMOApply(string keyValue)
{
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
string msg = "";
string sql = string.Empty;
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
foreach (var item in res)
{
JObject jo = (JObject)item;
sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@"update ICSMOApply set IssueQuantity =IssueQuantity-'{0}' where ApplyCode='{1}' and Sequence='{2}' and WorkPoint='{3}' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
}
try
{
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
{
}
}
catch (Exception ex)
{
msg = ex.Message;
}
return msg;
}
//材料出库
public string RevocationMOIssue(string keyValue)
{
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
string msg = "";
string sql = string.Empty;
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
foreach (var item in res)
{
JObject jo = (JObject)item;
sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@"update ICSMOIssue set IssueQuantity =IssueQuantity-'{0}' where IssueCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='1' and Status='2'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
}
try
{
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
{
}
}
catch (Exception ex)
{
msg = ex.Message;
}
return msg;
}
//产成品入库-生产订单
public string RevocationFinished(string keyValue)
{
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
string msg = "";
string sql = string.Empty;
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
foreach (var item in res)
{
JObject jo = (JObject)item;
sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@"update ICSMO set RCVQuantity =RCVQuantity-'{0}' where MOCode='{1}' and Sequence='{2}' and WorkPoint='{3}'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
}
try
{
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
{
}
}
catch (Exception ex)
{
msg = ex.Message;
}
return msg;
}
//产成品入库-产成品入库单
public string RevocationManufactureReceive(string keyValue)
{
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
string msg = "";
string sql = string.Empty;
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
foreach (var item in res)
{
JObject jo = (JObject)item;
sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@" update ICSManufactureReceive set RCVQuantity =RCVQuantity-'{0}' where RCVCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='1' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
}
try
{
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
{
}
}
catch (Exception ex)
{
msg = ex.Message;
}
return msg;
}
//一步调拨
public string RevocationICSTransfer(string keyValue)
{
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
string msg = "";
string sql = string.Empty;
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
foreach (var item in res)
{
JObject jo = (JObject)item;
sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}',WarehouseCode='{5}',LocationCode='{6}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint, jo["FromWarehouseCode"].ToString(), jo["FromLocationCode"].ToString());
sql += string.Format(@" update ICSTransfer set TransferQuantity =TransferQuantity-'{0}' where TransferNO='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='1' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
}
try
{
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
{
}
}
catch (Exception ex)
{
msg = ex.Message;
}
return msg;
}
//销售出库
public string RevocationMarket(string keyValue)
{
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
string msg = "";
string sql = string.Empty;
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
foreach (var item in res)
{
JObject jo = (JObject)item;
sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@" update ICSSDN set SDNQuantity =SDNQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
}
try
{
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
{
}
}
catch (Exception ex)
{
msg = ex.Message;
}
return msg;
}
//生产退料-生产退料单
public string RevocationProduceStripping(string keyValue)
{
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
string msg = "";
string sql = string.Empty;
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
foreach (var item in res)
{
JObject jo = (JObject)item;
string sqlseach = @"select Type from dbo.ICSInventoryLot where LotNo='"+ jo["LotNo"].ToString() + "'";
object LotNoType= SqlHelper.ExecuteScalar(sqlseach);
if (LotNoType.ToString()== "1")
{
//新条码退
sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
sql += string.Format(@" UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
FROM ICSInventoryLot a
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
INNER JOIN ICSMOApplyNegDetail c ON b.TransCode=c.ApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
INNER JOIN ICSMOApplyNeg d ON c.ApplyNegCode=d.ApplyNegCode AND c.WorkPoint=d.WorkPoint
INNER JOIN ICSMOPick e ON c.SourceDetailID=e.PickID AND c.WorkPoint=e.WorkPoint
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='1'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString());
}
else
{
sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity-'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
// sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
sql += string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
FROM ICSWareHouseLotInfoLog a
INNER JOIN ICSMO b ON a.TransCode=b.MOCode AND a.WorkPoint=b.WorkPoint
INNER JOIN ICSMOPick c ON b.MODetailID = c.MODetailID AND b.WorkPoint = c.WorkPoint AND a.TransSequence = b.Sequence + '~' + c.Sequence
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.ID='{3}'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString(), jo["ID"].ToString());
}
}
try
{
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
{
}
}
catch (Exception ex)
{
msg = ex.Message;
}
return msg;
}
//生产退料-生产退料单-领料申请单
public string RevocationProduceStrippingLL(string keyValue)
{
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
string msg = "";
string sql = string.Empty;
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
foreach (var item in res)
{
JObject jo = (JObject)item;
string sqlseach = @"select Type from dbo.ICSInventoryLot where LotNo='" + jo["LotNo"].ToString() + "'";
object LotNoType = SqlHelper.ExecuteScalar(sqlseach);
if (LotNoType.ToString() == "1")
{
//新条码退
sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
sql += string.Format(@" UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
FROM ICSInventoryLot a
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
INNER JOIN ICSMOApplyNegDetail c ON b.TransCode=c.ApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
INNER JOIN ICSMOApplyNeg d ON c.ApplyNegCode=d.ApplyNegCode AND c.WorkPoint=d.WorkPoint
INNER JOIN ICSMOApply e ON c.SourceDetailID=e.ApplyDetailID AND c.WorkPoint=e.WorkPoint
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='2'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString());
}
else
{
sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity-'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
// sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
sql += string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
FROM ICSWareHouseLotInfoLog a
INNER JOIN ICSMOApply c ON a.TransCode=c.ApplyCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.ID='{3}'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString(), jo["ID"].ToString());
}
}
try
{
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
{
}
}
catch (Exception ex)
{
msg = ex.Message;
}
return msg;
}
//生产退料-生产退料单-材料出库单
public string RevocationProduceStrippingCLCK(string keyValue)
{
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
string msg = "";
string sql = string.Empty;
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
foreach (var item in res)
{
JObject jo = (JObject)item;
string sqlseach = @"select Type from dbo.ICSInventoryLot where LotNo='" + jo["LotNo"].ToString() + "'";
object LotNoType = SqlHelper.ExecuteScalar(sqlseach);
if (LotNoType.ToString() == "1")
{
//新条码退
sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
sql += string.Format(@" UPDATE e SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
FROM ICSInventoryLot a
INNER JOIN ICSInventoryLotDetail b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
INNER JOIN ICSMOApplyNegDetail c ON b.TransCode=c.ApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
INNER JOIN ICSMOApplyNeg d ON c.ApplyNegCode=d.ApplyNegCode AND c.WorkPoint=d.WorkPoint
INNER JOIN ICSMOIssue e ON c.SourceDetailID=e.IssueDetailID AND c.WorkPoint=e.WorkPoint
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND d.Type='3'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString());
}
else
{
sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity-'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
// sql += string.Format(@" update ICSMOApplyNegDetail set IssueNegQuantity =IssueNegQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SDNCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
sql += string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
FROM ICSWareHouseLotInfoLog a
INNER JOIN ICSMOIssue c ON a.TransCode=c.IssueCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}' AND a.ID='{3}'", jo["LotNo"].ToString(), WorkPoint, jo["Quantity"].ToString(), jo["ID"].ToString());
}
}
try
{
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
{
}
}
catch (Exception ex)
{
msg = ex.Message;
}
return msg;
}
//其他出库(杂发)
public string RevocationOtheOutboundr(string keyValue)
{
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
string msg = "";
string sql = string.Empty;
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
foreach (var item in res)
{
JObject jo = (JObject)item;
sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+'{0}',MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where LotNo='{3}' and WorkPoint='{4}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@" update ICSOtherOut set OutQuantity =OutQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where OutCode='{3}' and Sequence='{4}' and WorkPoint='{5}'", jo["Quantity"].ToString(), MUSER, MUSERNAME, jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
}
try
{
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
{
}
}
catch (Exception ex)
{
msg = ex.Message;
}
return msg;
}
//其他入库(杂收)
public string RevocationOtheWarehousing(string keyValue)
{
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
string msg = "";
string sql = string.Empty;
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
foreach (var item in res)
{
JObject jo = (JObject)item;
sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@" update ICSOtherIn set InQuantity =InQuantity-'{0}' where InCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='1' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , MTIME=getdate(),MUSER='{0}',MUSERName='{1}' where ID='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
}
try
{
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
{
}
}
catch (Exception ex)
{
msg = ex.Message;
}
return msg;
}
}
}