纽威
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.
 
 
 
 
 

1314 lines
67 KiB

using NFine.Data.Extensions;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NFine.Code;
using NFine.Repository;
using System.Data.Common;
using NFine.Domain._03_Entity.SRM;
using ICS.Application.Entity;
using Newtonsoft.Json;
using System.Configuration;
using System.Data.SqlClient;
using ICS.Data;
using Newtonsoft.Json.Linq;
using NFine.Domain._03_Entity.WMS;
using System.Net;
using System.IO;
namespace NFine.Application.WMS
{
public class WMSCreateItemLotApp : RepositoryFactory<ICSVendor>
{
public DataTable GetGridJson(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
#region [SQL]
string sql = @"select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,a.Quantity,a.Amount,a.IssueNegQuantity,a.ExtensionID,a.MUSERName,a.MTIME ,c.LOTQTY,f.BatchCode
from ICSMOApplyNegDetail a
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
left join (
select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
group by mm.TransCode,mm.TransSequence,ee.WorkPoint
)c
on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint";
sql += " WHERE 1=1";
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
#endregion
if (!string.IsNullOrWhiteSpace(queryJson))
{
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
{
sql += " and a.POCode like '%" + queryParam["POCode"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
{
sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
{
sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
{
sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
}
}
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
{
sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
}
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 GetSubGridJson(string ApplyNegCode, string Sequence, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
//var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
string sql = @" select c.TransCode,c.TransSequence ,a.ID,a.LotNo,a.Quantity,a.MUSERName,a.MTIME from ICSInventoryLot a
left join (select count(LotNo) LotNoCount,LotNo,WorkPoint from ICSWareHouseLotInfo
group by LotNo,WorkPoint)b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
left join ICSInventoryLotDetail c on a.LotNo=c.LotNo
WHERE c.TransCode='" + ApplyNegCode + "' and c.TransSequence='" + Sequence + "' and a.WorkPoint in ('" + WorkPoint + "')";
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
}
/// <summary>
/// 点击生成条码
/// </summary>
public DataTable GetSubGridJsonByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
//var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @" select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
(a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
from ICSMOApplyNegDetail a
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
left join (
select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
group by b.TransCode,b.TransSequence
) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
WHERE 1 =1
and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
sql += " 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 ApplyNegCode, string Sequence, string keyValue, string WorkPoint)
{
var queryParam = keyValue.ToJObject();
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
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(ApplyNegCode, Sequence, WorkPoint);
string Pre = ApplyNegCode + Sequence;
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;
string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
string sqls = string.Empty;
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
//if (SqlHelper.ExecuteNonQuery(sqls) > 0)
//{
sql += string.Format(@"insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
select
newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'3','{3}','{4}', getdate(),'{5}'
from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence);
sql += "\r\n";
//}
}
int count = SqlHelper.CmdExecuteNonQueryLi(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();
}
/// <summary>
/// 删除条码
/// </summary>
/// <param name="keyValue"></param>
/// <returns></returns>
public string DeleteItemLot(string keyValue)
{
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
string msg = string.Empty;
string sql = string.Format(@"SELECT * FROM dbo.ICSInspection
WHERE LotNo IN (SELECT LotNO FROM dbo.ICSInventoryLot WHERE ID IN ({0})) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
DataTable dtASN = SqlHelper.GetDataTableBySql(sql);
if (dtASN != null && dtASN.Rows.Count > 0)
{
msg = "所选条码已生成检验单,无法删除!";
}
sql = string.Format(@"SELECT * FROM dbo.ICSWareHouseLotInfo WHERE LotNO IN
(SELECT LotNO FROM dbo.ICSInventoryLot WHERE ID IN ({0})) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
DataTable dtCarton = SqlHelper.GetDataTableBySql(sql);
if (dtCarton != null && dtCarton.Rows.Count > 0)
{
msg += "所选条码已入库,无法删除!";
}
if (string.IsNullOrEmpty(msg))
{
string sqls = string.Format("DELETE FROM ICSInventoryLotDetail WHERE LotNO IN (select LotNO from ICSInventoryLot where ID in ({0}) ) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
sqls += string.Format("DELETE FROM dbo.ICSInventoryLot WHERE ID IN ({0}) and WorkPoint in ('{1}')", keyValue.TrimEnd(','), WorkPoint);
SqlHelper.CmdExecuteNonQueryLi(sqls);
}
return msg;
}
public DataTable GetGridJsonWeiWai(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
#region [SQL]
string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,a.Quantity,a.Amount,a.IssueNegQuantity,a.ExtensionID,a.MUSERName,a.MTIME ,c.LOTQTY,f.BatchCode
from ICSOApplyNegDetail a
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
left join (
select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
group by mm.TransCode,mm.TransSequence,ee.WorkPoint
)c
on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint ";
sql += " WHERE 1=1";
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
#endregion
if (!string.IsNullOrWhiteSpace(queryJson))
{
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
{
sql += " and a.OApplyNegCode like '%" + queryParam["POCode"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
{
sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
{
sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
{
sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
}
}
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
{
sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
}
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 GetSubGridJsonWeiWai(string OApplyNegCode, string Sequence, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
//var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
string sql = @" select c.TransCode,c.TransSequence ,a.ID,a.LotNo,a.Quantity from ICSInventoryLot a
left join (select count(LotNo) LotNoCount,LotNo,WorkPoint from ICSWareHouseLotInfo
group by LotNo,WorkPoint)b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
left join ICSInventoryLotDetail c on a.LotNo=c.LotNo
WHERE c.TransCode='" + OApplyNegCode + "' and c.TransSequence='" + Sequence + "' and a.WorkPoint in (" + WorkPoint + ")";
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
}
/// <summary>
/// 点击委外退料生成条码
/// </summary>
public DataTable GetSubGridJsonWeiWaiByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
//var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
(a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
from ICSOApplyNegDetail a
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
left join (
select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
group by b.TransCode,b.TransSequence
) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
WHERE 1 =1
and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
return Repository().FindTableBySql(sql.ToString());
}
/// <summary>
/// 委外退料生成条码
/// </summary>
/// <param name="POCode"></param>
/// <param name="PORow"></param>
/// <param name="keyValue"></param>
/// 已改
/// <returns></returns>
public int SubmitFormWeiWai(string OApplyNegCode, string Sequence, string keyValue, string WorkPoint)
{
var queryParam = keyValue.ToJObject();
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
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(ApplyNegCode, Sequence, WorkPoint);
string Pre = OApplyNegCode + Sequence;
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;
string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
string sqls = string.Empty;
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints);
//if (SqlHelper.ExecuteNonQuery(sqls) > 0)
//{
sql += string.Format(@"insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
select
newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'4','{3}','{4}', getdate(),'{5}'
from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence);
sql += "\r\n";
//}
}
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
return count;
}
public DataTable GetGridJsonChengPing(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
#region [SQL]
string sql = @"select a.ID,a.MOCode,a.Sequence,a.RCVQuantity,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,a.Quantity,a.Amount,a.StartDate,a.DueDate,a.MOStatus,a.ExtensionID,a.MUSERName,a.MTIME ,c.LOTQTY,f.BatchCode
from ICSMO a
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
left join (
select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
group by mm.TransCode,mm.TransSequence,ee.WorkPoint
)c
on a.MOCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint ";
sql += " WHERE 1=1";
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
#endregion
if (!string.IsNullOrWhiteSpace(queryJson))
{
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
{
sql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
{
sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
{
sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
{
sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
}
}
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
{
sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
}
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);
}
/// <summary>
/// 点击成品生成条码(成品)
/// </summary>
public DataTable GetSubGridJsonChengPingByCreate(string MOCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
//var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
(a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
from ICSMO a
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
left join (
select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
group by b.TransCode,b.TransSequence
) c on a.MOCode=c.TransCode and a.Sequence=c.TransSequence
WHERE 1 =1
and a.MOCode='" + MOCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
return Repository().FindTableBySql(sql.ToString());
}
/// <summary>
/// 成品生成条码
/// </summary>
/// <param name="POCode"></param>
/// <param name="PORow"></param>
/// <param name="keyValue"></param>
/// 已改
/// <returns></returns>
public int SubmitFormChengPing(string MOCode, string Sequence, string keyValue, string WorkPoint)
{
var queryParam = keyValue.ToJObject();
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
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(ApplyNegCode, Sequence, WorkPoint);
string Pre = MOCode + Sequence;
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;
string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
string sqls = string.Empty;
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
LotNo, MOCode, Sequence, MUSER, MUSERNAME, WorkPoints);
//if (SqlHelper.ExecuteNonQuery(sqls) > 0)
//{
sql += string.Format(@"insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
select
newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'2','{3}','{4}', getdate(),'{5}'
from ICSMO where MOCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, MOCode, Sequence);
sql += "\r\n";
//}
}
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
return count;
}
public DataTable GetGridJsonXiaoShou(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
#region [SQL]
string sql = @" select a.ID,a.SDNCode,a.Sequence,a.SOCode,a.SOSequence,a.CusCode,a.CusName,a.Type,a.ArriveDate,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,a.Quantity,a.Amount,a.SDNQuantity,a.Status,a.ExtensionID,a.CreatePerson,a.CreateDateTime ,c.LOTQTY,f.BatchCode
from ICSSDN a
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
left join (
select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
group by mm.TransCode,mm.TransSequence,ee.WorkPoint
)c
on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
where a.Type='2'";
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
#endregion
if (!string.IsNullOrWhiteSpace(queryJson))
{
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
{
sql += " and a.MOCode like '%" + queryParam["POCode"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
{
sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
{
sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
{
sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
}
}
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
{
sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
}
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);
}
/// <summary>
/// 点击销售退货生成条码(销售退货)
/// </summary>
public DataTable GetSubGridJsonXiaoShouByCreate(string SDNCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
//var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
(a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
from ICSSDN a
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
left join (
select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
group by b.TransCode,b.TransSequence
) c on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence
WHERE 1 =1
and a.Type='2' and a.SDNCode='" + SDNCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
return Repository().FindTableBySql(sql.ToString());
}
/// <summary>
/// 销售退货生成条码
/// </summary>
/// <param name="POCode"></param>
/// <param name="PORow"></param>
/// <param name="keyValue"></param>
/// 已改
/// <returns></returns>
public int SubmitFormXiaoShou(string SDNCode, string Sequence, string keyValue, string WorkPoint)
{
var queryParam = keyValue.ToJObject();
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
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(ApplyNegCode, Sequence, WorkPoint);
string Pre = SDNCode + Sequence;
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;
string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
string sqls = string.Empty;
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}')",
LotNo, SDNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
//if (SqlHelper.ExecuteNonQuery(sqls) > 0)
//{
sql += string.Format(@"
insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
select
newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'2','{3}','{4}', getdate(),'{5}'
from ICSSDN where Type='2' and SDNCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, SDNCode, Sequence);
sql += "\r\n";
//}
}
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
return count;
}
public DataTable GetGridJsonQiTa(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
#region [SQL]
string sql = @" select a.ID,a.InCode,a.Sequence,a.WHCode,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,a.Quantity,a.Amount,a.InQuantity,a.CreatePerson,a.CreateDateTime,c.LOTQTY,f.BatchCode
from ICSOtherIn a
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
left join (
select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
group by mm.TransCode,mm.TransSequence,ee.WorkPoint
)c
on a.InCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
where a.Status='1'";
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
#endregion
if (!string.IsNullOrWhiteSpace(queryJson))
{
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
{
sql += " and a.InCode like '%" + queryParam["POCode"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
{
sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
{
sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
{
sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
}
}
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
{
sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
}
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);
}
/// <summary>
/// 点击销售退货生成条码(其他入库)
/// </summary>
public DataTable GetSubGridJsonQiTaByCreate(string InCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
//var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
(a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
from ICSOtherIn a
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
left join (
select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
group by b.TransCode,b.TransSequence
) c on a.InCode=c.TransCode and a.Sequence=c.TransSequence
WHERE 1 =1
and a.InCode='" + InCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
return Repository().FindTableBySql(sql.ToString());
}
/// <summary>
/// 其他入库生成条码
/// </summary>
/// <param name="POCode"></param>
/// <param name="PORow"></param>
/// <param name="keyValue"></param>
/// 已改
/// <returns></returns>
public int SubmitFormQiTa(string InCode, string Sequence, string keyValue, string WorkPoint)
{
var queryParam = keyValue.ToJObject();
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
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(ApplyNegCode, Sequence, WorkPoint);
string Pre = InCode + Sequence;
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;
string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
string sqls = string.Empty;
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
LotNo, InCode, Sequence, MUSER, MUSERNAME, WorkPoints);
//if (SqlHelper.ExecuteNonQuery(sqls) > 0)
//{
sql += string.Format(@"
insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
select
newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'2','{3}','{4}', getdate(),'{5}'
from ICSOtherIn where InCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, InCode, Sequence);
sql += "\r\n";
//}
}
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
return count;
}
//归还
public DataTable GetGridJsonGuiHuan(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
#region [SQL]
string sql = @"select a.ID,a.ReturnCode,a.Sequence,a.WHCode,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,a.Quantity,a.Amount,a.ReturnQuantity,a.CreatePerson,a.CreateDateTime,c.LOTQTY ,f.BatchCode from ICSReturn a
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
left join (
select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
group by mm.TransCode,mm.TransSequence,ee.WorkPoint
) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
where a.Status='2'";
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
#endregion
if (!string.IsNullOrWhiteSpace(queryJson))
{
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
{
sql += " and a.ReturnCode like '%" + queryParam["POCode"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
{
sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
{
sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
{
sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
}
}
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
{
sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
}
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 GetGridJsonSHDH(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
#region [SQL]
string sql = @"select a.ID, d.POCode,d.Sequence as POSequence,a.DNCode,a.Sequence,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,a.Quantity,a.Amount,a.RCVQuantity,a.UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,c.LOTQTY ,f.BatchCode
from ICSDeliveryNotice a
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
left join (
select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
group by mm.TransCode,mm.TransSequence,ee.WorkPoint
) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
inner join ICSPurchaseOrder d on a.POID=d.POID and a.PODetailID=d.PODetailID and a.WorkPoint=d.WorkPoint
left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
where a.Status='2' and a.ASNCode is null
";
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
#endregion
if (!string.IsNullOrWhiteSpace(queryJson))
{
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
{
sql += " and a.DNCode like '%" + queryParam["POCode"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
{
sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
{
sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
{
sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
{
sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
{
sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
}
}
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
{
sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
}
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 GetGridJsonWWSHDH(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
#region [SQL]
string sql = @"select a.ID, d.OOCode,d.Sequence as OOSequence,a.ODNCode,a.Sequence,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvName,b.InvStd,b.InvDesc,b.InvUnit,a.Quantity,a.Amount,a.RCVQuantity,a.UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,c.LOTQTY ,f.BatchCode
from ICSODeliveryNotice a
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
left join (
select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
group by mm.TransCode,mm.TransSequence,ee.WorkPoint
) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
inner join ICSOutsourcingOrder d on a.OOID=d.OOID and a.OODetailID=d.OODetailID and a.WorkPoint=d.WorkPoint
left join ICSVendor e on a.VenCode=e.VenCode and a.WorkPoint=e.WorkPoint
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
where a.ODNType='1' and a.Status='2' and a.OASNCode is null";
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
#endregion
if (!string.IsNullOrWhiteSpace(queryJson))
{
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
{
sql += " and a.ODNCode like '%" + queryParam["POCode"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
{
sql += " and a.VenCode like '%" + queryParam["VenCode"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
{
sql += " and e.VenName like '%" + queryParam["VenName"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
{
sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
{
sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
{
sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
}
}
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
{
sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
}
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 GetGridJsonKLCPRK(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
#region [SQL]
string sql = @"
select a.ID,a.RCVCode,a.Sequence,a.WHCode,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,a.Quantity,a.Amount,a.RCVQuantity,a.CreatePerson,a.CreateDateTime,c.LOTQTY,f.BatchCode
from ICSManufactureReceive a
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
left join (
select mm.TransCode,mm.TransSequence,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo
group by mm.TransCode,mm.TransSequence,ee.WorkPoint
) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence and a.WorkPoint=c.WorkPoint
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
where a.Status='1' and a.Type='1'";
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
#endregion
if (!string.IsNullOrWhiteSpace(queryJson))
{
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
{
sql += " and a.RCVCode like '%" + queryParam["POCode"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
{
sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString()))
{
sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString()))
{
sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' ";
}
}
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
{
sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
}
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);
}
/// <summary>
/// 点击审核委外到货单生成条码(审核委外到货单)
/// </summary>
public DataTable GetSubGridJsonWWSHDHByCreate(string ODNCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
//var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
(a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
from ICSODeliveryNotice a
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
group by b.TransCode,b.TransSequence
) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
WHERE 1 =1
and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
return Repository().FindTableBySql(sql.ToString());
}
/// <summary>
/// 点击开立成品入库生成条码(开立成品入库单)
/// </summary>
public DataTable GetSubGridJsonKLCPRKByCreate(string RCVCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
//var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
(a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
from ICSManufactureReceive a
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
group by b.TransCode,b.TransSequence
) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence
WHERE 1 =1
and a.RCVCode='" + RCVCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
return Repository().FindTableBySql(sql.ToString());
}
/// <summary>
/// 点击审核到货单生成条码(审核到货单)
/// </summary>
public DataTable GetSubGridJsonSHDHByCreate(string DNCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
//var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
(a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
from ICSDeliveryNotice a
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
group by b.TransCode,b.TransSequence
) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence
WHERE 1 =1
and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
return Repository().FindTableBySql(sql.ToString());
}
/// <summary>
/// 点击归还生成条码(归还)
/// </summary>
public DataTable GetSubGridJsonGuiHuanByCreate(string ReturnCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
//var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
(a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty
from ICSReturn a
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo
group by b.TransCode,b.TransSequence
) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence
WHERE 1 =1
and a.ReturnCode='" + ReturnCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
return Repository().FindTableBySql(sql.ToString());
}
/// <summary>
/// 归还单生成条码
/// </summary>
/// <param name="POCode"></param>
/// <param name="PORow"></param>
/// <param name="keyValue"></param>
/// 已改
/// <returns></returns>
public int SubmitFormGuiHuan(string ReturnCode, string Sequence, string keyValue, string WorkPoint)
{
var queryParam = keyValue.ToJObject();
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
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 Pre = ReturnCode + Sequence;
string sql = string.Empty;
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
string sqls = string.Empty;
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
LotNo, ReturnCode, Sequence, MUSER, MUSERNAME, WorkPoints);
//if (SqlHelper.ExecuteNonQuery(sqls) > 0)
//{
sql += string.Format(@"
insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
select
newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'2','{3}','{4}', getdate(),'{5}'
from ICSReturn where ReturnCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ReturnCode, Sequence);
sql += "\r\n";
//}
}
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
return count;
}
/// <summary>
/// 审核到货单生成条码
/// </summary>
/// <param name="POCode"></param>
/// <param name="PORow"></param>
/// <param name="keyValue"></param>
/// 已改
/// <returns></returns>
public int SubmitFormSHDH(string DNCode, string Sequence, string keyValue, string WorkPoint)
{
var queryParam = keyValue.ToJObject();
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
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 Pre = DNCode + Sequence;
string sql = string.Empty;
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
string sqls = string.Empty;
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
//if (SqlHelper.ExecuteNonQuery(sqls) > 0)
//{
sql += string.Format(@"
insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
select
newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'2','{3}','{4}', getdate(),'{5}'
from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence);
sql += "\r\n";
//}
}
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
return count;
}
/// <summary>
/// 审核委外到货单生成条码
/// </summary>
/// <param name="POCode"></param>
/// <param name="PORow"></param>
/// <param name="keyValue"></param>
/// 已改
/// <returns></returns>
public int SubmitFormWWSHDH(string ODNCode, string Sequence, string keyValue, string WorkPoint)
{
var queryParam = keyValue.ToJObject();
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
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 Pre = ODNCode + Sequence;
string sql = string.Empty;
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
string sqls = string.Empty;
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints);
//if (SqlHelper.ExecuteNonQuery(sqls) > 0)
//{
sql += string.Format(@"
insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
select
newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'2','{3}','{4}', getdate(),'{5}'
from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence);
sql += "\r\n";
//}
}
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
return count;
}
/// <summary>
/// 开立成品入库单
/// </summary>
/// <param name="POCode"></param>
/// <param name="PORow"></param>
/// <param name="keyValue"></param>
/// 已改
/// <returns></returns>
public int SubmitFormKLCPRK(string RCVCode, string Sequence, string keyValue, string WorkPoint)
{
var queryParam = keyValue.ToJObject();
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
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 Pre = RCVCode + Sequence;
string sql = string.Empty;
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
string sqls = string.Empty;
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5);
sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
LotNo, RCVCode, Sequence, MUSER, MUSERNAME, WorkPoints);
//if (SqlHelper.ExecuteNonQuery(sqls) > 0)
//{
sql += string.Format(@"
insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
select
newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'2','{3}','{4}', getdate(),'{5}'
from ICSManufactureReceive where RCVCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, RCVCode, Sequence);
sql += "\r\n";
//}
}
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
return count;
}
}
}