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.
991 lines
51 KiB
991 lines
51 KiB
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using NFine.Code;
|
|
using NFine.Data.Extensions;
|
|
using NFine.Domain._03_Entity.SRM;
|
|
using NFine.Domain.Entity.ProductManage;
|
|
using NFine.Domain.IRepository.ProductManage;
|
|
using NFine.Repository;
|
|
using NFine.Repository.ProductManage;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Data.Common;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace NFine.Application
|
|
{
|
|
public class ASNManageApp : RepositoryFactory<ICSVendor>
|
|
{
|
|
|
|
public DataTable GetGridJson(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT distinct a.ID, a.ASNCode,a.VenCode,b.VenName AS VENDORNAME,w.WorkPointName,w.WorkPointCode,a.MUSERName,
|
|
a.MTIME,CONVERT(NVARCHAR(50),a.PlanArriveDate,23) as EXPARRIVALDATE,
|
|
CASE WHEN c.DNCode IS NULL THEN a.Status ELSE '3' END AS STATUS
|
|
FROM dbo.ICSASN a
|
|
LEFT JOIN dbo.ICSVendor b ON a.VenCode=b.VenCode and a.WOrkPoint=b.WorkPoint
|
|
LEFT JOIN ICSDeliveryNotice c ON a.ASNCode = c.ASNCode
|
|
LEFT JOIN Sys_WorkPoint w on a.WorkPoint=w.WorkPointCode
|
|
WHERE 1=1";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["STNO"].ToString()))
|
|
{
|
|
sql += " and a.ASNCode like '%" + queryParam["STNO"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
{
|
|
sql += " and VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
|
|
{
|
|
sql += " and b.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
|
|
{
|
|
sql += " and a.MTIME >= '" + queryParam["TimeFrom"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TimeTo"].ToString()))
|
|
{
|
|
sql += " and a.MTIME <= '" + queryParam["TimeTo"].ToString() + "' ";
|
|
}
|
|
}
|
|
//多站点
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql += " and a.WorkPoint in (" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',') + ")";
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
{
|
|
sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
public DataTable GetGridJsonAdmin(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT a.ASNID, a.STNO,a.VENDORCODE,b.cVenName AS VENDORNAME,CONVERT(NVARCHAR(50),a.CREATETIME,23) as CREATETIME,w.WorkPointName,w.WorkPointCode,
|
|
a.CREATEUSER,a.ADDITION1,a.ADDITION2,CONVERT(NVARCHAR(50),
|
|
a.EXPARRIVALDATE,23) as EXPARRIVALDATE,
|
|
CASE WHEN c.cCode IS NULL THEN a.STSTATUS ELSE '3' END AS STATUS
|
|
FROM dbo.ICSASN a
|
|
LEFT JOIN dbo.ICSVendor b ON a.VENDORCODE=b.cVenCode and a.WOrkPoint=b.WorkPoint
|
|
LEFT JOIN ICSPOArrive c ON a.STNO = c.STNO
|
|
LEFT JOIN Sys_WorkPoint w on a.WorkPoint=w.WorkPointCode
|
|
WHERE 1=1 and a.STSTATUS in ( '1','2')";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["STNO"].ToString()))
|
|
{
|
|
sql += " and a.STNO like '%" + queryParam["STNO"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
{
|
|
sql += " and VENDORCODE like '%" + queryParam["VenCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
|
|
{
|
|
sql += " and b.cVenName like '%" + queryParam["VenName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
|
|
{
|
|
sql += " and a.CREATETIME >= '" + queryParam["TimeFrom"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TimeTo"].ToString()))
|
|
{
|
|
sql += " and a.CREATETIME <= '" + queryParam["TimeTo"].ToString() + "' ";
|
|
}
|
|
}
|
|
//多站点
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql += " and a.WorkPoint in (" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',') + ")";
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
{
|
|
sql += " and VENDORCODE='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 子表查询
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetSubGridJson(string STNO, ref Pagination jqgridparam,string WorkPoint)
|
|
{
|
|
|
|
DataTable dt = new DataTable();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT a.ID, a.LotNo,d.InvCode,d.InvName,c.ContainerID,b.Quantity,
|
|
a.ASNCode,f.BatchCode,f.ProjectCode,m.TransCode,m.TransSequence,d.InvDesc,d.ClassName,d.InvStd,w.WorkPointName,w.WorkPointCode
|
|
FROM dbo.ICSASNDetail a
|
|
LEFT JOIN dbo.ICSInventoryLot b ON a.LotNo =b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
left join ICSExtension f on b.ExtensionID=f.ID and b.WorkPoint=f.WorkPoint
|
|
left join ICSInventoryLotDetail m on b.LotNo=m.LotNo and b.WorkPoint=m.WorkPoint
|
|
LEFT JOIN dbo.ICSContainerLot c ON b.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN dbo.ICSInventory d ON b.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN dbo.ICSPurchaseOrder e ON m.TransCode=e.POCode AND m.TransSequence=e.Sequence AND a.WorkPoint=e.WorkPoint
|
|
LEFT JOIN Sys_WorkPoint w on e.WorkPoint=w.WorkPointCode
|
|
WHERE b.TYPE='1' AND a.ASNCode='" + STNO + "' and a.WorkPoint='" + WorkPoint + "' ";
|
|
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 选择条码信息
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetSubGridJson_Add(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
|
|
string sql = @"SELECT a.ID, a.LOTNO,d.InvCode,d.InvName,c.ContainerID,b.Quantity,
|
|
a.ASNCode,m.BatchCode,f.POCode,f.Sequence,d.InvDesc,d.ClassName,d.InvStd
|
|
FROM dbo.ICSASNDetail a
|
|
LEFT JOIN dbo.ICSInventoryLot b ON a.LotNo =b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
left join ICSExtension m on b.ExtensionID=m.ID and b.WorkPoint=m.WorkPoint
|
|
LEFT JOIN dbo.ICSContainerLot c ON a.LotNo=c.LotNo AND a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN dbo.ICSInventory d ON b.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint
|
|
left join ICSInventoryLotDetail e on b.LotNo=e.LotNo and b.WorkPoint=e.WorkPoint
|
|
LEFT JOIN dbo.ICSPurchaseOrder f ON e.TransCode=f.POCode AND e.TransSequence=f.Sequence and a.WorkPoint=f.WorkPoint
|
|
WHERE 1=1
|
|
AND a.ASNCode='" + queryParam["STNO"].ToString() + "' and a.WorkPoint='" + queryParam["WorkPoint"].ToString() + "' ";
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 子表查询
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetSubGridJson(string CartonNo, string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT a.ID,c.ItemCODE,d.INVNAME,c.VenderLotNO,c.LOTQTY,c.TYPE
|
|
FROM dbo.ICSITEMLot2Carton a
|
|
LEFT JOIN dbo.ICSCarton b ON a.CartonNO=b.CartonNO AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSITEMLot c ON a.LotNo_ID=c.ID AND a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN dbo.ICSINVENTORY d ON c.ItemCODE=d.INVCODE AND a.WorkPoint=d.WorkPoint
|
|
WHERE a.CartonNO='" + CartonNo + "' and a.WorkPoint='" + WorkPoint + "'";
|
|
if (!string.IsNullOrEmpty(queryJson))
|
|
{
|
|
sql += @"UNION ALL
|
|
SELECT a.ID,a.ItemCODE,b.INVNAME,a.VenderLotNO,a.LOTQTY,a.TYPE FROM
|
|
dbo.ICSITEMLot a
|
|
LEFT JOIN dbo.ICSINVENTORY b ON a.ItemCODE=b.INVCODE AND a.WorkPoint=b.WorkPoint
|
|
WHERE a.ID IN (" + queryJson.TrimEnd(',') + ") and a.WorkPoint='" + WorkPoint + "'";
|
|
}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
public DataTable GetSubGridJsonByCreate(string POCode, string PORow)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT a.ID, a.POCode,a.PORow,a.PODate,a.ORDERNO,a.VenCode,a.VenName,a.InvCode,
|
|
b.INVNAME,b.INVSTD,b.INVDESC,b.INVUOM,a.Quantity,ISNULL(c.CreatedQty,0) AS CreatedQty,isnull(c.InQty,0) as InQty,a.WorkPoint
|
|
FROM dbo.ICSPO_PoMain a
|
|
LEFT JOIN dbo.ICSINVENTORY b ON a.InvCode=b.INVCODE AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN (SELECT SUM(x.LOTQTY) CreatedQty,TransNO,TransLine,x.WorkPoint,
|
|
SUM(CASE WHEN y.LotNO IS NOT NULL THEN x.LOTQTY ELSE 0 END) AS InQty
|
|
FROM dbo.ICSITEMLot x
|
|
LEFT JOIN dbo.ICSWareHouseLotInfo y ON x.LotNO=y.LotNO AND x.WorkPoint=y.WorkPoint
|
|
GROUP BY TransNO,TransLine,x.WorkPoint) c ON a.POCode=c.TransNO AND a.PORow=c.TransLine AND a.WorkPoint=c.WorkPoint
|
|
WHERE 1=1
|
|
and a.POCode='" + POCode + "' and a.PORow='" + PORow + "' and a.WorkPoint='" + WorkPoint + "'";
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
public DataTable GetVendorLotNo(string VenCode, string WorkPoint)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string dtPre = DateTime.Now.ToString("yyyyMMdd");
|
|
string sql = @"EXEC Addins_GetSerialCode '" + WorkPoint + "','ICSITEMLotNo','VendorLotNo','" + VenCode + dtPre + "',2";
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 生成条码
|
|
/// </summary>
|
|
/// <param name="POCode"></param>
|
|
/// <param name="PORow"></param>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
public int CreateItemLotNo(string POCode, string PORow, string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString());
|
|
decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString());
|
|
decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString());
|
|
decimal LOTQTY = minPackQty;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string VenCode = GetVendorCode(POCode, PORow, WorkPoint);
|
|
string Pre = VenCode + DateTime.Now.ToString("yyMMdd");
|
|
string sql = string.Empty;
|
|
string VendorLot = queryParam["VendorLot"].ToString();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
|
|
for (int i = 0; i < createPageCount; i++)
|
|
{
|
|
if (i + 1 == createPageCount)
|
|
{
|
|
if (minPackQty * createPageCount > thisCreateQty)
|
|
{
|
|
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
|
|
}
|
|
}
|
|
string LotNo = GetSerialCode(WorkPoint, "ICSITEMLot", "LotNO", Pre, 5);
|
|
sql += string.Format(@"INSERT INTO dbo.ICSITEMLot
|
|
( ID ,LotNO ,ItemCODE ,TransNO ,TransLine ,VENDORITEMCODE ,VENDORCODE ,
|
|
VenderLotNO ,PRODUCTDATE ,LOTQTY ,ACTIVE ,Exdate ,WorkPoint ,
|
|
MUSER ,MUSERName ,MTIME ,TYPE,ORDERNO)
|
|
SELECT NEWID(),'{0}',InvCode,POCode,PORow,'',NULL,
|
|
'{1}',GETDATE(),'{2}','Y','2999-12-31 00:00:00.000','{3}',
|
|
'{4}','{5}',GETDATE(),'采购原料',ORDERNO
|
|
FROM dbo.ICSPO_PoMain WHERE POCode='{6}' AND PORow='{7}' AND WorkPoint='{3}'",
|
|
LotNo, VendorLot, LOTQTY, WorkPoint, MUSER, MUSERNAME, POCode, PORow);
|
|
sql += "\r\n";
|
|
}
|
|
int count = SqlHelper.ExecuteNonQuery(sql);
|
|
return count;
|
|
}
|
|
|
|
|
|
public string GetSerialCode(string workPointCode, string tbName, string colName, string Pre, int numLen)
|
|
{
|
|
string sql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}";
|
|
sql = string.Format(sql, new object[] { workPointCode, tbName, colName, Pre, numLen });
|
|
return DbHelper.ExecuteScalar(CommandType.Text, sql).ToString();
|
|
}
|
|
|
|
public string GetVendorCode(string POCode, string PORow, string WorkPoint)
|
|
{
|
|
string sql = string.Format(@"SELECT VenCode FROM dbo.ICSPO_PoMain
|
|
WHERE POCode='{0}' AND PORow='{1}' AND WorkPoint='{2}'", POCode, PORow, WorkPoint);
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
string VenCode = string.Empty;
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
VenCode = dt.Rows[0][0].ToString();
|
|
}
|
|
return VenCode;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除送货单内的条码或者箱号
|
|
/// </summary>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
public string DeleteInfo(string keyValue,string WorkPoint)
|
|
{
|
|
|
|
string msg = "";
|
|
string sql = string.Format(@" DELETE FROM dbo.ICSASNDetail
|
|
WHERE ID IN (
|
|
SELECT ID FROM dbo.ICSASNDetail WHERE LotNo IN (
|
|
SELECT LotNo FROM dbo.ICSContainerLot WHERE ContainerID IN (
|
|
SELECT a.ContainerID
|
|
FROM dbo.ICSContainerLot a
|
|
LEFT JOIN dbo.ICSASNDetail b ON a.LotNO=b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
WHERE b.ID IN ({0}) AND a.WorkPoint='{1}')
|
|
))", keyValue.TrimEnd(','), WorkPoint);
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
sql = string.Format(@" DELETE
|
|
FROM dbo.ICSASNDetail
|
|
WHERE ID IN ({0}) and WorkPoint ='{1}' ", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新送货单
|
|
/// </summary>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
public string UpdateSTNO(string keyValue,string WorkPoint)
|
|
{
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string[] keyValues = keyValue.Split(',');
|
|
string sql = string.Empty;
|
|
sql = "UPDATE ICSASN SET MTIME = {2} WHERE ASNCode = {0} AND WorkPoint in ({1})";
|
|
sql = string.Format(sql, keyValues[0].TrimStart(',').TrimEnd(','), WorkPoint, keyValues[1].TrimStart(',').TrimEnd(','));
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除送货单
|
|
/// </summary>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
public string DeleteSTNO(string keyValue,string WorkPoint)
|
|
{
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
sql = "SELECT ASNCode FROM dbo.ICSDeliveryNotice WHERE ASNCode IN (" + keyValue.TrimEnd(',') + ")";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
string STNO = dr["ASNCode"].ToString();
|
|
if (!string.IsNullOrEmpty(STNO))
|
|
{
|
|
msg += "送货单号:" + STNO + "已生成到货单,无法删除!";
|
|
}
|
|
}
|
|
if (string.IsNullOrEmpty(msg))
|
|
{
|
|
sql = string.Format(@" DELETE FROM dbo.ICSASNDetail WHERE ASNCode IN ({0}) and WorkPoint in ('{1}')
|
|
DELETE FROM dbo.ICSASN WHERE ASNCode IN ({0}) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
|
|
//string sql = string.Format(@"SELECT * FROM dbo.ICSASNDETAIL
|
|
// WHERE LOTNO IN (
|
|
// SELECT LotNO FROM dbo.ICSITEMLot2Carton WHERE CartonNO in ({0}) and WorkPoint='{1}') and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
//DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
//if (dt == null || dt.Rows.Count <= 0)
|
|
//{
|
|
// sql = string.Format(@"DELETE FROM dbo.ICSCarton WHERE CartonNO in ({0}) and WorkPoint='{1}'
|
|
// DELETE FROM dbo.ICSITEMLot2Carton WHERE CartonNO in ({0}) and WorkPoint='{1}' ", keyValue.TrimEnd(','), WorkPoint);
|
|
// DbHelper.ExecuteNonQuery(CommandType.Text, sql);
|
|
//}
|
|
//else
|
|
//{
|
|
// msg = "所选箱号中已有加入送货单中,请先在送单号中删除!";
|
|
//}
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
public int UpDateBySTNO(string keyValue, string Status, string WorkPoint)
|
|
{
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2);
|
|
string sql = string.Empty;
|
|
sql = @"UPDATE ICSASN SET Status = '{1}' WHERE ASNCode IN ({0}) AND WorkPoint in({2})";
|
|
sql = string.Format(sql, keyValue.TrimEnd(','), Status,WorkPoint.TrimEnd(','));
|
|
return SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
|
|
public string ChangeStatusBySTNO(string keyValue)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
sql = "SELECT STNO FROM dbo.ICSPOArrive WHERE STNO IN (" + keyValue.TrimEnd(',') + ")";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
string STNO = dr["STNO"].ToString();
|
|
if (!string.IsNullOrEmpty(STNO))
|
|
{
|
|
msg += "送货单号:" + STNO + "已生成到货单,无法删除!";
|
|
}
|
|
}
|
|
if (string.IsNullOrEmpty(msg))
|
|
{
|
|
sql = string.Format(@"DELETE FROM dbo.ICSASNDETAIL WHERE STNO IN ({0}) and WorkPoint ='{1}'
|
|
DELETE FROM dbo.ICSASN WHERE STNO IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
//string sql = string.Format(@"SELECT * FROM dbo.ICSASNDETAIL
|
|
// WHERE LOTNO IN (
|
|
// SELECT LotNO FROM dbo.ICSITEMLot2Carton WHERE CartonNO in ({0}) and WorkPoint='{1}') and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
//DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
//if (dt == null || dt.Rows.Count <= 0)
|
|
//{
|
|
// sql = string.Format(@"DELETE FROM dbo.ICSCarton WHERE CartonNO in ({0}) and WorkPoint='{1}'
|
|
// DELETE FROM dbo.ICSITEMLot2Carton WHERE CartonNO in ({0}) and WorkPoint='{1}' ", keyValue.TrimEnd(','), WorkPoint);
|
|
// DbHelper.ExecuteNonQuery(CommandType.Text, sql);
|
|
//}
|
|
//else
|
|
//{
|
|
// msg = "所选箱号中已有加入送货单中,请先在送单号中删除!";
|
|
//}
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除送货单
|
|
/// </summary>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
public string DeleteCartonNo(string keyValue)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
|
|
string sql = string.Format(@"SELECT * FROM dbo.ICSASNDETAIL
|
|
WHERE LOTNO IN (
|
|
SELECT LotNO FROM dbo.ICSITEMLot2Carton WHERE CartonNO in ({0}) and WorkPoint='{1}') and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
if (dt == null || dt.Rows.Count <= 0)
|
|
{
|
|
sql = string.Format(@"DELETE FROM dbo.ICSCarton WHERE CartonNO in ({0}) and WorkPoint='{1}'
|
|
DELETE FROM dbo.ICSITEMLot2Carton WHERE CartonNO in ({0}) and WorkPoint='{1}' ", keyValue.TrimEnd(','), WorkPoint);
|
|
DbHelper.ExecuteNonQuery(CommandType.Text, sql);
|
|
}
|
|
else
|
|
{
|
|
msg = "所选箱号中已有加入送货单中,请先在送单号中删除!";
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 选择条码
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetInfoBySelectItemCode(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT a.ID, a.LotNO,d.InvCode,d.InvName,a.Quantity,a.TYPE,
|
|
g.ProjectCode,e.POCode,e.Sequence,d.InvDesc,d.ClassName,d.INVSTD,g.BatchCode,a.Amount
|
|
FROM dbo.ICSInventoryLot a
|
|
left join ICSExtension g on a.ExtensionID=g.ID and a.WorkPoint=g.WorkPoint
|
|
LEFT JOIN dbo.ICSContainerLot b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSASNDetail c ON a.LotNO=c.LotNO AND a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN dbo.ICSInventory d ON a.InvCode=d.InvCode AND a.WorkPoint=d.WorkPoint
|
|
left join ICSInventoryLotDetail f on a.LotNo=f.LotNo and a.WorkPoint=f.WorkPoint
|
|
LEFT JOIN dbo.ICSPurchaseOrder e ON f.TransCode=e.POCode AND f.TransSequence=e.Sequence
|
|
WHERE c.LotNo is null and a.LotNO NOT IN (
|
|
SELECT LotNo FROM dbo.ICSContainerLot X WHERE x.WorkPoint=a.WorkPoint)";
|
|
//AND a.TYPE='采购'";
|
|
if (!string.IsNullOrEmpty(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
sql += " and d.InvCode like '%" + queryParam["InvCode"].ToString() + "%'";
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
|
|
sql += " and d.InvName like '%" + queryParam["InvName"].ToString() + "%'";
|
|
if (!string.IsNullOrWhiteSpace(queryParam["OrderNo"].ToString()))
|
|
sql += " and g.ProjectCode like '%" + queryParam["OrderNo"].ToString() + "%'";
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TransNo"].ToString()))
|
|
sql += " and e.POCode like '%" + queryParam["TransNo"].ToString() + "%'";
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TransLine"].ToString()))
|
|
sql += " and e.Sequence like '%" + queryParam["TransLine"].ToString() + "%'";
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
sql += " and e.VenCode='" + queryParam["VenCode"].ToString() + "'";
|
|
}
|
|
sql += " and a.WorkPoint='" + queryParam["WorkPoint"].ToString() + "'";
|
|
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取供应商列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetVendor()
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string sql = @"select '' as F_VenCode,'' as cVenName
|
|
union all
|
|
SELECT DISTINCT a.F_VenCode,isnull(b.VenName,'') as cVenName FROM dbo.Sys_SRM_User a
|
|
LEFT JOIN dbo.ICSVendor b ON a.F_VenCode=b.VenCode and a.F_Location=b.WorkPoint
|
|
WHERE a.F_VenCode IS NOT NULL AND a.F_VenCode <>''";
|
|
string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
|
|
if (role != "admin")
|
|
{
|
|
sql += " and b.WorkPoint=" + WorkPoint.TrimEnd(',') + "";
|
|
}
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
/// <summary>
|
|
/// 获取组织号信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetVendors()
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
|
|
string sql = @" select '' as WorkPointCode,'' as WorkPointName
|
|
union all
|
|
SELECT distinct (b.WorkPointCode),b.WorkPointName FROM Sys_SRM_User a
|
|
LEFT JOIN Sys_WorkPoint b ON a.F_Location=b.WorkPointCode where b.WorkPointCode is not null";
|
|
//if (role != "admin")
|
|
//{
|
|
// sql += " and a.F_Account='" + role + "'";
|
|
//}
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
public string GetSTNO(string WorkPoint)
|
|
{
|
|
string STNO = string.Empty;
|
|
string VenCode = NFine.Code.OperatorProvider.Provider.GetCurrent().VenCode;
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
if (!string.IsNullOrEmpty(VenCode))
|
|
{
|
|
string Date = DateTime.Now.ToString("yy");
|
|
string Pre = "DN" + VenCode + Date;
|
|
STNO = GetSerialCode(WorkPoint, "ICSASN", "STNO", Pre, 5);
|
|
}
|
|
if (!string.IsNullOrEmpty(STNO))
|
|
{
|
|
string sql = string.Empty;
|
|
string configSql = string.Empty;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string Status = "0";
|
|
|
|
#region [获取送货单配置信息,判断状态]
|
|
configSql = @"SELECT a.F_ItemCode,a.F_ItemName FROM Sys_SRM_ItemsDetail a
|
|
LEFT JOIN Sys_SRM_Items b ON a.F_ItemId = b.F_Id
|
|
WHERE b.F_EnCode = 'DeliveryNoteConfig'";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(configSql);
|
|
foreach (DataRow item in dt.Rows)
|
|
{
|
|
if (item["F_ItemName"].ToString().Equals("IsSub"))
|
|
{
|
|
Status = item["F_ItemCode"].ToString();
|
|
}
|
|
else if (item["F_ItemName"].ToString().Equals("IsEAV"))
|
|
{
|
|
if (Status == "1" && item["F_ItemCode"].ToString() == "3")
|
|
Status = "2";
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
sql = @"INSERT INTO dbo.ICSASN( ID ,MTIME,MUSER,MUSERNAME ,ASNCode ,VenCode ,WorkPoint,Status)
|
|
VALUES (NEWID(),GETDATE(),'" + VenCode + "','" + MUSERNAME + "','" + STNO + "','" + VenCode + "','" + WorkPoint + "','" + Status + "')";
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
return STNO;
|
|
}
|
|
|
|
public string GetSTNOByPerson(string VenCode, string ExpArrivalDate,string WorkPoint)
|
|
{
|
|
string STNO = string.Empty;
|
|
string Date = DateTime.Now.ToString("yy");
|
|
string Pre = "DN" + VenCode + Date;
|
|
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
STNO = GetSerialCode(WorkPoint, "ICSASN", "STNO", Pre, 5);
|
|
if (!string.IsNullOrEmpty(STNO))
|
|
{
|
|
string sql = string.Empty;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
sql = @" INSERT INTO dbo.ICSASN
|
|
( ID ,ASNCode,VenCode ,
|
|
Status ,MUSER ,MUSERName ,MTIME,WorkPoint)
|
|
VALUES (NEWID(),'" + STNO + "','" + VenCode + "','2','" + MUSER + "','" + MUSERNAME + "',getdate(),'" + WorkPoint + "')";
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
return STNO;
|
|
}
|
|
|
|
//public string CheckSTNO_ItemCode(string JsonData, string STNO, string WorkPoint, string ICSASN)
|
|
//{
|
|
// string msg = "";
|
|
// string APIURL = ConfigurationManager.ConnectionStrings["APIURLLOT"].ConnectionString;
|
|
// string result = SqlHelper.HttpPost(APIURL, ICSASN);
|
|
// 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;
|
|
//}
|
|
|
|
public string CheckSTNO_ItemCode(string JsonData, string STNO, string WorkPoint)
|
|
{
|
|
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;
|
|
sql = @"INSERT INTO dbo.ICSASNDetail
|
|
( ID ,ASNCode ,Sequence ,MUSER ,
|
|
LotNo , Quantity ,Amount ,DNQuantity ,DNAmount ,MUSERName,
|
|
MTIME,WorkPoint)
|
|
SELECT NEWID(),'" + STNO + "',ROW_NUMBER()over(partition by LotNO order by mtime desc),'" + MUSER + @"',
|
|
a.LotNO,a.Quantity,a.Quantity*Amount as Amount,0,0,'" + MUSERNAME + @"',
|
|
getdate()," + WorkPoint.TrimEnd(',') + @"
|
|
FROM dbo.ICSInventoryLot a
|
|
WHERE a.ID IN (" + JsonData.TrimEnd(',') + ")";
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
|
|
public string CheckSTNO_CartonNo(string JsonData, string STNO, string WorkPoint)
|
|
{
|
|
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;
|
|
sql = @"INSERT INTO dbo.ICSASNDetail
|
|
( ID ,ASNCode ,Sequence ,MUSER ,
|
|
LotNo , Quantity ,Amount ,DNQuantity ,DNAmount ,MUSERName,
|
|
MTIME,WorkPoint)
|
|
SELECT NEWID(),'" + STNO + "',row_number(),'" + MUSER + @"',
|
|
a.LotNO,b.Quantity,b.Quantity*b.Amount as Amount,0,0,'" + MUSERNAME + @"',
|
|
,getdate()," + WorkPoint.TrimEnd(',') + @"
|
|
FROM dbo.ICSContainerLot a
|
|
left JOIN dbo.ICSInventoryLot b ON a.LotNo=b.LotNo AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSInventory c ON c.InvCode=b.InvCode AND a.WorkPoint=c.WorkPoint
|
|
WHERE a.ContainerID IN (" + JsonData.TrimEnd(',') + ") and a.WorkPoint='" + WorkPoint + "'";
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取箱号主表信息
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetCartonGridJson(string queryJson, ref Pagination jqgridparam, string WorkPoint)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @" SELECT a.ID,a.ContainerID,
|
|
a.MUSERName,a.MTIME
|
|
FROM dbo.ICSContainerLot a
|
|
LEFT JOIN
|
|
(SELECT COUNT(x.LotNO) AS LotNoCount,ContainerID,x.WorkPoint FROM dbo.ICSContainerLot x
|
|
LEFT JOIN dbo.ICSInventoryLot y ON x.LotNO=y.LotNO AND x.WorkPoint=y.WorkPoint
|
|
GROUP BY ContainerID,x.WorkPoint) b ON a.ContainerID=b.ContainerID AND a.WorkPoint=b.WorkPoint
|
|
WHERE b.LotNoCount>0
|
|
AND a.ContainerID not IN
|
|
(SELECT b.ContainerID FROM dbo.ICSASNDetail a inner JOIN dbo.ICSContainerLot b ON a.LotNO =b.LotNO AND a.WorkPoint=b.WorkPoint)
|
|
";
|
|
// string sql = @" SELECT Serial,a.CartonNO,CartonStatus,PrintTimes,
|
|
//lastPrintTime,a.MUSERName,a.MTIME,EATTRIBUTE8
|
|
//FROM dbo.ICSCarton a
|
|
//LEFT JOIN
|
|
//(SELECT COUNT(x.LotNO) AS LotNoCount,CartonNO,x.WorkPoint FROM dbo.ICSITEMLot2Carton x
|
|
//LEFT JOIN dbo.ICSITEMLot y ON x.LotNO=y.LotNO AND x.WorkPoint=y.WorkPoint
|
|
//GROUP BY CartonNO,x.WorkPoint having COUNT(x.LotNO)>0) b ON a.CartonNO=b.CartonNO AND a.WorkPoint=b.WorkPoint
|
|
//left join (SELECT b.CartonNO FROM dbo.ICSASNDETAIL a inner JOIN dbo.ICSITEMLot2Carton b ON a.LOTNO =b.LotNO AND a.WorkPoint=b.WorkPoint) c
|
|
//on a.CartonNo=c.CartonNO WHERE a.EATTRIBUTE3='SRM' AND c.CartonNo is null
|
|
//";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["CartonNo"].ToString()))
|
|
{
|
|
sql += " and a.ContainerID like '%" + queryParam["CartonNo"].ToString() + "%' ";
|
|
}
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["OrderNo"].ToString()))
|
|
//{
|
|
// sql += " and b.OrderNO like '%" + queryParam["OrderNo"].ToString() + "%' ";
|
|
//}
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["TransNo"].ToString()))
|
|
//{
|
|
// sql += " and b.TransNO like '%" + queryParam["TransNO"].ToString() + "%' ";
|
|
//}
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["TransLine"].ToString()))
|
|
//{
|
|
// sql += " and b.TransLine like '%" + queryParam["TransLine"].ToString() + "%' ";
|
|
//}
|
|
//if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
//{
|
|
// sql += " and a.EATTRIBUTE8 = '" + queryParam["VenCode"].ToString() + "' ";
|
|
//}
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
|
|
{
|
|
sql += " and a.WorkPoint='" + WorkPoint + "'";
|
|
|
|
}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 箱号子表查询
|
|
/// </summary>
|
|
/// <param name="CartonNo"></param>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetCartonSubGridJson(string CartonNo, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT a.LotNO, a.ID,c.ItemCODE,d.INVNAME,c.VenderLotNO,c.LOTQTY,
|
|
c.TYPE,b.EATTRIBUTE8,c.ORDERNO,c.TransNO,c.TransLine,d.INVDESC,d.INVTYPE,e.MEMO,d.INVSTD,d.INVPARSETYPE
|
|
FROM dbo.ICSITEMLot2Carton a
|
|
LEFT JOIN dbo.ICSCarton b ON a.CartonNO=b.CartonNO AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSITEMLot c ON a.LotNo_ID=c.ID AND a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN dbo.ICSINVENTORY d ON c.ItemCODE=d.INVCODE AND a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN dbo.ICSPO_PoMain e ON c.TransNO=e.POCode AND c.TransLine =e.PORow AND a.WorkPoint=e.WorkPoint
|
|
WHERE a.CartonNO='" + CartonNo + "' and a.WorkPoint='" + WorkPoint + "'";
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
public DataTable GetASNListGridJson(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
// string sql = @"SELECT a.ASNDETAILID, a.STNO,a.ITEMCODE,d.INVNAME,d.INVTYPE,d.INVDESC,h.ReMark,a.LOTNO,b.VenderLotNO,
|
|
//b.LOTQTY,c.CartonNO,e.VENDORCODE,f.cVenName,
|
|
//b.TransNO,b.TransLine,g.F_RealName,CONVERT(NVARCHAR(50),e.CREATETIME,23) as CREATETIME,d.INVSTD,d.INVPARSETYPE,case
|
|
//when a.RECEIVEQTY is null then '否'
|
|
//else '是'
|
|
//end as IsReceive
|
|
//,w.WorkPointName,w.WorkPointCode
|
|
//FROM dbo.ICSASNDETAIL a
|
|
//LEFT JOIN dbo.ICSITEMLot b ON a.LOTNO=b.LotNO AND a.WorkPoint=b.WorkPoint
|
|
//LEFT JOIN dbo.ICSITEMLot2Carton c ON a.LOTNO=c.LotNO AND a.WorkPoint=c.WorkPoint
|
|
//LEFT JOIN dbo.ICSINVENTORY d ON a.ITEMCODE=d.INVCODE AND a.WorkPoint=d.WorkPoint
|
|
//LEFT JOIN dbo.ICSASN e ON a.STNO=e.STNO AND a.WorkPoint=e.WorkPoint
|
|
//LEFT JOIN dbo.ICSVendor f ON e.VENDORCODE=f.cVenCode AND a.WorkPoint=f.WorkPoint
|
|
//LEFT JOIN dbo.Sys_SRM_User g ON e.LOGUSER=g.F_Account and g.F_Location=a.WorkPoint
|
|
//LEFT JOIN dbo.ICSPO_PoMain h ON b.TransNO=h.POCode AND b.TransLine=h.PORow AND a.WorkPoint=h.WorkPoint
|
|
//LEFT JOIN dbo.Sys_WorkPoint w ON a.WorkPoint=w.WorkPointCode
|
|
//where 1=1";
|
|
string sql = @"SELECT a.ASNDETAILID, a.STNO,a.ITEMCODE,d.INVNAME,d.INVTYPE,d.INVDESC,h.ReMark,a.LOTNO,b.VenderLotNO,
|
|
b.LOTQTY,c.CartonNO,e.VENDORCODE,f.cVenName,
|
|
b.TransNO,b.TransLine,g.F_RealName,CONVERT(NVARCHAR(50),e.CREATETIME,23) as CREATETIME,d.INVSTD,d.INVPARSETYPE,case
|
|
when a.RECEIVEQTY is null then '否'
|
|
else '是'
|
|
end as IsReceive
|
|
,w.WorkPointName,w.WorkPointCode,CAST(ISNULL(II.repairqty,0) AS DECIMAL(18,3)) AS RepairQty,CAST(ISNULL(cc.NGQTY,0) AS DECIMAL(18,3))as NGQTY,CAST(ISNULL(cc.YLQTY,0) AS DECIMAL(18,3)) as YLQTY
|
|
FROM dbo.ICSASNDETAIL a
|
|
LEFT JOIN dbo.ICSITEMLot b ON a.LOTNO=b.LotNO AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSITEMLot2Carton c ON a.LOTNO=c.LotNO AND a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN dbo.ICSINVENTORY d ON a.ITEMCODE=d.INVCODE AND a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN dbo.ICSASN e ON a.STNO=e.STNO AND a.WorkPoint=e.WorkPoint
|
|
LEFT JOIN dbo.ICSVendor f ON e.VENDORCODE=f.cVenCode AND a.WorkPoint=f.WorkPoint
|
|
LEFT JOIN dbo.Sys_SRM_User g ON e.LOGUSER=g.F_Account and g.F_Location=a.WorkPoint
|
|
LEFT JOIN dbo.ICSPO_PoMain h ON b.TransNO=h.POCode AND b.TransLine=h.PORow AND a.WorkPoint=h.WorkPoint
|
|
LEFT JOIN dbo.Sys_WorkPoint w ON a.WorkPoint=w.WorkPointCode
|
|
LEFT JOIN (SELECT b.TransNO,b.TransLine,
|
|
(SUM(ISNULL(a.PLANQTY, 0)) - SUM(ISNULL(a.RECEIVEQTY, 0))) AS repairqty,a.WorkPoint
|
|
FROM ICSASNDETAIL a
|
|
LEFT JOIN ICSITEMLot b ON a.LOTNO = b.LotNO AND a.WorkPoint = b.WorkPoint AND a.RECEIVEQTY IS NOT NULL
|
|
GROUP BY b.TransNO,b.TransLine,a.WorkPoint
|
|
) II ON h.POCode = II.TransNO AND h.PORow = II.TransLine AND h.WorkPoint = II.WorkPoint
|
|
left join (
|
|
select b.TransNO,b.TransLine,sum(isnull(a.NLOTQTY,0)) NGQTY,sum(isnull(a.YLOTQTY,0)) YLQTY,a.WorkPoint from ICSINSPECTION a
|
|
left join ICSITEMLot b on a.LOTNO=b.LotNO
|
|
group by b.TransNO,b.TransLine,b.EATTRIBUTE2,a.WorkPoint
|
|
having b.EATTRIBUTE2 is null) cc on h.POCode=cc.TransNO and h.PORow=cc.TransLine AND h.WorkPoint=cc.WorkPoint
|
|
where 1=1";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["STNO"].ToString()))
|
|
{
|
|
sql += " and a.STNO like '%" + queryParam["STNO"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
|
|
{
|
|
sql += " and e.VENDORCODE like '%" + queryParam["VenCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
|
|
{
|
|
sql += " and f.cVenName like '%" + queryParam["VenName"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BeginDate"].ToString()))
|
|
{
|
|
sql += " and e.CREATETIME >= '" + queryParam["BeginDate"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["EndDate"].ToString()))
|
|
{
|
|
sql += " and e.CREATETIME <= '" + queryParam["EndDate"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["VenderLotNO"].ToString()))
|
|
{
|
|
sql += " and b.VenderLotNO = '%" + queryParam["VenderLotNO"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["IsReceive"].ToString()))
|
|
{
|
|
string IsReceive = queryParam["IsReceive"].ToString();
|
|
if (IsReceive == "1")
|
|
{
|
|
sql += " and isnull(a.RECEIVEQTY,0) <>0 ";
|
|
}
|
|
else if (IsReceive == "2")
|
|
{
|
|
sql += " and isnull(a.RECEIVEQTY,0)=0 ";
|
|
}
|
|
}
|
|
}
|
|
sql += " and a.WorkPoint in (" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',') + ")";
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
{
|
|
sql += " and e.VENDORCODE='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
}
|
|
//DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
public DataTable GetASNListExport(string keyVaule)
|
|
{
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT a.STNO AS 送货单号,a.ITEMCODE 物料编码,d.INVNAME 物料名称,d.INVSTD AS 规格型号,
|
|
d.INVPARSETYPE AS 存货代码
|
|
,d.INVTYPE 描述1,d.INVDESC 描述2,h.ReMark 行备注,case
|
|
when a.RECEIVEQTY is null then '否'
|
|
else '是'
|
|
end as 是否到货,
|
|
a.LOTNO 条码,b.VenderLotNO 条码批次,
|
|
b.LOTQTY 数量,c.CartonNO 箱号,e.VENDORCODE 供应商编码,f.cVenName 供应商名称,
|
|
b.TransNO 采购单号,b.TransLine 采购单行,g.F_RealName 维护人, CONVERT(NVARCHAR(50),e.CREATETIME,23) as 维护时间,w.WorkPointName as 站点名称,w.WorkPointCode as 站点编号
|
|
FROM dbo.ICSASNDETAIL a
|
|
LEFT JOIN dbo.ICSITEMLot b ON a.LOTNO=b.LotNO AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSITEMLot2Carton c ON a.LOTNO=c.LotNO AND a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN dbo.ICSINVENTORY d ON a.ITEMCODE=d.INVCODE AND a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN dbo.ICSASN e ON a.STNO=e.STNO AND a.WorkPoint=e.WorkPoint
|
|
LEFT JOIN dbo.ICSVendor f ON e.VENDORCODE=f.cVenCode AND a.WorkPoint=f.WorkPoint
|
|
LEFT JOIN dbo.Sys_SRM_User g ON e.LOGUSER=g.F_Account
|
|
LEFT JOIN dbo.ICSPO_PoMain h ON b.TransNO=h.POCode AND b.TransLine=h.PORow AND a.WorkPoint=h.WorkPoint
|
|
LEFT JOIN dbo.Sys_WorkPoint w ON a.WorkPoint=w.WorkPointCode
|
|
where 1=1";
|
|
sql += " and a.ASNDETAILID in (" + keyVaule + ")";
|
|
sql += " and a.WorkPoint in (" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',') + ")";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
public DataTable GetASNListExport(string ORDERNO, string STNO, string BeginDate, string EndDate, string VenCode, string VenName, string VenderLotNO, string IsReceive)
|
|
{
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT a.STNO AS 送货单号,h.ORDERNO as 项目号,a.ITEMCODE 物料编码,d.INVNAME 物料名称,
|
|
d.INVSTD AS 规格型号,d.INVPARSETYPE AS 存货代码,
|
|
d.INVTYPE 描述1,d.INVDESC 描述2,h.ReMark 行备注,case
|
|
when a.RECEIVEQTY is null then '否'
|
|
else '是'
|
|
end as 是否到货,
|
|
a.LOTNO 条码,b.VenderLotNO 条码批次,
|
|
b.LOTQTY 数量,c.CartonNO 箱号,e.VENDORCODE 供应商编码,f.cVenName 供应商名称,
|
|
b.TransNO 采购单号,b.TransLine 采购单行,g.F_RealName 维护人,CONVERT(NVARCHAR(50),e.CREATETIME,23) as 维护时间,w.WorkPointName as 站点名称,w.WorkPointCode as 站点编号
|
|
FROM dbo.ICSASNDETAIL a
|
|
LEFT JOIN dbo.ICSITEMLot b ON a.LOTNO=b.LotNO AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSITEMLot2Carton c ON a.LOTNO=c.LotNO AND a.WorkPoint=c.WorkPoint
|
|
LEFT JOIN dbo.ICSINVENTORY d ON a.ITEMCODE=d.INVCODE AND a.WorkPoint=d.WorkPoint
|
|
LEFT JOIN dbo.ICSASN e ON a.STNO=e.STNO AND a.WorkPoint=e.WorkPoint
|
|
LEFT JOIN dbo.ICSVendor f ON e.VENDORCODE=f.cVenCode AND a.WorkPoint=f.WorkPoint
|
|
LEFT JOIN dbo.Sys_SRM_User g ON e.LOGUSER=g.F_Account
|
|
LEFT JOIN dbo.ICSPO_PoMain h ON b.TransNO=h.POCode AND b.TransLine=h.PORow AND a.WorkPoint=h.WorkPoint
|
|
LEFT JOIN dbo.Sys_WorkPoint w ON a.WorkPoint=w.WorkPointCode
|
|
where 1=1";
|
|
if (!string.IsNullOrWhiteSpace(ORDERNO))
|
|
sql += " and a.ORDERNO like '%" + ORDERNO + "%'";
|
|
if (!string.IsNullOrWhiteSpace(STNO))
|
|
sql += " and a.STNO like '%" + STNO + "%'";
|
|
if (!string.IsNullOrWhiteSpace(BeginDate))
|
|
sql += " and e.CREATETIME >= '" + BeginDate + "'";
|
|
if (!string.IsNullOrWhiteSpace(BeginDate))
|
|
sql += " and e.CREATETIME <= '" + EndDate + "'";
|
|
if (!string.IsNullOrWhiteSpace(VenCode))
|
|
sql += " and e.VENDORCODE like '%" + VenCode + "%'";
|
|
if (!string.IsNullOrWhiteSpace(VenCode))
|
|
sql += " and f.cVenName like '%" + VenName + "%'";
|
|
if (!string.IsNullOrWhiteSpace(VenderLotNO))
|
|
sql += " and b.VenderLotNO like '%" + VenderLotNO + "%'";
|
|
if (IsReceive == "1")
|
|
{
|
|
sql += " and isnull(a.RECEIVEQTY,0)<>0";
|
|
}
|
|
else if (IsReceive == "2")
|
|
{
|
|
sql += " and isnull(a.RECEIVEQTY,0)=0";
|
|
}
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
|
|
{
|
|
sql += " and e.VENDORCODE='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
|
|
}
|
|
sql += " and a.WorkPoint in (" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',') + ")";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
public string CheckIsAll(string STNO,string WorkPoint)
|
|
{
|
|
string sql = @"SELECT * FROM dbo.ICSASNDetail WHERE ASNCode='" + STNO + "' AND ISNULL(DNQuantity,0)<>0";
|
|
sql += " and WorkPoint in('"+ WorkPoint + "')";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
return "0";
|
|
}
|
|
else
|
|
{
|
|
return "1";
|
|
}
|
|
}
|
|
}
|
|
}
|