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.
 
 
 
 
 

4950 lines
305 KiB

using NFine.Data.Extensions;
using System;
using System.Collections.Generic;
using System.Data;
using NFine.Code;
using NFine.Repository;
using System.Data.Common;
using NFine.Domain._03_Entity.SRM;
using System.Configuration;
using System.Text;
using System.Net;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using System.IO;
using System.Data.SqlClient;
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>();
object Figure = GetDecimalDigits();
#region [SQL]
string sql = @"select a.ID,y.MOCode,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
,CAST(a.Amount AS DECIMAL(18,{0})) as Amount , CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME , CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
from ICSMOApplyNegDetail a
left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
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 and ee.type='1'
where isnull(ee.EATTRIBUTE1,'')=''
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
inner JOIN ICSMOPick x ON a.SourceDetailID=x.PickID AND a.WorkPoint=x.WorkPoint
left JOIN ICSMO y ON x.MODetailID=y.MODetailID AND x.WorkPoint=y.WorkPoint
where d.Type='1'";
sql = string.Format(sql, Figure);
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
#endregion
if (!string.IsNullOrWhiteSpace(queryJson))
{
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
{
sql += " and a.ApplyNegCode 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 (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
{
string POStatus = queryParam["POStatus"].ToString();
if (POStatus == "0")
{
//sql += " and a.Quantity=ISNULL(c.LotQty,0)";
}
else if (POStatus == "1")
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
}
else
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
}
}
}
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>
/// <param name="MODetailID"></param>
/// <param name="workpoint"></param>
/// <param name="jqgridparam"></param>
/// <returns></returns>
public DataTable GetICSMOPick(string MODetailID,string workpoint, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
List<DbParameter> parameter = new List<DbParameter>();
object Figure = GetDecimalDigits();
#region [SQL]
string sql = @"SELECT b.InvCode,c.InvName,c.InvStd,InvUnit,b.ID,b.Quantity,b.IssueQuantity FROM dbo.ICSMO a
LEFT JOIN dbo.ICSMOPick b ON a.MODetailID=b.MODetailID AND a.WorkPoint=b.WorkPoint
LEFT JOIN dbo.ICSInventory c ON b.InvCode=c.InvCode AND b.WorkPoint=c.WorkPoint
WHERE a.MODetailID='{0}'
";
sql = string.Format(sql, MODetailID);
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
#endregion
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
}
public DataTable GetSubGridJson(string ApplyNegCode, string Sequence, string Type, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
object Figure = GetDecimalDigits();
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, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity ,a.MUSERName,a.MTIME
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,
case when isnull(d.ID,'')='' then '未入库' else '已入库' end as isStorage,
case when g.InvIQC='1'and isnull(e.ID,'')='' then '未检验' else '免检' end as isInspection,
case when g.InvIQC='1' then '是' else '否' end as isExemption,a.Amount,
convert(varchar(20),a.ProductDate,23) as ProductDate,convert(varchar(20),a.ExpirationDate,23) as ExpirationDate ,g.EffectiveDays
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 and a.WorkPoint=c.WorkPoint
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
left join dbo.ICSWareHouseLotInfo d on a.LotNo=d.LotNo and a.WorkPoint=d.WorkPoint
left join ICSInspection e on a.LotNo=e.LotNo and e.Enable='1' and a.WorkPoint=e.WorkPoint
left join ICSInventory g on a.InvCode=g.InvCode and a.WorkPoint=g.WorkPoint
WHERE isnull(a.EATTRIBUTE1,'')='' and a.Type='" + Type + "' and c.TransCode='" + ApplyNegCode + "' and c.TransSequence='" + Sequence + "' and a.WorkPoint in ('" + WorkPoint + "')";
sql = string.Format(sql, Figure);
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
}
/// <summary>
/// 点击生成条码
/// </summary>
public DataTable GetSubGridJsonByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
object Figure = GetDecimalDigits();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,4)) as Quantity, CAST( a.Amount as DECIMAL(18,4)) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,4)) as CreatedQty ,
CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,4)) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,4)) as EffectiveDays,
d.ProjectCode,d.BatchCode,d.Version,d.Brand,d.cFree1,d.cFree2,d.cFree3,d.cFree4,d.cFree5,d.cFree6,d.cFree7,d.cFree8,d.cFree9,d.cFree10
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 and a.Type='1'
where isnull(a.EATTRIBUTE1,'')=''
group by b.TransCode,b.TransSequence
) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
left join ICSExtension d on a.ExtensionID=d.ID and a.WorkPoint=d.WorkPoint
WHERE 1 =1
and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
sql = string.Format(sql, Figure);
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,string AMEnable)
{
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 = "MDN" + ApplyNegCode + (Convert.ToInt32(Sequence)).ToString("D4");
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 InvCode = queryParam["ClassCode"].ToString();
string Colspan = "";
string sqls = string.Empty;
string LotNo = string.Empty;
string str1 = "";
List<string> ExtensionIDList = new List<string>();
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
bool flag = true;
foreach (var item in ExtensionIDList)
{
if (item == Colspan + WorkPoint)
{
flag = false;
}
}
if (ExtensionID == null && flag == true)
{
str1 = Guid.NewGuid().ToString();
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
str1, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
MUSER, MUSERNAME, WorkPoints);
}
else if (ExtensionID != null)
{
str1 = ExtensionID.ToString();
}
ExtensionIDList.Add(Colspan + WorkPoint);
//传过来的参数判断是否是奥美的项目奥美项目执行独有生成条码规则
if (AMEnable == "true")
{
LotNo = SqlHelper.GetLOTNumber(InvCode,WorkPoint);
}
else
{
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,Amount
,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
select
newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','1','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, str1, Convert.ToDecimal( Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY)/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
, queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
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 Repository().FindTableBySql(sql.ToString());
return SqlHelper.ExecuteScalar(sql).ToString();
//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>();
object Figure = GetDecimalDigits();
#region [SQL]
string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit, CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
,CAST(a.Amount AS DECIMAL(18,{0})) as Amount , CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity,a.ExtensionID,a.MUSERName,a.MTIME ,
CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
from ICSOApplyNegDetail a
left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
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 and ee.type='2'
where isnull(ee.EATTRIBUTE1,'')=''
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
WHERE d.Type='1' ";
sql = string.Format(sql, Figure);
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 (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
{
string POStatus = queryParam["POStatus"].ToString();
if (POStatus == "0")
{
//sql += " and a.Quantity=ISNULL(c.LotQty,0)";
}
else if (POStatus == "1")
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
}
else
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
}
}
}
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();
object Figure = GetDecimalDigits();
//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,CAST(a.Quantity AS DECIMAL(18,{0})) as 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 + ")";
sql = string.Format(sql, Figure);
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
}
/// <summary>
/// 点击委外退料生成条码
/// </summary>
public DataTable GetSubGridJsonWeiWaiByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
object Figure = GetDecimalDigits();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
,e.ProjectCode,e.BatchCode,e.Version,e.Brand,e.cFree1,e.cFree2,e.cFree3,e.cFree4,e.cFree5,e.cFree6,e.cFree7,e.cFree8,e.cFree9,e.cFree10
from ICSOApplyNegDetail a
left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
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 and a.Type='2'
where isnull(a.EATTRIBUTE1,'')=''
group by b.TransCode,b.TransSequence
) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
left join ICSExtension e on a.ExtensionID=e.ID and a.WorkPoint=e.WorkPoint
WHERE d.Type='1'
and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
sql = string.Format(sql, Figure);
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 Pre = "OI" + OApplyNegCode + (Convert.ToInt32(Sequence)).ToString("D4");
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;
string Colspan = "";
List<string> ExtensionIDList = new List<string>();
string str1 = "";
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
bool flag = true;
foreach (var item in ExtensionIDList)
{
if (item == Colspan + WorkPoint)
{
flag = false;
}
}
if (ExtensionID == null && flag == true)
{
str1 = Guid.NewGuid().ToString();
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
str1, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
MUSER, MUSERNAME, WorkPoints);
}
else if (ExtensionID != null)
{
str1 = ExtensionID.ToString();
}
ExtensionIDList.Add(Colspan + WorkPoint);
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);
sql += string.Format(@"insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount
,EATTRIBUTE1,EATTRIBUTE2,,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
select
newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','2','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()
, queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString() );
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>();
object Figure = GetDecimalDigits();
#region [SQL]
string sql = @" select distinct a.ID, a.MODetailID,a.MOCode,a.Sequence, CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity ,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount,a.StartDate
,a.DueDate,a.MOStatus,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY ,CAST( a.Quantity AS DECIMAL(18,{0})) -CAST(a.RCVQuantity AS DECIMAL(18,{0})) as ERPNum,a.MOMemo
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
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 and ee.type='3'
where isnull(ee.EATTRIBUTE1,'')=''
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 and a.MOStatus<>'3' ";
sql = string.Format(sql, Figure);
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 (!string.IsNullOrWhiteSpace(queryParam["SelGDLX"].ToString()))
{
sql += " and a.MOType like '%" + queryParam["SelGDLX"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
{
string POStatus = queryParam["POStatus"].ToString();
if (POStatus == "0")
{
//sql += " and a.Quantity=ISNULL(c.LotQty,0)";
}
else if (POStatus == "1")
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
}
else
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)>0";
}
}
}
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();
object Figure = GetDecimalDigits();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select d.Enable, a.InvCode,b.ClassCode,b.InvName,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
,e.ProjectCode,e.BatchCode,e.Version,e.Brand,e.cFree1,e.cFree2,e.cFree3,e.cFree4,e.cFree5,e.cFree6,e.cFree7,e.cFree8,e.cFree9,e.cFree10
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 and a.Type='3'
where isnull(a.EATTRIBUTE1,'')=''
group by b.TransCode,b.TransSequence
) c on a.MOCode=c.TransCode and a.Sequence=c.TransSequence
left join ICSConfiguration d on d.Code='CompleteVerification001' and a.WorkPoint =d.WorkPoint
left join ICSExtension e on a.ExtensionID=e.ID and a.WorkPoint=e.WorkPoint
WHERE 1 =1 and a.MOStatus<>'3'
and a.MOCode='" + MOCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
sql = string.Format(sql, Figure);
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 = "CP" + MOCode + (Convert.ToInt32(Sequence)).ToString("D4");
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 InvCode = queryParam["ClassCode"].ToString();
string sqls = string.Empty;
string Colspan = "";
string str1 = "";
string LotNo = string.Empty;
List<string> ExtensionIDList = new List<string>();
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
bool flag = true;
foreach (var item in ExtensionIDList)
{
if (item == Colspan + WorkPoint)
{
flag = false;
}
}
if (ExtensionID == null && flag == true)
{
str1 = Guid.NewGuid().ToString();
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
str1, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
MUSER, MUSERNAME, WorkPoints);
}
else if (ExtensionID != null)
{
str1 = ExtensionID.ToString();
}
ExtensionIDList.Add(Colspan + WorkPoint);
//传过来的参数判断是否是奥美的项目奥美项目执行独有生成条码规则
//if (AMEnable == "true")
//{
// LotNo = SqlHelper.GetLOTNumber(InvCode, WorkPoint);
//}vvv
//else
//{
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,Amount
,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
select
newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','3','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
from ICSMO where MOCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, MOCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()
, queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
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>();
object Figure = GetDecimalDigits();
#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,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity
,cast(a.Amount as decimal(18,{0})) as Amount, CAST(a.SDNQuantity AS DECIMAL(18,{0})) as SDNQuantity ,a.Status,a.ExtensionID,a.CreatePerson,a.CreateDateTime ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
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 and ee.type='4'
where isnull(ee.EATTRIBUTE1,'')=''
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, Figure);
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
#endregion
if (!string.IsNullOrWhiteSpace(queryJson))
{
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
{
sql += " and a.SDNCode 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 (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
{
string POStatus = queryParam["POStatus"].ToString();
if (POStatus == "0")
{
//sql += " and a.Quantity=ISNULL(c.LotQty,0)";
}
else if (POStatus == "1")
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
}
else
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
}
}
}
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();
object Figure = GetDecimalDigits();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
,d.ProjectCode,d.BatchCode,d.Version,d.Brand,d.cFree1,d.cFree2,d.cFree3,d.cFree4,d.cFree5,d.cFree6,d.cFree7,d.cFree8,d.cFree9,d.cFree10
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 and a.Type='4'
where isnull(a.EATTRIBUTE1,'')=''
group by b.TransCode,b.TransSequence
) c on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence
left join ICSExtension d on a.ExtensionID=d.ID and a.WorkPoint=d.WorkPoint
WHERE 1 =1
and a.Type='2' and a.SDNCode='" + SDNCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
sql = string.Format(sql, Figure);
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,string AMEnable)
{
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 = "SR" + SDNCode + (Convert.ToInt32(Sequence)).ToString("D4");
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 InvCode = queryParam["ClassCode"].ToString();
string sqls = string.Empty;
string Colspan = "";
string str1 = "";
string LotNo = string.Empty;
List<string> ExtensionIDList = new List<string>();
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
bool flag = true;
foreach (var item in ExtensionIDList)
{
if (item == Colspan + WorkPoint)
{
flag = false;
}
}
if (ExtensionID == null && flag == true)
{
str1 = Guid.NewGuid().ToString();
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
str1, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
MUSER, MUSERNAME, WorkPoints);
}
else if (ExtensionID != null)
{
str1 = ExtensionID.ToString();
}
ExtensionIDList.Add(Colspan + WorkPoint);
//传过来的参数判断是否是奥美的项目奥美项目执行独有生成条码规则
if (AMEnable == "true")
{
LotNo = SqlHelper.GetLOTNumber(InvCode, WorkPoint);
}
else
{
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,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
select
newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','4','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
from ICSSDN where Type='2' and SDNCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, SDNCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
, queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
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>();
object Figure = GetDecimalDigits();
#region [SQL]
string sql = @" select a.ID,a.InCode,a.Sequence,a.WHCode,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,
CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST(a.Amount AS DECIMAL(18,{0})) as Amount, CAST(a.InQuantity AS DECIMAL(18,{0})) as InQuantity,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
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 and ee.type='5'
where isnull(ee.EATTRIBUTE1,'')=''
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, Figure);
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 (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
{
string POStatus = queryParam["POStatus"].ToString();
if (POStatus == "0")
{
//sql += " and a.Quantity=ISNULL(c.LotQty,0)";
}
else if (POStatus == "1")
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
}
else
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
}
}
}
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();
object Figure = GetDecimalDigits();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
,d.ProjectCode,d.BatchCode,d.Version,d.Brand,d.cFree1,d.cFree2,d.cFree3,d.cFree4,d.cFree5,d.cFree6,d.cFree7,d.cFree8,d.cFree9,d.cFree10
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 and a.Type='5'
where isnull(a.EATTRIBUTE1,'')=''
group by b.TransCode,b.TransSequence
) c on a.InCode=c.TransCode and a.Sequence=c.TransSequence
left join ICSExtension d on a.ExtensionID=d.ID and a.WorkPoint=d.WorkPoint
WHERE 1 =1
and a.InCode='" + InCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
sql = string.Format(sql, Figure);
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,string AMEnable)
{
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 = "QT" + InCode + (Convert.ToInt32(Sequence)).ToString("D4");
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 InvCode = queryParam["ClassCode"].ToString();
string sqls = string.Empty;
string Colspan = "";
string str1 = "";
string LotNo = string.Empty;
List<string> ExtensionIDList = new List<string>();
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
bool flag = true;
foreach (var item in ExtensionIDList)
{
if (item == Colspan + WorkPoint)
{
flag = false;
}
}
if (ExtensionID == null && flag == true)
{
str1 = Guid.NewGuid().ToString();
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
str1, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
MUSER, MUSERNAME, WorkPoints);
}
else if (ExtensionID != null)
{
str1 = ExtensionID.ToString();
}
ExtensionIDList.Add(Colspan + WorkPoint);
//传过来的参数判断是否是奥美的项目奥美项目执行独有生成条码规则
if (AMEnable == "true")
{
LotNo = SqlHelper.GetLOTNumber(InvCode, WorkPoint);
}
else
{
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,Amount
,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
select
newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','5','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
from ICSOtherIn where InCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, InCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
, queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
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>();
object Figure = GetDecimalDigits();
#region [SQL]
string sql = @"select a.ID,a.ReturnCode,a.Sequence,a.WHCode,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount, CAST(a.ReturnQuantity AS DECIMAL(18,{0})) as ReturnQuantity,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
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 and ee.type='6'
where isnull(ee.EATTRIBUTE1,'')=''
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, Figure);
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 (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
{
string POStatus = queryParam["POStatus"].ToString();
if (POStatus == "0")
{
//sql += " and a.Quantity=ISNULL(c.LotQty,0)";
}
else if (POStatus == "1")
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
}
else
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
}
}
}
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>();
object Figure = GetDecimalDigits();
#region [SQL]
string sql = @"select distinct 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,
CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST(a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
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 and ee.type='7'
where isnull(ee.EATTRIBUTE1,'')=''
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.DNType='1' and a.Status='2' and a.ASNCode is null
";
sql = string.Format(sql, Figure);
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 (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
{
string POStatus = queryParam["POStatus"].ToString();
if (POStatus == "0")
{
//sql += " and a.Quantity=ISNULL(c.LotQty,0)";
}
else if (POStatus == "1")
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
}
else
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
}
}
}
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>();
object Figure = GetDecimalDigits();
#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.InvStd,b.InvDesc,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST(a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,
CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY ,d.OODetailID ,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10 ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
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 and ee.type='8'
where isnull(ee.EATTRIBUTE1,'')=''
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, Figure);
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 (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
{
string POStatus = queryParam["POStatus"].ToString();
if (POStatus == "0")
{
//sql += " and a.Quantity=ISNULL(c.LotQty,0)";
}
else if (POStatus == "1")
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
}
else
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
}
}
}
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>();
object Figure = GetDecimalDigits();
#region [SQL]
string sql = @"
select a.ID,a.RCVCode,a.Sequence,a.WHCode,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,
CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity ,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
,b.EffectiveEnable,b.EffectiveDays
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
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 and ee.type='9'
where isnull(ee.EATTRIBUTE1,'')=''
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, Figure);
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 (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
{
string POStatus = queryParam["POStatus"].ToString();
if (POStatus == "0")
{
//sql += " and a.Quantity=ISNULL(c.LotQty,0)";
}
else if (POStatus == "1")
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
}
else
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
}
}
}
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();
object Figure = GetDecimalDigits();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select e.Enable, a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
,d.ProjectCode,d.BatchCode,d.Version,d.Brand,d.cFree1,d.cFree2,d.cFree3,d.cFree4,d.cFree5,d.cFree6,d.cFree7,d.cFree8,d.cFree9,d.cFree10
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 and a.Type='8'
where isnull(a.EATTRIBUTE1,'')=''
group by b.TransCode,b.TransSequence
) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
left join ICSConfiguration e on e.Code='CompleteVerification002' and a.WorkPoint =e.WorkPoint
left join ICSExtension d on a.ExtensionID=d.ID and a.WorkPoint=d.WorkPoint
WHERE 1 =1
and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
sql = string.Format(sql, Figure);
return Repository().FindTableBySql(sql.ToString());
}
/// <summary>
/// 点击开立成品入库生成条码(开立成品入库单)
/// </summary>
/// //--
public DataTable GetSubGridJsonKLCPRKByCreate(string RCVCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
object Figure = GetDecimalDigits();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
,d.ProjectCode,d.BatchCode,d.Version,d.Brand,d.cFree1,d.cFree2,d.cFree3,d.cFree4,d.cFree5,d.cFree6,d.cFree7,d.cFree8,d.cFree9,d.cFree10
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 and a.Type='9'
where isnull(a.EATTRIBUTE1,'')=''
group by b.TransCode,b.TransSequence
) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence
left join ICSExtension d on a.ExtensionID=d.ID and a.WorkPoint=d.WorkPoint
WHERE 1 =1
and a.RCVCode='" + RCVCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
sql = string.Format(sql, Figure);
return Repository().FindTableBySql(sql.ToString());
}
/// <summary>
/// 点击审核到货单生成条码(审核到货单)
/// </summary>
public DataTable GetSubGridJsonSHDHByCreate(string DNCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
object Figure = GetDecimalDigits();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
,d.ProjectCode,d.BatchCode,d.Version,d.Brand,d.cFree1,d.cFree2,d.cFree3,d.cFree4,d.cFree5,d.cFree6,d.cFree7,d.cFree8,d.cFree9,d.cFree10
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 and a.Type='7'
where isnull(a.EATTRIBUTE1,'')=''
group by b.TransCode,b.TransSequence
) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence
left join ICSExtension d on a.ExtensionID=d.ID and a.WorkPoint=d.WorkPoint
WHERE 1 =1
and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
sql = string.Format(sql, Figure);
return Repository().FindTableBySql(sql.ToString());
}
/// <summary>
/// 点击归还生成条码(归还)
/// </summary>
public DataTable GetSubGridJsonGuiHuanByCreate(string ReturnCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
object Figure = GetDecimalDigits();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
,d.ProjectCode,d.BatchCode,d.Version,d.Brand,d.cFree1,d.cFree2,d.cFree3,d.cFree4,d.cFree5,d.cFree6,d.cFree7,d.cFree8,d.cFree9,d.cFree10
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 and a.Type='6'
where isnull(a.EATTRIBUTE1,'')=''
group by b.TransCode,b.TransSequence
) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence
left join ICSExtension d on a.ExtensionID=d.ID and a.WorkPoint=d.WorkPoint
WHERE 1 =1
and a.ReturnCode='" + ReturnCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
sql = string.Format(sql, Figure);
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 = "GH" + ReturnCode + (Convert.ToInt32(Sequence)).ToString("D4");
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;
string Colspan = "";
string str1="";
List<string> ExtensionIDList = new List<string>();
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
bool flag = true;
foreach (var item in ExtensionIDList)
{
if (item == Colspan + WorkPoint)
{
flag = false;
}
}
if (ExtensionID == null && flag == true)
{
str1 = Guid.NewGuid().ToString();
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
str1, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
MUSER, MUSERNAME, WorkPoints);
}
else if (ExtensionID != null)
{
str1 = ExtensionID.ToString();
}
ExtensionIDList.Add(Colspan + WorkPoint);
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,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
select
newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','6','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
from ICSReturn where ReturnCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ReturnCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
, queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
sql += "\r\n";
//}
}
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
return count;
}
/// <summary>
/// 审核到货单生成条码
/// </summary>
/// <param name="POCode"></param>
/// <param name="PORow"></param>
/// <param name="keyValue"></param>
/// 2023 1117 传过来的参数判断是否是奥美的项目奥美项目执行独有生成条码规则 lacy.xu
/// <returns></returns>
public int SubmitFormSHDH(string DNCode, string Sequence, string keyValue, string WorkPoint,string AMEnable)
{
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 = "DN" + DNCode + (Convert.ToInt32(Sequence)).ToString("D4");
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 InvCode = queryParam["ClassCode"].ToString();
string sqls = string.Empty;
string Colspan = "";
string str1 = "";
string LotNo = string.Empty;
List<string> ExtensionIDList = new List<string>();
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
bool flag = true;
foreach (var item in ExtensionIDList)
{
if (item == Colspan + WorkPoint)
{
flag = false;
}
}
if (ExtensionID == null && flag == true)
{
str1 = Guid.NewGuid().ToString();
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
str1, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
MUSER, MUSERNAME, WorkPoints);
}
else if (ExtensionID != null)
{
str1 = ExtensionID.ToString();
}
ExtensionIDList.Add(Colspan + WorkPoint);
//传过来的参数判断是否是奥美的项目奥美项目执行独有生成条码规则
if (AMEnable == "true")
{
LotNo = SqlHelper.GetLOTNumber(InvCode, WorkPoint);
}
else
{
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);
sql += string.Format(@"
insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
select
newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','7','{3}','{4}', getdate(),'{5}','{9}'
,'{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
, queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
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>
/// 2023 1117 传过来的参数判断是否是奥美的项目奥美项目执行独有生成条码规则 lacy.xu
public int SubmitFormWWSHDH(string ODNCode, string Sequence, string keyValue, string WorkPoint,string AMEnable)
{
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 = "ODN" + ODNCode + (Convert.ToInt32(Sequence)).ToString("D4");
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 InvCode = queryParam["ClassCode"].ToString();
string sqls = string.Empty;
string Colspan = "";
string str1 = "";
string LotNo = string.Empty;
List<string> ExtensionIDList = new List<string>();
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
bool flag = true;
foreach (var item in ExtensionIDList)
{
if (item == Colspan + WorkPoint)
{
flag = false;
}
}
if (ExtensionID == null && flag == true)
{
str1 = Guid.NewGuid().ToString();
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
str1, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
MUSER, MUSERNAME, WorkPoints);
}
else if (ExtensionID != null)
{
str1 = ExtensionID.ToString();
}
ExtensionIDList.Add(Colspan + WorkPoint);
//传过来的参数判断是否是奥美的项目奥美项目执行独有生成条码规则
if (AMEnable == "true")
{
LotNo = SqlHelper.GetLOTNumber(InvCode, WorkPoint);
}
else
{
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);
sql += string.Format(@"
insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
select
newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','8','{3}','{4}', getdate(),'{5}','{9}'
,'{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
, queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
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 = "KCP" + RCVCode + (Convert.ToInt32(Sequence)).ToString("D4");
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;
string Colspan = "";
string str1 = "";
List<string> ExtensionIDList = new List<string>();
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
bool flag = true;
foreach (var item in ExtensionIDList)
{
if (item == Colspan + WorkPoint)
{
flag = false;
}
}
if (ExtensionID == null && flag == true)
{
str1 = Guid.NewGuid().ToString();
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
str1, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
MUSER, MUSERNAME, WorkPoints);
}
else if (ExtensionID != null)
{
str1 = ExtensionID.ToString();
}
ExtensionIDList.Add(Colspan + WorkPoint);
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);
sql += string.Format(@"
insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
select
newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','9','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
from ICSManufactureReceive where RCVCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, RCVCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
, queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
sql += "\r\n";
}
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
return count;
}
//委外拒收单
public DataTable GetGridJsonWWJSD(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
object Figure = GetDecimalDigits();
#region [SQL]
string sql = @"select a.ID, a.ODNCode OOCode,a.Sequence OOSequence,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,
CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST(a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10 ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
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 and ee.type='11'
where isnull(ee.EATTRIBUTE1,'')=''
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='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null
";
sql = string.Format(sql, Figure);
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 (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
{
string POStatus = queryParam["POStatus"].ToString();
if (POStatus == "0")
{
//sql += " and a.Quantity=ISNULL(c.LotQty,0)";
}
else if (POStatus == "1")
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
}
else
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
}
}
}
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 GetGridJsonJSD(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
object Figure = GetDecimalDigits();
#region [SQL]
string sql = @"select a.ID,a.DNCode ,a.Sequence ,a.VenCode,e.VenName,a.InvCode, b.InvName,b.InvStd,b.InvDesc,b.InvUnit,
CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as RCVQuantity,CAST( a.UnitPrice AS DECIMAL(18,{0})) as UnitPrice,a.Currency,a.CreatePerson,a.CreateDateTime,
CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
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 and ee.type='10'
where isnull(ee.EATTRIBUTE1,'')=''
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.DNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null
";
sql = string.Format(sql, Figure);
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 (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
{
string POStatus = queryParam["POStatus"].ToString();
if (POStatus == "0")
{
//sql += " and a.Quantity=ISNULL(c.LotQty,0)";
}
else if (POStatus == "1")
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
}
else
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
}
}
}
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 GetGridJsonLLSQTL(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
object Figure = GetDecimalDigits();
#region [SQL]
string sql = @"select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
from ICSMOApplyNegDetail a
left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
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 and ee.type='12'
where isnull(ee.EATTRIBUTE1,'')=''
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
WHERE d.Type='2'";
sql = string.Format(sql, Figure);
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
#endregion
if (!string.IsNullOrWhiteSpace(queryJson))
{
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
{
sql += " and a.ApplyNegCode 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 (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
{
string POStatus = queryParam["POStatus"].ToString();
if (POStatus == "0")
{
//sql += " and a.Quantity=ISNULL(c.LotQty,0)";
}
else if (POStatus == "1")
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
}
else
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
}
}
}
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>
/// <param name="POCode"></param>
/// <param name="PORow"></param>
/// <param name="keyValue"></param>
/// <returns></returns>
public int SubmitFormJSD(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 = "JS" + DNCode + (Convert.ToInt32(Sequence)).ToString("D4");
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;
string Colspan = "";
string str1 = "";
List<string> ExtensionIDList = new List<string>();
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
bool flag = true;
foreach (var item in ExtensionIDList)
{
if (item == Colspan + WorkPoint)
{
flag = false;
}
}
if (ExtensionID == null && flag == true)
{
str1 = Guid.NewGuid().ToString();
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
str1, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
MUSER, MUSERNAME, WorkPoints);
}
else if (ExtensionID != null)
{
str1 = ExtensionID.ToString();
}
ExtensionIDList.Add(Colspan + WorkPoint);
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,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
select
newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','10','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
, queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
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 SubmitFormWWJSD(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 = "OJS" + ODNCode + (Convert.ToInt32(Sequence)).ToString("D4");
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;
string Colspan = "";
string str1 = "";
List<string> ExtensionIDList = new List<string>();
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
bool flag = true;
foreach (var item in ExtensionIDList)
{
if (item == Colspan + WorkPoint)
{
flag = false;
}
}
if (ExtensionID == null && flag == true)
{
str1 = Guid.NewGuid().ToString();
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
str1, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
MUSER, MUSERNAME, WorkPoints);
}
else if (ExtensionID != null)
{
str1 = ExtensionID.ToString();
}
ExtensionIDList.Add(Colspan + WorkPoint);
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,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
select
newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','11','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
, queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
sql += "\r\n";
//}
}
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
return count;
}
/// <summary>
/// 点击审核到货单生成条码(审核到货单)
/// </summary>
public DataTable GetSubGridJsonJSDByCreate(string DNCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
object Figure = GetDecimalDigits();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
,d.ProjectCode,d.BatchCode,d.Version,d.Brand,d.cFree1,d.cFree2,d.cFree3,d.cFree4,d.cFree5,d.cFree6,d.cFree7,d.cFree8,d.cFree9,d.cFree10
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 and a.Type='10'
where isnull(a.EATTRIBUTE1,'')=''
group by b.TransCode,b.TransSequence
) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence
left join ICSExtension d on a.ExtensionID=d.ID and a.WorkPoint=d.WorkPoint
WHERE a.DNType='3'
and a.DNCode='" + DNCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
sql = string.Format(sql, Figure);
return Repository().FindTableBySql(sql.ToString());
}
/// <summary>
/// 点击审核委外到货单生成条码(审核委外到货单)
/// </summary>
public DataTable GetSubGridJsonWWJSDByCreate(string ODNCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
object Figure = GetDecimalDigits();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
,d.ProjectCode,d.BatchCode,d.Version,d.Brand,d.cFree1,d.cFree2,d.cFree3,d.cFree4,d.cFree5,d.cFree6,d.cFree7,d.cFree8,d.cFree9,d.cFree10
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 and a.Type='11'
where isnull(a.EATTRIBUTE1,'')=''
group by b.TransCode,b.TransSequence
) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
left join ICSExtension d on a.ExtensionID=d.ID and a.WorkPoint=d.WorkPoint
WHERE a.ODNType='3'
and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
sql = string.Format(sql, Figure);
return Repository().FindTableBySql(sql.ToString());
}
public DataTable GetSubGridJsonLLSQDByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
object Figure = GetDecimalDigits();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
,e.ProjectCode,e.BatchCode,e.Version,e.Brand,e.cFree1,e.cFree2,e.cFree3,e.cFree4,e.cFree5,e.cFree6,e.cFree7,e.cFree8,e.cFree9,e.cFree10
from ICSMOApplyNegDetail a
left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
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 and a.Type='12'
where isnull(a.EATTRIBUTE1,'')=''
group by b.TransCode,b.TransSequence
) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
left join ICSExtension e on a.ExtensionID=e.ID and a.WorkPoint=e.WorkPoint
WHERE d.Type='2'
and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
sql = string.Format(sql, Figure);
return Repository().FindTableBySql(sql.ToString());
}
//领料申请退料生成条码
public int SubmitFormLLSQTL(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 = "MA" + ApplyNegCode + (Convert.ToInt32(Sequence)).ToString("D4");
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;
string Colspan = "";
string str1 = "";
List<string> ExtensionIDList = new List<string>();
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
bool flag = true;
foreach (var item in ExtensionIDList)
{
if (item == Colspan + WorkPoint)
{
flag = false;
}
}
if (ExtensionID == null && flag == true)
{
str1 = Guid.NewGuid().ToString();
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
str1, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
MUSER, MUSERNAME, WorkPoints);
}
else if (ExtensionID != null)
{
str1 = ExtensionID.ToString();
}
ExtensionIDList.Add(Colspan + WorkPoint);
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,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
select
newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','12','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
, queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
sql += "\r\n";
//}
}
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
return count;
}
//材料出库退料
public DataTable GetGridJsonCLCK(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
object Figure = GetDecimalDigits();
#region [SQL]
string sql = @"
select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,
CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
from ICSMOApplyNegDetail a
left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
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 and ee.type='13'
where isnull(ee.EATTRIBUTE1,'')=''
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
WHERE d.Type='3'";
sql = string.Format(sql, Figure);
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
#endregion
if (!string.IsNullOrWhiteSpace(queryJson))
{
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
{
sql += " and a.ApplyNegCode 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 (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
{
string POStatus = queryParam["POStatus"].ToString();
if (POStatus == "0")
{
//sql += " and a.Quantity=ISNULL(c.LotQty,0)";
}
else if (POStatus == "1")
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
}
else
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
}
}
}
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 GetSubGridJsonCLCKByCreate(string ApplyNegCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
object Figure = GetDecimalDigits();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
,f.ProjectCode,f.BatchCode,f.Version,f.Brand,f.cFree1,f.cFree2,f.cFree3,f.cFree4,f.cFree5,f.cFree6,f.cFree7,f.cFree8,f.cFree9,f.cFree10
from ICSMOApplyNegDetail a
left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
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 and a.Type='13'
where isnull(a.EATTRIBUTE1,'')=''
group by b.TransCode,b.TransSequence
) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
WHERE d.Type='3'
and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
sql = string.Format(sql, Figure);
return Repository().FindTableBySql(sql.ToString());
}
//材料出库退料生成条码
public int SubmitFormCLCKT(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 Pre = "MD" + ApplyNegCode + (Convert.ToInt32(Sequence)).ToString("D4");
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;
string Colspan = "";
string str1 = "";
List<string> ExtensionIDList = new List<string>();
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
bool flag = true;
foreach (var item in ExtensionIDList)
{
if (item == Colspan + WorkPoint)
{
flag = false;
}
}
if (ExtensionID == null && flag == true)
{
str1 = Guid.NewGuid().ToString();
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
str1, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
MUSER, MUSERNAME, WorkPoints);
}
else if (ExtensionID != null)
{
str1 = ExtensionID.ToString();
}
ExtensionIDList.Add(Colspan + WorkPoint);
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);
sql += string.Format(@"insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
select
newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','13','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
, queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
sql += "\r\n";
}
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
return count;
}
public DataTable GetGridJsonWWLLTL(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
object Figure = GetDecimalDigits();
#region [SQL]
string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
from ICSOApplyNegDetail a
left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
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 and ee.type='14'
where isnull(ee.EATTRIBUTE1,'')=''
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
WHERE d.Type='2'";
sql = string.Format(sql, Figure);
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 (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
{
string POStatus = queryParam["POStatus"].ToString();
if (POStatus == "0")
{
//sql += " and a.Quantity=ISNULL(c.LotQty,0)";
}
else if (POStatus == "1")
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
}
else
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
}
}
}
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 GetSubGridJsonWWLLByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
object Figure = GetDecimalDigits();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"
select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
,e.ProjectCode,e.BatchCode,e.Version,e.Brand,e.cFree1,e.cFree2,e.cFree3,e.cFree4,e.cFree5,e.cFree6,e.cFree7,e.cFree8,e.cFree9,e.cFree10
from ICSOApplyNegDetail a
left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
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 and a.Type='14'
where isnull(a.EATTRIBUTE1,'')=''
group by b.TransCode,b.TransSequence
) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
left join ICSExtension e on a.ExtensionID=e.ID and a.WorkPoint=e.WorkPoint
WHERE d.Type='2'
and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
sql = string.Format(sql, Figure);
return Repository().FindTableBySql(sql.ToString());
}
//委外领料申请退料
public int SubmitFormWWLL(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 Pre = "OMA" + OApplyNegCode + (Convert.ToInt32(Sequence)).ToString("D4");
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;
string Colspan = "";
string str1 = "";
List<string> ExtensionIDList = new List<string>();
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
bool flag = true;
foreach (var item in ExtensionIDList)
{
if (item == Colspan + WorkPoint)
{
flag = false;
}
}
if (ExtensionID == null && flag == true)
{
str1 = Guid.NewGuid().ToString();
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
str1, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
MUSER, MUSERNAME, WorkPoints);
}
else if (ExtensionID != null)
{
str1 = ExtensionID.ToString();
}
ExtensionIDList.Add(Colspan + WorkPoint);
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);
sql += string.Format(@"insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
select
newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','14','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
, queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
sql += "\r\n";
}
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
return count;
}
//委外材料出库
public DataTable GetGridJsonWWCLCK(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
object Figure = GetDecimalDigits();
#region [SQL]
string sql = @"select a.ID,a.OApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as IssueNegQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
from ICSOApplyNegDetail a
left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
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 and ee.type='15'
where isnull(ee.EATTRIBUTE1,'')=''
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
WHERE d.Type='3'";
sql = string.Format(sql, Figure);
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 (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
{
string POStatus = queryParam["POStatus"].ToString();
if (POStatus == "0")
{
//sql += " and a.Quantity=ISNULL(c.LotQty,0)";
}
else if (POStatus == "1")
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
}
else
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
}
}
}
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 GetSubGridJsonWWCLByCreate(string OApplyNegCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
object Figure = GetDecimalDigits();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"
select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
,f.ProjectCode,f.BatchCode,f.Version,f.Brand,f.cFree1,f.cFree2,f.cFree3,f.cFree4,f.cFree5,f.cFree6,f.cFree7,f.cFree8,f.cFree9,f.cFree10
from ICSOApplyNegDetail a
left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
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 and a.Type='15'
where isnull(a.EATTRIBUTE1,'')=''
group by b.TransCode,b.TransSequence
) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence
left join ICSExtension f on a.ExtensionID=d.ID and a.WorkPoint=d.WorkPoint
WHERE d.Type='3'
and a.OApplyNegCode='" + OApplyNegCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
sql = string.Format(sql, Figure);
return Repository().FindTableBySql(sql.ToString());
}
//委外材料出库
public int SubmitFormWWCL(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 = "OMD" + OApplyNegCode + (Convert.ToInt32(Sequence)).ToString("D4");
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;
string Colspan = "";
string str1 = "";
List<string> ExtensionIDList = new List<string>();
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
bool flag = true;
foreach (var item in ExtensionIDList)
{
if (item == Colspan + WorkPoint)
{
flag = false;
}
}
if (ExtensionID == null && flag == true)
{
str1 = Guid.NewGuid().ToString();
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
str1, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
MUSER, MUSERNAME, WorkPoints);
}
else if (ExtensionID != null)
{
str1 = ExtensionID.ToString();
}
ExtensionIDList.Add(Colspan + WorkPoint);
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,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
select
newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','15','{3}','{4}', getdate(),'{5}','{9}'
,'{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
, queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
sql += "\r\n";
//}
}
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
return count;
}
public DataTable SelectICSExtensionEnable()
{
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
string sql = @"select ColCode from ICSExtensionEnable
where Enable=0 and WorkPoint='"+ WorkPoints + "' order by cast(EATTRIBUTE1 as int)";
DataTable dt = SqlHelper.GetDataTableBySql(sql);
return dt;
}
public DataTable GetComplete()
{
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
string sql = @"select Enable from ICSConfiguration where Code='CompleteVerification001' and WorkPoint='" + WorkPoints + "'";
DataTable dt = SqlHelper.GetDataTableBySql(sql);
return dt;
}
public DataTable GetWWComplete()
{
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
string sql = @"select Enable from ICSConfiguration where Code='CompleteVerification002' and WorkPoint='" + WorkPoints + "'";
DataTable dt = SqlHelper.GetDataTableBySql(sql);
return dt;
}
//返工工单
public DataTable GetGridJsonFGGD(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
object Figure = GetDecimalDigits();
#region [SQL]
string sql = @"select a.ID,d.MOCode,d.Sequence+'~'+ a.Sequence as Sequence,a.PickID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,
CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueQuantity AS DECIMAL(18,{0})) as IssueQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
from ICSMOPick a
left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3'
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 and ee.type='16'
where isnull(ee.EATTRIBUTE1,'')=''
group by mm.TransCode,mm.TransSequence,ee.WorkPoint
)c
on d.MOCode=c.TransCode and d.Sequence+'~'+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.EATTRIBUTE1='1' and d.EATTRIBUTE1='1'";
sql = string.Format(sql, Figure);
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
#endregion
if (!string.IsNullOrWhiteSpace(queryJson))
{
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
{
sql += " and d.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 (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
{
string POStatus = queryParam["POStatus"].ToString();
if (POStatus == "0")
{
//sql += " and a.Quantity=ISNULL(c.LotQty,0)";
}
else if (POStatus == "1")
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
}
else
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
}
}
}
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 GetSubGridJsonFGGDCreate(string FGGDMOCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
object Figure = GetDecimalDigits();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"
select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
,e.ProjectCode,e.BatchCode,e.Version,e.Brand,e.cFree1,e.cFree2,e.cFree3,e.cFree4,e.cFree5,e.cFree6,e.cFree7,e.cFree8,e.cFree9,e.cFree10
from ICSMOPick a
left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3'
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 and a.Type='16'
where isnull(a.EATTRIBUTE1,'')=''
group by b.TransCode,b.TransSequence
) c on d.MOCode=c.TransCode and d.Sequence+'~'+a.Sequence=c.TransSequence
left join ICSExtension e on d.ExtensionID=e.ID and a.WorkPoint=e.WorkPoint
WHERE 1=1
and d.MOCode='" + FGGDMOCode + "' and d.Sequence+'~'+a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
sql = string.Format(sql, Figure);
return Repository().FindTableBySql(sql.ToString());
}
//返工工单
public int SubmitFormFGGD(string FGGDMOCode, 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;
Sequence = Sequence.Replace("~", "");
string Pre = "FG" + FGGDMOCode + (Convert.ToInt32(Sequence)).ToString("D4");
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;
string Colspan = "";
string str1 = "";
List<string> ExtensionIDList = new List<string>();
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
bool flag = true;
foreach (var item in ExtensionIDList)
{
if (item == Colspan + WorkPoint)
{
flag = false;
}
}
if (ExtensionID == null && flag == true)
{
str1 = Guid.NewGuid().ToString();
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
str1, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
MUSER, MUSERNAME, WorkPoints);
}
else if (ExtensionID != null)
{
str1 = ExtensionID.ToString();
}
ExtensionIDList.Add(Colspan + WorkPoint);
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, FGGDMOCode, Sequence, MUSER, MUSERNAME, WorkPoints);
sql += string.Format(@"insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
select
newid(),'{0}',a.InvCode,'{1}','{10}','{2}','{8}','16','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
from ICSMOPick a left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint where d.MOCode='{6}' and d.Sequence+'~'+a.Sequence='{7}' and a.WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, FGGDMOCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()
, queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
sql += "\r\n";
}
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
return count;
}
public object GetDecimalDigits()
{
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
try
{
string sql = string.Empty;
sql = @"select Figure from ICSConfiguration where Code='Figure001' and Enable='1' and WorkPoint='" + WorkPoint + "'";
object Figure = SqlHelper.ExecuteScalar(sql);
return Figure;
}
catch (Exception ex)
{
throw new Exception(ex.Message.ToString());
}
}
/// <summary>
/// 生成条码导出
/// </summary>
/// <param name="ProductBrand"></param>
/// <param name="cCusName"></param>
/// <param name="DesignAddRate"></param>
/// <returns></returns>
public DataTable StatementExportAll(string Type,string ID)
{
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
string sql = string.Empty;
object Figure = GetDecimalDigits();
string TableCode = string.Empty;
#region sql语句
if (Type == "1") //生产退料
{
sql = @"select a.ApplyNegCode as 退料单号,a.Sequence as 退料单行号,a.InvCode as 料品编码,b.InvName as 料品名称,b.InvStd as 规格型号,b.InvUnit as 单位, CAST(a.Quantity AS DECIMAL(18,{0})) as 数量
,CAST(a.Amount AS DECIMAL(18,{0})) as 辅计量数量 , CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as 已退数量 ,a.MUSERName as 操作人,a.MTIME as 日期, CAST(c.LOTQTY AS DECIMAL(18,{0})) as 已生成数量
,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
from ICSMOApplyNegDetail a
left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
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 and ee.type='1'
where isnull(ee.EATTRIBUTE1,'')=''
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
where d.Type='1' and a.ID in (" + ID.TrimEnd(',') + ")";
TableCode = "ICSMOApplyNegDetail";
}
if (Type == "2") //委外退料
{
sql = @"select a.OApplyNegCode as 退料单号,a.Sequence as 退料单行号,a.InvCode as 料品编码,b.InvName as 料品名称,b.InvStd as 规格型号,b.InvUnit as 单位, CAST(a.Quantity AS DECIMAL(18,{0})) as 数量
,CAST(a.Amount AS DECIMAL(18,{0})) as 辅计量数量 , CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as 已退数量 ,a.MUSERName as 操作人,a.MTIME as 日期, CAST(c.LOTQTY AS DECIMAL(18,{0})) as 已生成数量
,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
from ICSOApplyNegDetail a
left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
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 and ee.type='2'
where isnull(ee.EATTRIBUTE1,'')=''
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
WHERE d.Type='1' and a.ID in (" + ID.TrimEnd(',') + ")";
TableCode = "ICSOApplyNegDetail";
}
if (Type == "3")//工单成品生成条码
{
sql = @"select a.MOCode as 工单号,a.Sequence as 工单行号 ,a.InvCode as 料品编码,b.InvName as 料品名称,b.InvStd as 规格型号,b.InvUnit as 单位
,CAST( a.Quantity AS DECIMAL(18,{0})) as 数量,CAST( a.Amount as DECIMAL(18,{0})) as 辅计量数量
,a.MUSERName as 操作人 ,a.MTIME as 日期 ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as 已生成数量
,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,
a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
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 and ee.type='3'
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
WHERE 1=1 and a.MOStatus<>'3' and a.Quantity-ISNULL(c.LOTQTY,0)<>0 and a.ID in (" + ID.TrimEnd(',') + ")";
TableCode = "ICSMO";
}
if (Type == "4")//销售退货
{
sql = @"select a.SDNCode as 单据号,a.Sequence as 行号,a.SOCode as 销售订单号,a.SOSequence as 销售订单行号,a.CusCode as 客户代码 ,a.CusName as 客户名称 ,a.ArriveDate as 发货日期,a.InvCode as 料品编码,b.InvName as 料品名称,b.InvStd as 规格型号,b.InvUnit as 单位,CAST(a.Quantity AS DECIMAL(18,{0})) as 数量
,cast(a.Amount as decimal(18,{0})) as 辅计量数量, CAST(a.SDNQuantity AS DECIMAL(18,{0})) as 已发数量 ,a.CreatePerson as 创建人,a.CreateDateTime as 创建时间,CAST(c.LOTQTY AS DECIMAL(18,{0})) as 已生成数量
,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
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 and ee.type='4'
where isnull(ee.EATTRIBUTE1,'')=''
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'and a.ID in (" + ID.TrimEnd(',') + ")";
TableCode = "ICSSDN";
}
if (Type == "5")//其它入库生成条码
{
sql = @"select a.InCode as 单据号,a.Sequence as 行号,a.WHCode as 仓库编码,a.InvCode as 料品编码, b.InvName as 料品名称,b.InvStd as 料品型号 ,b.InvDesc as 料品描述,b.InvUnit as 料品单位,
CAST(a.Quantity AS DECIMAL(18,{0})) as 数量,CAST(a.Amount AS DECIMAL(18,{0})) as 辅计量数量, CAST(a.InQuantity AS DECIMAL(18,{0})) as 已入数量,a.CreatePerson as 创建人,a.CreateDateTime as 创建时间,CAST(c.LOTQTY AS DECIMAL(18,{0})) as 已生成数量
,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
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 and ee.type='5'
where isnull(ee.EATTRIBUTE1,'')=''
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' and a.ID in (" + ID.TrimEnd(',') + ")";
TableCode = "ICSOtherIn";
}
if (Type == "6")//归还单生成条码
{
sql = @" select a.ReturnCode as 单据号,a.Sequence as 行号,a.WHCode as 仓库编码,a.InvCode as 料品编码, b.InvName as 料品名称,b.InvStd as 料品型号,b.InvDesc as 料品描述,b.InvUnit as 料品单位
,CAST(a.Quantity AS DECIMAL(18,{0})) as 数量 ,CAST(a.Amount AS DECIMAL(18,{0})) as 辅计量数量, CAST(a.ReturnQuantity AS DECIMAL(18,{0})) as 已归还数量,a.CreatePerson as 创建人,a.CreateDateTime as 创建时间,CAST(c.LOTQTY AS DECIMAL(18,{0})) as 已生成数量
,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
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 and ee.type='6'
where isnull(ee.EATTRIBUTE1,'')=''
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' and a.ID in (" + ID.TrimEnd(',') + ")";
TableCode = "ICSReturn";
}
if (Type == "7")//*审核到货单生成条码
{
sql = @"select d.POCode as 采购订单号,d.Sequence as 采购订单行号,a.DNCode as 单据号,a.Sequence as 行号,a.VenCode as 供应商代码,e.VenName as 供应商名称,a.InvCode as 料品编码, b.InvName as 料品名称,b.InvStd as 料品型号,b.InvDesc as 料品描述,b.InvUnit as 料品单位,
CAST(a.Quantity AS DECIMAL(18,{0})) as 数量 ,CAST(a.Amount AS DECIMAL(18,{0})) as 辅计量数量,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as 入库数量,a.Currency as 币种,a.CreatePerson as 创建人,a.CreateDateTime as 创建时间,CAST(c.LOTQTY AS DECIMAL(18,{0})) as 已生成数量
,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
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 and ee.type='7'
where isnull(ee.EATTRIBUTE1,'')=''
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.DNType='1' and a.Status='2' and a.ASNCode is null and a.ID in (" + ID.TrimEnd(',') + ")";
TableCode = "ICSDeliveryNotice";
}
if (Type == "8")//审核委外到货单生成条码
{
sql = @"select d.OOCode as 委外采购订单号,d.Sequence as 委外采购订单行号,a.ODNCode as 单据号,a.Sequence as 行号,a.VenCode as 供应商代码,e.VenName as 供应商名称,a.InvCode as 料品编码, b.InvName as ,b.InvStd as 料品型号,b.InvDesc as 料品描述,b.InvUnit as 料品单位,CAST(a.Quantity AS DECIMAL(18,{0})) as 数量 ,CAST(a.Amount AS DECIMAL(18,{0})) as 辅计量数量,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as 入库数量,a.Currency as 币种,a.CreatePerson as 创建人,a.CreateDateTime as 创建时间,
CAST(c.LOTQTY AS DECIMAL(18,{0})) as 已生成数量
,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10 ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
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 and ee.type='8'
where isnull(ee.EATTRIBUTE1,'')=''
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 and a.ID in (" + ID.TrimEnd(',') + ")";
TableCode = "ICSODeliveryNotice";
}
if (Type == "9")//开立得成品入库单 生成条码
{
sql = @"select a.RCVCode as 单据号,a.Sequence as 行号,a.WHCode as 仓库号,a.InvCode as 料品编码, b.InvName as 料品名称,b.InvStd as 料品型号,b.InvDesc as 料品描述,b.InvUnit as 料品单位,CAST(a.Quantity AS DECIMAL(18,{0})) as 数量 ,
CAST(a.Amount AS DECIMAL(18,{0})) as 辅计量数量,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as 入库数量 ,a.CreatePerson as 创建人,a.CreateDateTime as 创建时间,CAST(c.LOTQTY AS DECIMAL(18,{0})) as 已生成数量
,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
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 and ee.type='9'
where isnull(ee.EATTRIBUTE1,'')=''
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' and a.ID in (" + ID.TrimEnd(',') + ")";
TableCode = "ICSManufactureReceive";
}
if (Type == "10")//采购拒收单
{
sql = @"select a.DNCode as 拒收单号 ,a.Sequence as 拒收单行号 ,a.VenCode as 供应商代码,e.VenName as 供应商名称,a.InvCode as 料品编码, b.InvName as 料品名称,b.InvStd as 料品型号,b.InvDesc as 料品描述,b.InvUnit as 料品单位,
CAST(a.Quantity AS DECIMAL(18,{0})) as 数量 ,CAST(a.Amount AS DECIMAL(18,{0})) as 辅计量数量,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as 入库数量,a.Currency as 币种,a.CreatePerson as 创建人,a.CreateDateTime as 创建时间,
CAST(c.LOTQTY AS DECIMAL(18,{0})) as 已生成数量
,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
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 and ee.type='10'
where isnull(ee.EATTRIBUTE1,'')=''
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.DNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null and a.ID in (" + ID.TrimEnd(',') + ")";
TableCode = "ICSDeliveryNotice";
}
if (Type == "11") //委外拒收单生成条码
{
sql = @"select a.ODNCode as 委外拒收单号,a.Sequence as 委外拒收单行号,a.VenCode as 供应商代码,e.VenName as 供应商名称,a.InvCode as 料品编码, b.InvName as 料品名称,b.InvStd as 料品型号,b.InvDesc as 料品描述,b.InvUnit as 料品单位,
CAST(a.Quantity AS DECIMAL(18,{0})) as 数量 ,CAST(a.Amount AS DECIMAL(18,{0})) as 辅计量数量,CAST(a.RCVQuantity AS DECIMAL(18,{0})) as 入库数量,a.Currency as 币种,a.CreatePerson as 创建人,a.CreateDateTime as 创建时间,CAST(c.LOTQTY AS DECIMAL(18,{0})) as 已生成数量
,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10 ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
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 and ee.type='11'
where isnull(ee.EATTRIBUTE1,'')=''
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='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null and a.ID in (" + ID.TrimEnd(',') + ")";
TableCode = "ICSODeliveryNotice";
}
if (Type == "12")//领料申请退料生成条码
{
sql = @"select a.ApplyNegCode as 退料单号,a.Sequence as 退料单行号,a.InvCode as 料品编码,b.InvName as 料品编码,b.InvDesc as 料品描述,b.InvStd as 规格型号,b.InvUnit as 单位,
CAST(a.Quantity AS DECIMAL(18,{0})) as 数量 ,CAST(a.Amount AS DECIMAL(18,{0})) as 辅计量数量,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as 已退数量 ,a.MUSERName as 操作人,a.MTIME as 日期 ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as 已生成数量
,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
from ICSMOApplyNegDetail a
left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
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 and ee.type='12'
where isnull(ee.EATTRIBUTE1,'')=''
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
WHERE d.Type='2' and a.ID in (" + ID.TrimEnd(',') + ")";
TableCode = "ICSMOApplyNegDetail";
}
if (Type == "13")//材料出库退料
{
sql = @" select a.ApplyNegCode as 退料单号,a.Sequence as 退料单行号,a.InvCode as 料品编码,b.InvName as 料品名称,b.InvDesc as 料品描述,b.InvStd as 规格型号,b.InvUnit as 单位,
CAST(a.Quantity AS DECIMAL(18,{0})) as 数量 ,
CAST(a.Amount AS DECIMAL(18,{0})) as 辅计量数量,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as 已退数量 ,a.MUSERName as 操作人,a.MTIME as 日期 ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as 已生成数量
,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10
from ICSMOApplyNegDetail a
left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
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 and ee.type='13'
where isnull(ee.EATTRIBUTE1,'')=''
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
WHERE d.Type='3' and a.ID in (" + ID.TrimEnd(',') + ")";
TableCode = "ICSMOApplyNegDetail";
}
if (Type == "14")//委外领料申请退料
{
sql = @" select a.OApplyNegCode as 退料单号,a.Sequence as 退料单行号,a.InvCode as 料品编码,b.InvName as 料品名称,b.InvDesc as 料品描述,b.InvStd as 规格型号,b.InvUnit as 单位,
CAST(a.Quantity AS DECIMAL(18,{0})) as 数量 ,CAST(a.Amount AS DECIMAL(18,{0})) as 辅计量数量,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as 已退数量 ,a.MUSERName as 操作人,a.MTIME as 日期 ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as 已生成数量
,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
from ICSOApplyNegDetail a
left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
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 and ee.type='14'
where isnull(ee.EATTRIBUTE1,'')=''
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
WHERE d.Type='2' and a.ID in (" + ID.TrimEnd(',') + ")";
TableCode = "ICSOApplyNegDetail";
}
if (Type == "15")//委外材料出库退料
{
sql = @" select a.OApplyNegCode as 退料单号,a.Sequence as 退料单行号,a.InvCode as 料品编码,b.InvName as 料品名称,b.InvDesc as 料品描述,b.InvStd as 规格型号,b.InvUnit as 单位,
CAST(a.Quantity AS DECIMAL(18,{0})) as 数量 ,CAST(a.Amount AS DECIMAL(18,{0})) as 辅计量数量,CAST(a.IssueNegQuantity AS DECIMAL(18,{0})) as 已退数量 ,a.MUSERName as 操作人,a.MTIME as 日期 ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as 已生成数量
,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
from ICSOApplyNegDetail a
left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
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 and ee.type='15'
where isnull(ee.EATTRIBUTE1,'')=''
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
WHERE d.Type='3' and a.ID in (" + ID.TrimEnd(',') + ")";
TableCode = "ICSOApplyNegDetail";
}
if (Type == "16") //返工工单
{
sql = @"select d.MOCode as 工单号,d.Sequence+'~'+ a.Sequence as 工单子件行号,a.InvCode as 料品编码,b.InvName as 料品名称,b.InvDesc as 料品描述,b.InvStd as 规格型号,b.InvUnit as 单位,
CAST(a.Quantity AS DECIMAL(18,{0})) as 数量 ,
CAST(a.Amount AS DECIMAL(18,{0})) as 辅计量数量,CAST(a.IssueQuantity AS DECIMAL(18,{0})) as 已发数量 ,a.MUSERName as 操作人,a.MTIME as 日期 ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as 已生成数量
,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
from ICSMOPick a
left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3'
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 and ee.type='16'
where isnull(ee.EATTRIBUTE1,'')=''
group by mm.TransCode,mm.TransSequence,ee.WorkPoint
)c
on d.MOCode=c.TransCode and d.Sequence+'~'+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.EATTRIBUTE1='1' and d.EATTRIBUTE1='1' and a.ID in (" + ID.TrimEnd(',') + ")";
TableCode = "ICSMOPick";
}
if (Type == "17")//检验不合格条码重新生成
{
sql = @"select a.LotNo as 不合格条码, a.InvCode as 料品编码,b.InvName as 料品名称,b.InvDesc as 料品描述,b.InvStd as 规格型号,b.InvUnit as 单位,
CAST(a.Quantity AS DECIMAL(18,{0})) as 数量 ,
CAST(c.Amount AS DECIMAL(18,{0})) as 辅计量数量,a.MUSERName,a.MUSERName as 操作人,a.MTIME as 日期 ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as 已生成数量
,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,
a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
from ICSInspection a
left join dbo.ICSInventoryLot d on a.LotNo=d.LotNo and a.WorkPoint=d.WorkPoint
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
left join (
select ee.LotNo,ee.EATTRIBUTE1,ee.Amount,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='17'
group by ee.LotNo,ee.EATTRIBUTE1,ee.Amount,ee.WorkPoint
)c
on c.EATTRIBUTE1=d.LotNo and a.WorkPoint=c.WorkPoint
left join ICSExtension f on d.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
where a.UnqualifiedQuantity>0 and a.Enable='1' and a.ID in (" + ID.TrimEnd(',') + ")";
TableCode = "ICSInspection";
}
#endregion
sql = sql + " and a.WorkPoint='{1}'";
sql = string.Format(sql, Figure, WorkPoint);
DataTable dt = SqlHelper.GetDataTableBySql(sql);
string sqls = @"SELECT ColCode,ColName,Enable
from ICSExtensionEnable where WorkPoint='" + WorkPoint + "'";
DataTable dtExtension = SqlHelper.GetDataTableBySql(sqls);
foreach (DataRow drE in dtExtension.Rows)
{
if (dt.Columns.Contains(drE["ColCode"].ToString()) )
{
if (!Convert.ToBoolean(drE["Enable"]))
{
dt.Columns.Remove(drE["ColCode"].ToString());
}
else if (Convert.ToBoolean(drE["Enable"]))
{
dt.Columns[drE["ColCode"].ToString()].ColumnName = drE["ColName"].ToString();
}
}
}
DataTable dtColumn = ColumnEnable(TableCode);
foreach (DataRow drC in dtColumn.Rows)
{
if (dt.Columns.Contains(drC["ColumnCode"].ToString()))
{
if (!Convert.ToBoolean(drC["Enable"]))
{
dt.Columns.Remove(drC["ColumnCode"].ToString());
}
else if (Convert.ToBoolean(drC["Enable"]))
{
dt.Columns[drC["ColumnCode"].ToString()].ColumnName = drC["Name"].ToString();
}
}
}
return dt;
}
public DataTable ColumnEnable(string TableCode)
{
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
string sql = string.Empty;
sql = @"select ColumnCode,Name,Enable from ICSColumnEnable where TableCode='{0}' and WorkPoint='{1}'";
sql = string.Format(sql, TableCode, WorkPoint);
DataTable dt = SqlHelper.GetDataTableBySql(sql);
return dt;
}
public object GetQiSetNum(string keyValue)
{
decimal Num = 0;
string msg = "";
string APIURL = ConfigurationManager.ConnectionStrings["ERPAPIURL"].ConnectionString + "Complete/Approve";
string result = HttpPost(APIURL, keyValue);
JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
string MessAge = Obj["Message"].ToString();
string Success = Obj["Success"].ToString();
if (Success.ToUpper() == "FALSE")
{
msg = MessAge;
}
else
{
if (MessAge == "U9")
{
decimal Date = Convert.ToDecimal(Obj["Data"].ToString());
int date = Convert.ToInt32(Date);
Num = date;
}
else
{
if (msg == "")
{
JArray res = (JArray)JsonConvert.DeserializeObject(Obj["Data"].ToString());
foreach (var item in res)
{
JObject jo = (JObject)item;
//var aa= jo["min_lotqty"].ToString();
Num = Convert.ToDecimal(jo["min_lotqty"].ToString());
}
}
}
}
var Header = new
{
msg = msg,
Num = Num,
};
return Header;
}
//接口api解析
public static string HttpPost(string url, string body)
{
try
{
Encoding encoding = Encoding.UTF8;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.Accept = "application/json, text/javascript, */*"; //"text/html, application/xhtml+xml, */*";
request.ContentType = "application/json; charset=utf-8";
byte[] buffer = encoding.GetBytes(body);
request.ContentLength = buffer.Length;
request.GetRequestStream().Write(buffer, 0, buffer.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
{
return reader.ReadToEnd();
}
}
catch (WebException ex)
{
throw new Exception(ex.Message);
}
}
public DataTable GetLoadShow()
{
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
string sql = @"
select * from ICSExtensionEnable where WorkPoint='" + WorkPoints + "' order by cast(EATTRIBUTE1 as int) ";
return Repository().FindTableBySql(sql.ToString());
}
//不合格条码重新生成入库
public DataTable GetGridJsonBHGTM(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
object Figure = GetDecimalDigits();
#region [SQL]
string sql = @"select a.ID,a.LotNo, a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
CAST(a.UnqualifiedQuantity AS DECIMAL(18,{0})) as Quantity ,
CAST(c.Amount AS DECIMAL(18,{0})) as Amount,a.MUSERName,a.MTIME,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY,d.ExtensionID
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
from ICSInspection a
left join dbo.ICSInventoryLot d on a.LotNo=d.LotNo and a.WorkPoint=d.WorkPoint
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
left join (
select ee.LotNo,ee.EATTRIBUTE1,ee.Amount,sum(isnull(ee.Quantity,0)) LOTQTY,ee.WorkPoint from ICSInventoryLot ee
left join ICSInventoryLotDetail mm on ee.LotNo=mm.LotNo and ee.type='17'
group by ee.LotNo,ee.EATTRIBUTE1,ee.Amount,ee.WorkPoint
)c
on c.EATTRIBUTE1=d.LotNo and a.WorkPoint=c.WorkPoint
left join ICSExtension f on d.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
where a.UnqualifiedQuantity>0 and a.Enable='1'";
sql = string.Format(sql, Figure);
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
#endregion
if (!string.IsNullOrWhiteSpace(queryJson))
{
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
{
sql += " and a.LotNo 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 (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
{
string POStatus = queryParam["POStatus"].ToString();
if (POStatus == "0")
{
//sql += " and a.Quantity=ISNULL(c.LotQty,0)";
}
else if (POStatus == "1")
{
sql += " and a.UnqualifiedQuantity-ISNULL(c.LOTQTY,0)=0";
}
else
{
sql += " and a.UnqualifiedQuantity-ISNULL(c.LOTQTY,0)<>0";
}
}
}
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
{
sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'";
}
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
}
public DataTable GetSubGridJsonBHGTM(string LotNo, string Type, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
object Figure = GetDecimalDigits();
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, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity ,a.MUSERName,a.MTIME
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,
case when isnull(d.ID,'')='' then '未入库' else '已入库' end as isStorage,
case when isnull(e.ID,'')='' then '未检验' else '已检验' end as isInspection,
case when g.InvIQC='1' then '是' else '否' end as isExemption
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 and a.WorkPoint=c.WorkPoint
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
left join dbo.ICSWareHouseLotInfo d on a.LotNo=d.LotNo and a.WorkPoint=d.WorkPoint
left join ICSInspection e on a.LotNo=e.LotNo and e.Enable='1' and a.WorkPoint=e.WorkPoint
left join ICSInventory g on a.InvCode=g.InvCode and a.WorkPoint=g.WorkPoint
WHERE isnull(a.EATTRIBUTE1,'')='" + LotNo+"' and a.Type='" + Type + "' and a.WorkPoint in ('" + WorkPoint + "')";
sql = string.Format(sql, Figure);
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
}
public int SubmitFormBHGTM(string OldLotNo, 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 = "DN" + DNCode + (Convert.ToInt32(Sequence)).ToString("D4");
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;
string Colspan = "";
string str1 = "";
List<string> ExtensionIDList = new List<string>();
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
string LotNo = GetNewLotNo(OldLotNo);
sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
select '{0}',TransCode,TransSequence,'{1}','{2}',getdate(),'{3}' from ICSInventoryLotDetail where LotNo='{4}'",
LotNo, MUSER, MUSERNAME, WorkPoints, OldLotNo);
sql += string.Format(@"
insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount,EATTRIBUTE1)
select
newid(),'{0}',a.InvCode,a.ProductDate,a.ExpirationDate,b.UnqualifiedQuantity,a.ExtensionID,'17','{1}','{2}',getdate(),'{3}',a.Amount,'{4}'
from ICSInventoryLot a
inner join ICSInspection b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint and b.Enable='1'
where a.LotNo='{4}' and a.WorkPoint='{3}'",
LotNo, MUSER, MUSERNAME, WorkPoints, OldLotNo);
sql += "\r\n";
}
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
return count;
}
public string GetNewLotNo(string LotNO)
{
DataTable dt = new DataTable();
List<DbParameter> parameter = new List<DbParameter>();
//string sql = @"select max(LotNo) as NewLotNo from ICSInventoryLot where EATTRIBUTE1='{0}' ";
string sql = @"SELECT TOP 1 LotNO as NewLotNo FROM ICSInventoryLot WHERE EATTRIBUTE1='{0}'
ORDER BY CAST(SUBSTRING(LotNO, (LEN(LotNO)-CHARINDEX('-',REVERSE(LotNO))+1)+1,CHARINDEX('-',REVERSE(LotNO))-1) AS INT) DESC";
sql = string.Format(sql, LotNO);
dt = Repository().FindTableBySql(sql.ToString());
if (dt == null || dt.Rows.Count == 0 || dt.Rows[0]["NewLotNo"].ToString() == "")
{
return LotNO + "-1";
}
else
{
string newLotNO = dt.Rows[0]["NewLotNo"].ToString();
int COUNT = Convert.ToInt32(newLotNO.Substring(newLotNO.LastIndexOf('-') + 1)) + 1;
return LotNO + "-" + COUNT.ToString();
}
}
public DataTable SelGDLX()
{
string sql = string.Empty;
DataTable dt = null;
sql = string.Format(@"select distinct isnull(MOType,'') as Code ,isnull(MOType,'') as Name from dbo.ICSMO where isnull(MOType,'')<>''");
dt = SqlHelper.GetDataTableBySql(sql);
return dt;
}
public DataTable GetFreeEnble()
{
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
string sql = @"
select * from ICSExtensionEnable where WorkPoint='" + WorkPoints + "' order by cast(EATTRIBUTE1 as int) ";
return Repository().FindTableBySql(sql.ToString());
}
public DataTable GetInvBatchEnable(string InvCode)
{
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
string sql = @"select distinct BatchEnable from ICSInventory where InvCode='{0}' and WorkPoint='{1}'";
sql = string.Format(sql,InvCode, WorkPoints);
DataTable dt = SqlHelper.GetDataTableBySql(sql);
return dt;
}
//副产品
public DataTable GetGridJsonFCP(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
object Figure = GetDecimalDigits();
#region [SQL]
string sql = @"select a.ID,d.MOCode,d.Sequence+'~'+ a.Sequence as Sequence,a.PickID,a.InvCode as ZInvCode,d.InvCode as MInvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,
CAST(a.Quantity AS DECIMAL(18,{0})) as Quantity ,
CAST(a.Amount AS DECIMAL(18,{0})) as Amount,CAST(a.IssueQuantity AS DECIMAL(18,{0})) as IssueQuantity ,a.ExtensionID,a.MUSERName,a.MTIME ,CAST(c.LOTQTY AS DECIMAL(18,{0})) as LOTQTY
,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4
,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8,
a.EATTRIBUTE9,a.EATTRIBUTE10
from ICSMOPick a
left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3'
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 and ee.type='18'
where isnull(ee.EATTRIBUTE1,'')=''
group by mm.TransCode,mm.TransSequence,ee.WorkPoint
)c
on d.MOCode=c.TransCode and d.Sequence+'~'+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.EATTRIBUTE1='1' ";
sql = string.Format(sql, Figure);
sql = string.Format(sql, DbHelper.GetErpIp(), DbHelper.GetErpName());
#endregion
if (!string.IsNullOrWhiteSpace(queryJson))
{
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
{
sql += " and d.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 (!string.IsNullOrWhiteSpace(queryParam["POStatus"].ToString()))
{
string POStatus = queryParam["POStatus"].ToString();
if (POStatus == "0")
{
//sql += " and a.Quantity=ISNULL(c.LotQty,0)";
}
else if (POStatus == "1")
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)=0";
}
else
{
sql += " and a.Quantity-ISNULL(c.LOTQTY,0)<>0";
}
}
}
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 GetSubGridJsonFCPCreate(string FCPMOCode, string Sequence, string WorkPoint)
{
DataTable dt = new DataTable();
object Figure = GetDecimalDigits();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"
select a.InvCode,b.InvName,b.ClassCode,b.InvStd,b.InvUnit, CAST( a.Quantity AS DECIMAL(18,{0})) as Quantity,CAST( a.Amount as DECIMAL(18,{0})) as Amount, CAST( isnull(c.LOTQTY,0) as DECIMAL(18,{0})) as CreatedQty,
CAST( (a.Quantity-ISNULL(c.LOTQTY,0)) as DECIMAL(18,{0})) as thisCreateQty,isnull(b.EffectiveEnable,0) as EffectiveEnable, CAST( isnull(b.EffectiveDays,0) as DECIMAL(18,{0})) as EffectiveDays
,e.ProjectCode,e.BatchCode,e.Version,e.Brand,e.cFree1,e.cFree2,e.cFree3,e.cFree4,e.cFree5,e.cFree6,e.cFree7,e.cFree8,e.cFree9,e.cFree10
from ICSMOPick a
left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3'
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 and a.Type='18'
where isnull(a.EATTRIBUTE1,'')=''
group by b.TransCode,b.TransSequence
) c on d.MOCode=c.TransCode and d.Sequence+'~'+a.Sequence=c.TransSequence
left join ICSExtension e on d.ExtensionID=e.ID and a.WorkPoint=e.WorkPoint
WHERE 1=1
and d.MOCode='" + FCPMOCode + "' and d.Sequence+'~'+a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'";
sql = string.Format(sql, Figure);
return Repository().FindTableBySql(sql.ToString());
}
//副产品
public int SubmitFormFCP(string FCPMOCode, 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 Sequences = Sequence.Replace("~", "");
string Pre = "FCP" + FCPMOCode + (Convert.ToInt32(Sequences)).ToString("D4");
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string sql = string.Empty;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString();
string sqls = string.Empty;
string Colspan = "";
string str1 = "";
List<string> ExtensionIDList = new List<string>();
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
Colspan = queryParam["ProjectCode"].ToString() + "~" + queryParam["BatchCode"].ToString() + "~" + queryParam["Version"].ToString() + "~" + queryParam["Brand"].ToString() + "~" + queryParam["cFree1"].ToString() + "~" + queryParam["cFree2"].ToString() + "~" + queryParam["cFree3"].ToString() + "~" + queryParam["cFree4"].ToString() + "~" + queryParam["cFree5"].ToString() + "~" + queryParam["cFree6"].ToString() + "~" + queryParam["cFree7"].ToString() + "~" + queryParam["cFree8"].ToString() + "~" + queryParam["cFree9"].ToString() + "~" + queryParam["cFree10"].ToString();
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
bool flag = true;
foreach (var item in ExtensionIDList)
{
if (item == Colspan + WorkPoint)
{
flag = false;
}
}
if (ExtensionID == null && flag == true)
{
str1 = Guid.NewGuid().ToString();
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
str1, Colspan, queryParam["ProjectCode"].ToString(), queryParam["BatchCode"].ToString(), queryParam["Version"].ToString(), queryParam["Brand"].ToString(), queryParam["cFree1"].ToString(), queryParam["cFree2"].ToString(), queryParam["cFree3"].ToString(), queryParam["cFree4"].ToString(), queryParam["cFree5"].ToString(), queryParam["cFree6"].ToString(), queryParam["cFree7"].ToString(), queryParam["cFree8"].ToString(), queryParam["cFree9"].ToString(), queryParam["cFree10"].ToString(),
MUSER, MUSERNAME, WorkPoints);
}
else if (ExtensionID != null)
{
str1 = ExtensionID.ToString();
}
ExtensionIDList.Add(Colspan + WorkPoint);
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, FCPMOCode, Sequence, MUSER, MUSERNAME, WorkPoints);
sql += string.Format(@"insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount ,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,EATTRIBUTE9,EATTRIBUTE10)
select
newid(),'{0}',a.InvCode,'{1}','{10}','{2}','{8}','18','{3}','{4}', getdate(),'{5}','{9}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}'
from ICSMOPick a left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3' where d.MOCode='{6}' and d.Sequence+'~'+a.Sequence='{7}' and a.WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, FCPMOCode, Sequence, str1, Convert.ToDecimal(queryParam["Amount"].ToString()) / minPackQty * LOTQTY, queryParam["ExpirationDate"].ToString()
, queryParam["EATTRIBUTE1"].ToString(), queryParam["EATTRIBUTE2"].ToString(), queryParam["EATTRIBUTE3"].ToString(), queryParam["EATTRIBUTE4"].ToString(), queryParam["EATTRIBUTE5"].ToString(),
queryParam["EATTRIBUTE6"].ToString(), queryParam["EATTRIBUTE7"].ToString(), queryParam["EATTRIBUTE8"].ToString(), queryParam["EATTRIBUTE9"].ToString(), queryParam["EATTRIBUTE10"].ToString());
sql += "\r\n";
}
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
return count;
}
public bool GetGeneratedNum(string Code, string Sequence, string Type, string thisCreateQty)
{
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
DataTable dt = new DataTable();
List<DbParameter> parameter = new List<DbParameter>();
string sql = string.Empty;
bool flag = true;
if (Type=="1")
{
sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
from ICSMOApplyNegDetail a
left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
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 and ee.type='1'
where isnull(ee.EATTRIBUTE1,'')=''
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
where d.Type='1'
and a.ApplyNegCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
}
if (Type=="2")
{
sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
from ICSOApplyNegDetail a
left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
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 and ee.type='2'
where isnull(ee.EATTRIBUTE1,'')=''
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
WHERE d.Type='1' and a.OApplyNegCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
}
if (Type == "3")
{
sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
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 and ee.type='3'
where isnull(ee.EATTRIBUTE1,'')=''
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
WHERE 1=1 and a.MOStatus<>'3' and a.MOCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
}
if (Type == "4")
{
sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
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 and ee.type='4'
where isnull(ee.EATTRIBUTE1,'')=''
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'
and a.SDNCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
}
if (Type == "5")
{
sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
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 and ee.type='5'
where isnull(ee.EATTRIBUTE1,'')=''
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'
and a.InCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
}
if (Type == "6")
{
sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
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 and ee.type='6'
where isnull(ee.EATTRIBUTE1,'')=''
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'
and a.ReturnCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
}
if (Type == "7")
{
sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
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 and ee.type='7'
where isnull(ee.EATTRIBUTE1,'')=''
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.DNType='1' and a.Status='2' and a.ASNCode is null
and a.DNCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
}
if (Type == "8")
{
sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
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 and ee.type='8'
where isnull(ee.EATTRIBUTE1,'')=''
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
and a.ODNCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
}
if (Type == "9")
{
sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
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 and ee.type='9'
where isnull(ee.EATTRIBUTE1,'')=''
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'
and a.RCVCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
}
if (Type == "10")
{
sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
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 and ee.type='10'
where isnull(ee.EATTRIBUTE1,'')=''
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.DNType='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null
and a.DNCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
}
if (Type == "11")
{
sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
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 and ee.type='11'
where isnull(ee.EATTRIBUTE1,'')=''
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='3' and a.Status='2' and a.EATTRIBUTE1 is NOT null
and a.ODNCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
}
if (Type == "12")
{
sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
from ICSMOApplyNegDetail a
left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
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 and ee.type='12'
where isnull(ee.EATTRIBUTE1,'')=''
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
WHERE d.Type='2'
and a.ApplyNegCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
}
if (Type == "13")
{
sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
from ICSMOApplyNegDetail a
left join ICSMOApplyNeg d on a.ApplyNegCode=d.ApplyNegCode and a.WorkPoint=d.WorkPoint
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 and ee.type='13'
where isnull(ee.EATTRIBUTE1,'')=''
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
WHERE d.Type='3'
and a.ApplyNegCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
}
if (Type == "14")
{
sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
from ICSOApplyNegDetail a
left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
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 and ee.type='14'
where isnull(ee.EATTRIBUTE1,'')=''
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
WHERE d.Type='2'
and a.OApplyNegCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
}
if (Type == "15")
{
sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
from ICSOApplyNegDetail a
left join ICSOApplyNeg d on a.OApplyNegCode=d.OApplyNegCode AND a.WorkPoint=d.WorkPoint
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 and ee.type='15'
where isnull(ee.EATTRIBUTE1,'')=''
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
WHERE d.Type='3'
and a.OApplyNegCode='" + Code + "' and a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
}
if (Type == "16")
{
sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
from ICSMOPick a
left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3'
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 and ee.type='16'
where isnull(ee.EATTRIBUTE1,'')=''
group by mm.TransCode,mm.TransSequence,ee.WorkPoint
)c
on d.MOCode=c.TransCode and d.Sequence+'~'+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.EATTRIBUTE1='1' and d.EATTRIBUTE1='1'
and d.MOCode='" + Code + "' and d.Sequence+'~'+a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
}
if (Type == "18")
{
sql = @" select distinct CAST(isnull(a.Quantity,0) AS DECIMAL(18,4)) as Quantity ,
CAST(isnull(c.LOTQTY,0) AS DECIMAL(18,4)) as LOTQTY
from ICSMOPick a
left join ICSMO d on a.MODetailID=d.MODetailID and a.WorkPoint=d.WorkPoint and d.MOStatus<>'3'
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 and ee.type='18'
where isnull(ee.EATTRIBUTE1,'')=''
group by mm.TransCode,mm.TransSequence,ee.WorkPoint
)c
on d.MOCode=c.TransCode and d.Sequence+'~'+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.EATTRIBUTE1='1'
and d.MOCode='" + Code + "' and d.Sequence+'~'+a.Sequence='" + Sequence + "' and a.WorkPoint='" + WorkPoints + "'";
}
dt = SqlHelper.GetDataTableBySql(sql);
decimal Quantity= Convert.ToDecimal(dt.Rows[0]["Quantity"].ToString());
decimal LOTQTY = Convert.ToDecimal(dt.Rows[0]["LOTQTY"].ToString());
decimal thisQty = Convert.ToDecimal(thisCreateQty);
if (LOTQTY+ thisQty> Quantity)
{
flag = false;
}
return flag;
}
/// <summary>
/// 开立成品入库单(一键生成)
/// </summary>
public int SubmitFormKLCPRKALL (string keyValue)
{
string sql = string.Empty;
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
foreach (var item in res)
{
JObject jo = (JObject)item;
int createPageCount = Convert.ToInt32(jo["createPageCount"].ToString());
decimal minPackQty = Convert.ToDecimal(jo["minPackQty"].ToString());
decimal thisCreateQty = Convert.ToDecimal(jo["thisCreateQty"].ToString());
decimal LOTQTY = minPackQty;
string Pre = "KCP" + jo["Code"].ToString() + (Convert.ToInt32(jo["Sequence"].ToString())).ToString("D4");
string PRODUCTDATE = jo["PRODUCTDATE"].ToString();
string sqls = string.Empty;
string Colspan = "";
string str1 = "";
List<string> ExtensionIDList = new List<string>();
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
Colspan = jo["ProjectCode"].ToString() + "~" + jo["BatchCode"].ToString() + "~" + jo["Version"].ToString() + "~" + jo["Brand"].ToString() + "~" + jo["cFree1"].ToString() + "~" + jo["cFree2"].ToString() + "~" + jo["cFree3"].ToString() + "~" + jo["cFree4"].ToString() + "~" + jo["cFree5"].ToString() + "~" + jo["cFree6"].ToString() + "~" + jo["cFree7"].ToString() + "~" + jo["cFree8"].ToString() + "~" + jo["cFree9"].ToString() + "~" + jo["cFree10"].ToString();
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
bool flag = true;
foreach (var items in ExtensionIDList)
{
if (items == Colspan + WorkPoint)
{
flag = false;
}
}
if (ExtensionID == null && flag == true)
{
str1 = Guid.NewGuid().ToString();
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
str1, Colspan, jo["ProjectCode"].ToString(), jo["BatchCode"].ToString(), jo["Version"].ToString(), jo["Brand"].ToString(), jo["cFree1"].ToString(), jo["cFree2"].ToString(), jo["cFree3"].ToString(), jo["cFree4"].ToString(), jo["cFree5"].ToString(), jo["cFree6"].ToString(), jo["cFree7"].ToString(), jo["cFree8"].ToString(), jo["cFree9"].ToString(), jo["cFree10"].ToString(),
MUSER, MUSERNAME, WorkPoint);
}
else if (ExtensionID != null)
{
str1 = ExtensionID.ToString();
}
ExtensionIDList.Add(Colspan + WorkPoint);
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, jo["Code"].ToString(), jo["Sequence"].ToString(), MUSER, MUSERNAME, WorkPoint);
sql += string.Format(@"
insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
select
newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','9','{3}','{4}', getdate(),'{5}','{9}'
from ICSManufactureReceive where RCVCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoint, jo["Code"].ToString(), jo["Sequence"].ToString(), str1, Convert.ToDecimal(jo["Amount"].ToString()) / minPackQty * LOTQTY, jo["ExpirationDate"].ToString());
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 SubmitFormSHDHALL(string keyValue)
{
string sql = string.Empty;
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
foreach (var resItem in res)
{
JObject jo = (JObject)resItem;
int createPageCount = Convert.ToInt32(jo["createPageCount"].ToString());
decimal minPackQty = Convert.ToDecimal(jo["minPackQty"].ToString());
decimal thisCreateQty = Convert.ToDecimal(jo["thisCreateQty"].ToString());
decimal LOTQTY = minPackQty;
string Pre = "DN" + jo["Code"].ToString() + (Convert.ToInt32(jo["Sequence"])).ToString("D4");
string PRODUCTDATE = jo["PRODUCTDATE"].ToString();
string sqls = string.Empty;
string Colspan = "";
string str1 = "";
List<string> ExtensionIDList = new List<string>();
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
Colspan = jo["ProjectCode"].ToString() + "~" + jo["BatchCode"].ToString() + "~" + jo["Version"].ToString() + "~" + jo["Brand"].ToString() + "~" + jo["cFree1"].ToString() + "~" + jo["cFree2"].ToString() + "~" + jo["cFree3"].ToString() + "~" + jo["cFree4"].ToString() + "~" + jo["cFree5"].ToString() + "~" + jo["cFree6"].ToString() + "~" + jo["cFree7"].ToString() + "~" + jo["cFree8"].ToString() + "~" + jo["cFree9"].ToString() + "~" + jo["cFree10"].ToString();
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
bool flag = true;
foreach (var item in ExtensionIDList)
{
if (item == Colspan + WorkPoint)
{
flag = false;
}
}
if (ExtensionID == null && flag == true)
{
str1 = Guid.NewGuid().ToString();
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
str1, Colspan, jo["ProjectCode"].ToString(), jo["BatchCode"].ToString(), jo["Version"].ToString(), jo["Brand"].ToString(), jo["cFree1"].ToString(), jo["cFree2"].ToString(), jo["cFree3"].ToString(), jo["cFree4"].ToString(), jo["cFree5"].ToString(), jo["cFree6"].ToString(), jo["cFree7"].ToString(), jo["cFree8"].ToString(), jo["cFree9"].ToString(), jo["cFree10"].ToString(),
MUSER, MUSERNAME, WorkPoint);
}
else if (ExtensionID != null)
{
str1 = ExtensionID.ToString();
}
ExtensionIDList.Add(Colspan + WorkPoint);
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, jo["Code"].ToString(), jo["Sequence"].ToString(), MUSER, MUSERNAME, WorkPoint);
sql += string.Format(@"
insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
select
newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','7','{3}','{4}', getdate(),'{5}','{9}'
from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoint, jo["Code"].ToString(), jo["Sequence"], str1, Convert.ToDecimal(jo["Amount"].ToString()) / minPackQty * LOTQTY, jo["ExpirationDate"].ToString());
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 SubmitFormWWSHDHALL(string keyValue)
{
string sql = string.Empty;
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
foreach (var resItem in res)
{
JObject jo = (JObject)resItem;
int createPageCount = Convert.ToInt32(jo["createPageCount"].ToString());
decimal minPackQty = Convert.ToDecimal(jo["minPackQty"].ToString());
decimal thisCreateQty = Convert.ToDecimal(jo["thisCreateQty"].ToString());
decimal LOTQTY = minPackQty;
string Pre = "ODN" + jo["Code"] + (Convert.ToInt32(jo["Sequence"])).ToString("D4");
string PRODUCTDATE = jo["PRODUCTDATE"].ToString();
string sqls = string.Empty;
string Colspan = "";
string str1 = "";
List<string> ExtensionIDList = new List<string>();
for (int i = 0; i < createPageCount; i++)
{
if (i + 1 == createPageCount)
{
if (minPackQty * createPageCount > thisCreateQty)
{
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1));
}
}
Colspan = jo["ProjectCode"].ToString() + "~" + jo["BatchCode"].ToString() + "~" + jo["Version"].ToString() + "~" + jo["Brand"].ToString() + "~" + jo["cFree1"].ToString() + "~" + jo["cFree2"].ToString() + "~" + jo["cFree3"].ToString() + "~" + jo["cFree4"].ToString() + "~" + jo["cFree5"].ToString() + "~" + jo["cFree6"].ToString() + "~" + jo["cFree7"].ToString() + "~" + jo["cFree8"].ToString() + "~" + jo["cFree9"].ToString() + "~" + jo["cFree10"].ToString();
sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
bool flag = true;
foreach (var item in ExtensionIDList)
{
if (item == Colspan + WorkPoint)
{
flag = false;
}
}
if (ExtensionID == null && flag == true)
{
str1 = Guid.NewGuid().ToString();
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
str1, Colspan, jo["ProjectCode"].ToString(), jo["BatchCode"].ToString(), jo["Version"].ToString(), jo["Brand"].ToString(), jo["cFree1"].ToString(), jo["cFree2"].ToString(), jo["cFree3"].ToString(), jo["cFree4"].ToString(), jo["cFree5"].ToString(), jo["cFree6"].ToString(), jo["cFree7"].ToString(), jo["cFree8"].ToString(), jo["cFree9"].ToString(), jo["cFree10"].ToString(),
MUSER, MUSERNAME, WorkPoint);
}
else if (ExtensionID != null)
{
str1 = ExtensionID.ToString();
}
ExtensionIDList.Add(Colspan + WorkPoint);
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, jo["Code"], jo["Sequence"], MUSER, MUSERNAME, WorkPoint);
sql += string.Format(@"
insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount)
select
newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','8','{3}','{4}', getdate(),'{5}','{9}'
from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoint, jo["Code"], jo["Sequence"], str1, Convert.ToDecimal(jo["Amount"].ToString()) / minPackQty * LOTQTY, jo["ExpirationDate"].ToString());
sql += "\r\n";
}
}
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
return count;
}
public DataTable SelectICSColumnEnableForLotEnable()
{
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
string sql = @" select ColumnCode from ICSColumnEnable
where Enable='0' and TableCode='ICSInventoryLot' and WorkPoint='" + WorkPoints + "' order by cast(Code as int)";
DataTable dt = SqlHelper.GetDataTableBySql(sql);
return dt;
}
public DataTable GetLoadShowForColumn()
{
string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
string sql = @"
select * from ICSColumnEnable where TableCode='ICSInventoryLot' and WorkPoint='" + WorkPoints + "' order by cast(code as int) ";
DataTable dt = SqlHelper.GetDataTableBySql(sql);
return dt;
}
public string GetAMEnable()
{
string Code = SqlHelper.GetItemsDetailEnabledMark("LotNoMaintenance");
return Code;
}
public DataTable SeachMeasure()
{
DataTable dt = new DataTable();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @" SELECT Top 1 a.F_ItemCode as Code
FROM [dbo].[Sys_SRM_ItemsDetail] a
LEFT JOIN [dbo].[Sys_SRM_Items] b ON a.F_ItemId=b.F_Id
WHERE b.F_EnCode='CrtLot001' AND a.F_EnabledMark='1' ORDER BY a.F_ItemCode";
return Repository().FindTableBySql(sql.ToString());
}
public DataTable SeachLableofDisable()
{
DataTable dt = new DataTable();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"
SELECT a.F_ItemCode as Code,a.F_EnabledMark as Enable
FROM [dbo].[Sys_SRM_ItemsDetail] a
LEFT JOIN [dbo].[Sys_SRM_Items] b ON a.F_ItemId=b.F_Id
WHERE b.F_EnCode='Lot0001' ORDER BY a.F_SortCode";
return Repository().FindTableBySql(sql.ToString());
}
public DataTable SeachAmountEnablebyInvCode(string InvCode)
{
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
DataTable dt = new DataTable();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"
select isnull(AmountEnable,0) as AmountEnable from dbo.ICSInventory where InvCode='"+ InvCode + "' and WorkPoint='"+ WorkPoint + "'";
return Repository().FindTableBySql(sql.ToString());
}
public string LotBindCode(String savePath)
{
//数据获取
try
{
int index = 1;
string msg = "";
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
SqlConnection conn = SqlHelper.GetDataCenterConn();
string sql = "";
int count = 0;
DataTable data = FileToExcel.ExcelToTable(savePath);
foreach (DataRow dr in data.Rows)
{
index++;
//string GUID = Guid.NewGuid().ToString();
string Code = dr["单据号"].ToString().Trim().ToUpper();
string Sequence = dr["单据行号"].ToString().Trim().ToUpper();
string LotNo = dr["条码"].ToString().Trim().ToUpper();
string Quantity = dr["条码数量"].ToString().Trim().ToUpper();
if (Code == "" || Code == null)
{
throw new Exception("第 " + index + " 行单据号不能为空!");
}
if (Sequence == "" || Sequence == null)
{
throw new Exception("第 " + index + " 行单据行号不能为空!");
}
if (LotNo == "" || LotNo == null)
{
throw new Exception("第 " + index + " 行条码不能为空!");
}
if (Quantity == "" || Quantity == null)
{
throw new Exception("第 " + index + " 行条码数量不能为空!");
}
string sqlCode = @" select a.MOCode,a.Sequence, a.Quantity,a.Amount,a.InvCode,isnull(c.LOTQTY,0) as LOTQTY,
case when b.EffectiveEnable='1' then getdate()+b.EffectiveDays else '2999-12-31 00:00:00.000' end as ExpirationDate,
a.ExtensionID
from ICSMO a
left join (
select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY from ICSInventoryLot a
left join ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.Type='3'
where isnull(a.EATTRIBUTE1,'')=''
group by b.TransCode,b.TransSequence
) c on a.MOCode=c.TransCode and a.Sequence=c.TransSequence
inner join dbo.ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint where a.MOCode='{0}' and a.Sequence='{1}' and a.WorkPoint='{2}'";
sqlCode = string.Format(sqlCode, Code, Sequence, WorkPoint);
DataTable dd = SqlHelper.CmdExecuteDataTable(sqlCode);
if (dd == null || dd.Rows.Count <= 0)
{
throw new Exception("第 " + index + "行单号: " + Code + "行号" + Sequence + " 单据不存在!");
}
string ExtensionID = dd.Rows[0]["ExtensionID"].ToString();
string ExpirationDate= dd.Rows[0]["ExpirationDate"].ToString();
string InvCode = dd.Rows[0]["InvCode"].ToString();
decimal CQuantity = Convert.ToDecimal(dd.Rows[0]["Quantity"].ToString());
decimal CAmount = Convert.ToDecimal(dd.Rows[0]["Amount"].ToString());
decimal CLOTQTY = Convert.ToDecimal(dd.Rows[0]["LOTQTY"].ToString());
if (Convert.ToDecimal(Quantity) > (CQuantity- CLOTQTY))
{
throw new Exception("第 " + index + "行单号: " + Code + "行号" + Sequence + " 所输入条码数量超出该单据可生成数量!");
}
var Amount = CAmount / CQuantity * Convert.ToDecimal(Quantity);
sql += @"Insert INto ICSInventoryLot
( ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,Amount,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint)
Values (newid(),'{0}','{1}',getdate(),'{2}','{3}','{4}','{5}','3','{6}','{7}',getdate(),'{8}')
";
sql += @" Insert INto ICSInventoryLotDetail
( LotNo,TransID,TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values ('{0}','','{9}','{10}','{6}','{7}',getdate(),'{8}')";
sql = string.Format(sql, LotNo, InvCode, ExpirationDate, Quantity, Amount, ExtensionID, MUSER, MUSERNAME, WorkPoint, Code, Sequence);
}
count = SqlHelper.CmdExecuteNonQueryLi(sql);
if (count > 0)
{
msg = "导入成功";
}
else
{
return "无有效的导入数据。";
}
return msg;
}
catch (Exception ex)
{
return ex.Message;
}
}
}
}