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.
129 lines
5.5 KiB
129 lines
5.5 KiB
using NFine.Data.Extensions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Text;
|
|
using NFine.Repository;
|
|
using System.Data.Common;
|
|
using NFine.Domain._03_Entity.SRM;
|
|
using Newtonsoft.Json;
|
|
using System.Configuration;
|
|
using Newtonsoft.Json.Linq;
|
|
using System.Net;
|
|
using System.IO;
|
|
using NFine.Domain._03_Entity.WMS;
|
|
|
|
namespace NFine.Application.WMS
|
|
{
|
|
public class DeleteArrivalDocApp : RepositoryFactory<ICSVendor>
|
|
{
|
|
|
|
//删除采购到货单
|
|
public string DeleteICSDeliveryNotice(string keyValue)
|
|
{
|
|
//站点信息
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
string sqlSeach = string.Format(@"SELECT h.* FROM ICSDeliveryNotice a
|
|
inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint
|
|
inner JOIN ICSInspection h ON h.LotNo=b.LotNo AND h.WorkPoint=b.WorkPoint
|
|
WHERE a.DNCode IN ({0}) and a.WorkPoint in ('{1}')
|
|
", keyValue.TrimEnd(','), WorkPoint);
|
|
DataTable dtASN = SqlHelper.GetDataTableBySql(sqlSeach);
|
|
if (dtASN != null && dtASN.Rows.Count > 0)
|
|
{
|
|
msg = "所选单据已生成检验单,无法删除!";
|
|
}
|
|
sqlSeach = string.Format(@"SELECT h.* FROM ICSDeliveryNotice a
|
|
inner JOIN ICSASNDetail b ON a.ASNCode=b.ASNCode AND a.WorkPoint=b.WorkPoint
|
|
inner JOIN ICSWareHouseLotInfo h ON h.LotNo=b.LotNo AND h.WorkPoint=b.WorkPoint
|
|
WHERE a.DNCode IN ({0}) and a.WorkPoint in ('{1}')
|
|
", keyValue.TrimEnd(','), WorkPoint);
|
|
DataTable dtCarton = SqlHelper.GetDataTableBySql(sqlSeach);
|
|
if (dtCarton != null && dtCarton.Rows.Count > 0)
|
|
{
|
|
msg += "所选单据已入库,无法删除!";
|
|
}
|
|
sql += string.Format(@" update b set b.DNQuantity=0,b.DNAmount=0
|
|
from ICSDeliveryNotice a
|
|
inner join ICSASNDetail b on a.ASNCode=b.ASNCode and a.WorkPoint=b.WorkPoint
|
|
where a.DNCode IN ({0}) and a.WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
sql += string.Format(@"DELETE FROM dbo.ICSDeliveryNotice WHERE DNCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
|
|
//删除委外采购到货单
|
|
|
|
public string DeleteICSODeliveryNotice(string keyValue)
|
|
{
|
|
//站点信息
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
string sqlSeach = string.Format(@"SELECT h.* FROM ICSODeliveryNotice a
|
|
inner JOIN ICSOASNDetail b ON a.OASNCode=b.OASNCode AND a.WorkPoint=b.WorkPoint
|
|
inner JOIN ICSInspection h ON h.LotNo=b.LotNo AND h.WorkPoint=b.WorkPoint
|
|
WHERE a.ODNCode IN ({0}) and a.WorkPoint in ('{1}')
|
|
", keyValue.TrimEnd(','), WorkPoint);
|
|
DataTable dtASN = SqlHelper.GetDataTableBySql(sqlSeach);
|
|
if (dtASN != null && dtASN.Rows.Count > 0)
|
|
{
|
|
msg = "所选单据已生成检验单,无法删除!";
|
|
}
|
|
sqlSeach = string.Format(@"SELECT h.* FROM ICSODeliveryNotice a
|
|
inner JOIN ICSOASNDetail b ON a.OASNCode=b.OASNCode AND a.WorkPoint=b.WorkPoint
|
|
inner JOIN ICSWareHouseLotInfo h ON h.LotNo=b.LotNo AND h.WorkPoint=b.WorkPoint
|
|
WHERE a.ODNCode IN ({0}) and a.WorkPoint in ('{1}')
|
|
", keyValue.TrimEnd(','), WorkPoint);
|
|
DataTable dtCarton = SqlHelper.GetDataTableBySql(sqlSeach);
|
|
if (dtCarton != null && dtCarton.Rows.Count > 0)
|
|
{
|
|
msg = "所选单据已入库,无法删除!";
|
|
}
|
|
sql += string.Format(@" update b set b.ODNQuantity=0,b.ODNAmount=0
|
|
from ICSODeliveryNotice a
|
|
inner join ICSOASNDetail b on a.OASNCode=b.OASNCode and a.WorkPoint=b.WorkPoint
|
|
where a.ODNCode IN ({0}) and a.WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
sql += string.Format(@"DELETE FROM dbo.ICSODeliveryNotice WHERE ODNCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|