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.
 
 
 
 
 

2030 lines
118 KiB

using NFine.Data.Extensions;
using System;
using NFine.Repository;
using NFine.Domain._03_Entity.SRM;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Data;
using System.Configuration;
using System.Text;
using System.Net;
using System.IO;
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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
sql += string.Format(@"update ICSWareHouseLotInfo set Quantity=Quantity+ROUND('{0}' ,3),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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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;
string sqlEnable = @"SELECT b.LotEnable FROM ICSInventoryLot a
LEFT JOIN ICSInventory b ON a.InvCode=b.InvCode AND a.WorkPoint=b.WorkPoint
where a.LotNo='{0}' and a.WorkPoint='{1}'";
sqlEnable = string.Format(sqlEnable, jo["LotNo"].ToString(), WorkPoint);
object Enable = SqlHelper.ExecuteScalar(sqlEnable);
string sqlQty = @"select Quantity from dbo.ICSWareHouseLotInfo where LotNo='{0}' ";
sqlQty = string.Format(sqlQty, jo["LotNo"].ToString());
object Qty = SqlHelper.ExecuteScalar(sqlQty);
sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
if (Convert.ToBoolean(Enable) == true && (Convert.ToDecimal(Qty)-Convert.ToDecimal(jo["Quantity"].ToString())>0 ))
{
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());
}
else
{
sql += string.Format(@"update ICSWareHouseLotInfo set MTIME=getdate(),MUSER='{0}',MUSERName='{1}',WarehouseCode='{4}',LocationCode='{5}' where LotNo='{2}' and WorkPoint='{3}'", 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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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;
}
// u9跨组织调入(调拨单)
public string RevocationKZZICSTransfer(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 WorkPoint from ICSTransfer where TransferNO='"+ jo["TransCode"].ToString() + "' and Sequence='"+ jo["TransSequence"].ToString() + "'";
object OldWorkPoint = SqlHelper.ExecuteScalar(sqlSeach);
string sqlNewColspan = @" select b.Colspan from dbo.ICSInventoryLot a
inner join dbo.ICSExtension b on a.ExtensionID=b.ID and a.WorkPoint=b.WorkPoint
where a.LotNo='" + jo["LotNo"].ToString() + "' ";
object NewColspan = SqlHelper.ExecuteScalar(sqlNewColspan);
string sqlOldColspan = @"select ID from dbo.ICSExtension where WorkPoint='" + OldWorkPoint + "' and Colspan='" + NewColspan + "'";
object OldID = SqlHelper.ExecuteScalar(sqlOldColspan);
string sqlQty = @"select Quantity from dbo.ICSWareHouseLotInfo where LotNo='{0}' ";
sqlQty = string.Format(sqlQty, jo["LotNo"].ToString());
object Qty = SqlHelper.ExecuteScalar(sqlQty);
sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
sql += string.Format(@"update ICSWareHouseLotInfo set MTIME=getdate(),MUSER='{0}',MUSERName='{1}',WarehouseCode='{4}',LocationCode='{5}' ,WorkPoint='{6}' where LotNo='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint, jo["FromWarehouseCode"].ToString(), jo["FromLocationCode"].ToString(), OldWorkPoint);
sql += string.Format(@"update ICSInventoryLot set WorkPoint='{0}' , ExtensionID='{2}' where LotNo='{1}'", OldWorkPoint, jo["LotNo"].ToString(), OldID);
sql += string.Format(@"update ICSInventoryLotDetail set WorkPoint='{0}' where LotNo='{1}'", OldWorkPoint, jo["LotNo"].ToString());
sql += string.Format(@" update ICSTransfer set TransferQuantity =TransferQuantity-'{0}' where TransferNO='{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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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);
//新增验证(2025.5.14)
sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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 ApplyNegCode='{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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 ApplyNegCode='{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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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);
sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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);
sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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}' ", 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 RevocationBrrow(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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 ICSBrrow set BrrowQuantity =BrrowQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where BrrowCode='{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;
}
//u9跨组织调出(调拨申请单)
public string RevocationKZZICSTransferApplication(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 WorkPoint from ICSTransferApplication where TransferNO='" + jo["TransCode"].ToString() + "' and Sequence='" + jo["TransSequence"].ToString() + "' and EATTRIBUTE30='"+ WorkPoint + "'";
object OldWorkPoint = SqlHelper.ExecuteScalar(sqlSeach);
string sqlNewColspan = @" select b.Colspan from dbo.ICSInventoryLot a
inner join dbo.ICSExtension b on a.ExtensionID=b.ID and a.WorkPoint=b.WorkPoint
where a.LotNo='"+ jo["LotNo"].ToString() + "' ";
object NewColspan = SqlHelper.ExecuteScalar(sqlNewColspan);
string sqlOldColspan = @"select ID from dbo.ICSExtension where WorkPoint='"+ OldWorkPoint + "' and Colspan='"+ NewColspan + "'";
object OldID = SqlHelper.ExecuteScalar(sqlOldColspan);
string sqlQty = @"select Quantity from dbo.ICSWareHouseLotInfo where LotNo='{0}' ";
sqlQty = string.Format(sqlQty, jo["LotNo"].ToString());
object Qty = SqlHelper.ExecuteScalar(sqlQty);
sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
sql += string.Format(@"update ICSWareHouseLotInfo set MTIME=getdate(),MUSER='{0}',MUSERName='{1}',WarehouseCode='{4}',LocationCode='{5}' ,WorkPoint='{6}' where LotNo='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint, jo["FromWarehouseCode"].ToString(), jo["FromLocationCode"].ToString(), OldWorkPoint);
sql += string.Format(@"update ICSInventoryLot set WorkPoint='{0}' , ExtensionID='{2}' where LotNo='{1}'", OldWorkPoint, jo["LotNo"].ToString(), OldID);
sql += string.Format(@"update ICSInventoryLotDetail set WorkPoint='{0}' where LotNo='{1}'", OldWorkPoint, jo["LotNo"].ToString());
sql += string.Format(@" update ICSTransferApplication 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(), OldWorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 RevocationWWProduceStripping(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);
sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
if (LotNoType.ToString() == "1")
{
//新条码退
sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@" update ICSOApplyNegDetail 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' where ID='{0}' and WorkPoint='{1}'", 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 ICSOApplyNegDetail c ON b.TransCode=c.OApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
INNER JOIN ICSOApplyNeg d ON c.OApplyNegCode=d.OApplyNegCode AND c.WorkPoint=d.WorkPoint
INNER JOIN ICSOOPick 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}',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' where ID='{0}' and WorkPoint='{1}'", jo["ID"].ToString(), WorkPoint);
sql += string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
FROM ICSWareHouseLotInfoLog a
INNER JOIN ICSOutsourcingOrder b ON a.TransCode=b.OOCode AND a.WorkPoint=b.WorkPoint
INNER JOIN ICSMOPick c ON b.OODetailID = c.OODetailID 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 RevocationWWProduceStrippingLL(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);
sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
if (LotNoType.ToString() == "1")
{
//新条码退
sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@" update ICSOApplyNegDetail 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' where ID='{0}' and WorkPoint='{1}'", 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 ICSOApplyNegDetail c ON b.TransCode=c.OApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
INNER JOIN ICSOApplyNeg d ON c.OApplyNegCode=d.OApplyNegCode AND c.WorkPoint=d.WorkPoint
INNER JOIN ICSOApply 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}',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' where ID='{0}' and WorkPoint='{1}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
sql += string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
FROM ICSWareHouseLotInfoLog a
INNER JOIN ICSOApply 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 RevocationWWProduceStrippingCLCK(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);
sql += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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' where ID='{0}' and WorkPoint='{1}'", 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 ICSOApplyNegDetail c ON b.TransCode=c.OApplyNegCode AND b.TransSequence=c.Sequence AND b.WorkPoint=c.WorkPoint
INNER JOIN ICSOApplyNeg d ON c.OApplyNegCode=d.OApplyNegCode AND c.WorkPoint=d.WorkPoint
INNER JOIN ICSOIssue 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' where ID='{0}' and WorkPoint='{1}'", MUSER, MUSERNAME, jo["ID"].ToString(), WorkPoint);
sql += string.Format(@"UPDATE c SET IssueQuantity=ISNULL(IssueQuantity,0)+'{2}'
FROM ICSWareHouseLotInfoLog a
INNER JOIN ICSOIssue 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 RevocationWWPurchase(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}' ", jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@"update ICSOutsourcingOrder set InQuantity =InQuantity-'{0}' where OOCode='{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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 DataTable GetLogNewID(string LotNo)
{
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
string sql = @" select top 1 a.ID,a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{0}' and a.WorkPoint='{1}' and isnull(EATTRIBUTE1,'')<>'1'
order by a.MTIME desc
";
sql = string.Format(sql, LotNo, WorkPoints);
DataTable dt = SqlHelper.GetDataTableBySql(sql);
return dt;
}
public string RevocationPickingCPRKDC(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 RevocationICSOOPickWWCPRKDC(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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 ICSOOPick a
left join ICSOutsourcingOrder b on a.OODetailID=b.OODetailID and a.WorkPoint=b.WorkPoint
where b.OOCode='{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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 RevocationWYTDB(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
sql += string.Format(@"update ICSWareHouseLotInfo set 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 ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 RevocationWWDHRK(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}' ", jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@"update ICSODeliveryNotice set RCVQuantity =RCVQuantity-'{0}' where ODNCode='{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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 RevocationWWTHWWTHD(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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 ICSODeliveryNotice set RCVQuantity =RCVQuantity-'{0}' where ODNCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and ODNType='2' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 RevocationWWTHHZRKD(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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 ICSOutsourcingReceive set RCVQuantity =RCVQuantity-'{0}' where RCVCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='2' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 RevocationWWRK(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}' ", jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@"update ICSOutsourcingReceive 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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 RevocationCGTTHD(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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 ICSDeliveryNotice set RCVQuantity =RCVQuantity-'{0}' where DNCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and DNType='2' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 RevocationCGTHZRKD(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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 ICSPurchaseReceive set RCVQuantity =RCVQuantity-'{0}' where RCVCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='2' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 RevocationXSTXSTHD(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}' ", jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@"update ICSSDN set SDNQuantity =SDNQuantity-'{0}' where SDNCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='2'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 RevocationWWFLBLB(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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 ICSOOPick a
left join ICSOutsourcingOrder b on a.OODetailID=b.OODetailID and a.WorkPoint=b.WorkPoint
where b.OOCode='{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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 RevocationWWFLLLSQ(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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 ICSOApply 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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 RevocationOOIssue(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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 ICSOIssue 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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 DeleteERPLotLog(string keyValue)
{
string msg = "";
string APIURL = ConfigurationManager.ConnectionStrings["ERPAPIURL"].ConnectionString + "ERPLot/DELETE";
string result = HttpPost(APIURL, keyValue);
JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
string MessAge = Obj["Message"].ToString();
string Success = Obj["Success"].ToString();
if (Success.ToUpper() == "FALSE")
{
msg = MessAge;
}
return msg;
}
//接口api解析
public static string HttpPost(string url, string body)
{
try
{
Encoding encoding = Encoding.UTF8;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.Accept = "application/json, text/javascript, */*"; //"text/html, application/xhtml+xml, */*";
request.ContentType = "application/json; charset=utf-8";
byte[] buffer = encoding.GetBytes(body);
request.ContentLength = buffer.Length;
request.GetRequestStream().Write(buffer, 0, buffer.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
{
return reader.ReadToEnd();
}
}
catch (WebException ex)
{
throw new Exception(ex.Message);
}
}
//销售出库
public string RevocationXSCK(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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 ICSSSD set SSDQuantity =SSDQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SSDCode='{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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 RevocationXSCKJINH(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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 ICSSSD set SSDQuantity =SSDQuantity-'{0}' , MTIME=getdate(),MUSER='{1}',MUSERName='{2}' where SSDCode='{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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 RevocationHZXSCK(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}' ", jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@"update ICSSSD set SSDQuantity =SSDQuantity-'{0}' where SSDCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='2'", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 RevocationSHDRK(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}' ", jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@"update ICSPurchaseReceive set RCVQuantity =RCVQuantity-'{0}' where RCVCode='{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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 RevocationPickingJHBWLL(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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);
string checksql = @"select a.id from ICSMOPick a
INNER JOIN ICSMO b ON a.MODetailID=b.MODetailID AND a.WorkPoint=b.WorkPoint
where b.mocode='{0}' and a.WorkPoint='{1}' AND a.SupplyType='3' AND b.MOStatus<>'3' and a.EATTRIBUTE1<>'1' ";
checksql = string.Format(checksql, jo["TransCode"].ToString(), WorkPoint);
DataTable checkdt = SqlHelper.GetDataTableBySql(checksql);
if (checkdt.Rows.Count == 0 || checkdt == null)
{//不需要回写单据数量
}
else
{//需要回写单据子件已领数量
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' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 RevocationFCPRK(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
sql += string.Format(@"delete from ICSWareHouseLotInfo where LotNo='{0}' and WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint);
sql += string.Format(@"UPDATE d 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 ICSMO c ON b.TransCode=c.MOCode AND b.WorkPoint=c.WorkPoint
INNER JOIN ICSMOPick d ON c.MODetailID=d.MODetailID AND b.TransSequence=c.Sequence+'~'+d.Sequence AND b.WorkPoint=d.WorkPoint
WHERE a.LotNo='{0}' AND a.WorkPoint='{1}'", jo["LotNo"].ToString(), WorkPoint,jo["Quantity"].ToString() );
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 RevocationHP(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
sql += string.Format(@"UPDATE a set a.Quantity = b.Quantity
FROM ICSWareHouseLotInfo a
INNER JOIN ICSWareHouseLotInfoLog b ON a.LotNo = b.LotNo and a.WorkPoint=b.WorkPoint
WHERE b.BusinessCode = '33' AND b.Identification = '{0}' and a.WorkPoint='{1}' ", jo["Identification"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{1}' where Identification='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["Identification"].ToString(), WorkPoint);
}
try
{
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
{
}
}
catch (Exception ex)
{
msg = ex.Message;
}
return msg;
}
//移库
public string RevocationYK(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
sql += string.Format(@"update ICSWareHouseLotInfo set MTIME=getdate(),MUSER='{0}',MUSERName='{1}',WarehouseCode='{4}',LocationCode='{5}' where LotNo='{2}' and WorkPoint='{3}'", MUSER, MUSERNAME, jo["LotNo"].ToString(), WorkPoint, jo["FromWarehouseCode"].ToString(), jo["FromLocationCode"].ToString());
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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 RevocationQTRKHZ(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 += $@" if NOT EXISTS(SELECT Id FROM ICSWareHouseLotInfoLog WHERE WorkPoint='{WorkPoint}' AND Identification=(select top 1 a.Identification from dbo.ICSWareHouseLotInfoLog a
where a.LotNo='{jo["LotNo"]}' and a.WorkPoint='{WorkPoint}' and isnull(EATTRIBUTE1,'')<>'1' order by a.MTIME desc) AND Identification='{jo["Identification"]}')
BEGIN
RAISERROR(',', 16, 1);
RETURN
END ;";
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 ICSOtherIn set InQuantity =InQuantity-'{0}' where RCVCode='{1}' and Sequence='{2}' and WorkPoint='{3}' and Type='2' ", jo["Quantity"].ToString(), jo["TransCode"].ToString(), jo["TransSequence"].ToString(), WorkPoint);
sql += string.Format(@"update ICSWareHouseLotInfoLog set EATTRIBUTE1 ='1' , EATTRIBUTE3=getdate(),EATTRIBUTE4='{0}',EATTRIBUTE5='{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;
}
}
}