|
|
@ -1643,5 +1643,200 @@ left join (select b.TransCode,b.TransSequence,sum(isnull(Quantity,0)) LOTQTY fro |
|
|
|
return Repository().FindTableBySql(sql.ToString()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public DataTable GetSubGridJsonLLSQDByCreate(string ApplyNegCode, string Sequence, string WorkPoint) |
|
|
|
{ |
|
|
|
DataTable dt = new DataTable(); |
|
|
|
//var queryParam = queryJson.ToJObject();
|
|
|
|
List<DbParameter> parameter = new List<DbParameter>(); |
|
|
|
string sql = @" select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
|
|
|
|
(a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty |
|
|
|
from ICSMOApplyNegDetail a |
|
|
|
left join 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 |
|
|
|
group by b.TransCode,b.TransSequence |
|
|
|
) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence |
|
|
|
WHERE d.Type='2' |
|
|
|
and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
|
|
|
|
sql += " and a.WorkPoint='" + WorkPoint + "'"; |
|
|
|
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 = ApplyNegCode + Sequence; |
|
|
|
string sql = string.Empty; |
|
|
|
//string VendorLot = queryParam["VendorLot"].ToString();
|
|
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; |
|
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; |
|
|
|
string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString(); |
|
|
|
string sqls = string.Empty; |
|
|
|
for (int i = 0; i < createPageCount; i++) |
|
|
|
{ |
|
|
|
if (i + 1 == createPageCount) |
|
|
|
{ |
|
|
|
if (minPackQty * createPageCount > thisCreateQty) |
|
|
|
{ |
|
|
|
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); |
|
|
|
sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
|
|
|
|
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
|
|
|
|
LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints); |
|
|
|
//if (SqlHelper.ExecuteNonQuery(sqls) > 0)
|
|
|
|
//{
|
|
|
|
sql += string.Format(@"insert into ICSInventoryLot
|
|
|
|
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint) |
|
|
|
select |
|
|
|
newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'3','{3}','{4}', getdate(),'{5}' |
|
|
|
from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
|
|
|
|
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence); |
|
|
|
sql += "\r\n"; |
|
|
|
//}
|
|
|
|
|
|
|
|
} |
|
|
|
int count = SqlHelper.CmdExecuteNonQueryLi(sql); |
|
|
|
return count; |
|
|
|
} |
|
|
|
|
|
|
|
//材料出库退料
|
|
|
|
public DataTable GetGridJsonCLCK(string queryJson, ref Pagination jqgridparam) |
|
|
|
{ |
|
|
|
DataTable dt = new DataTable(); |
|
|
|
var queryParam = queryJson.ToJObject(); |
|
|
|
List<DbParameter> parameter = new List<DbParameter>(); |
|
|
|
|
|
|
|
#region [SQL]
|
|
|
|
string sql = @"
|
|
|
|
select a.ID,a.ApplyNegCode,a.Sequence,a.SourceDetailID,a.InvCode,b.InvName,b.InvDesc,b.InvStd,b.InvUnit,a.Quantity,a.Amount,a.IssueNegQuantity,a.ExtensionID,a.MUSERName,a.MTIME ,c.LOTQTY,f.BatchCode |
|
|
|
from ICSMOApplyNegDetail a |
|
|
|
left join 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 |
|
|
|
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, DbHelper.GetErpIp(), DbHelper.GetErpName()); |
|
|
|
#endregion
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryJson)) |
|
|
|
{ |
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString())) |
|
|
|
{ |
|
|
|
sql += " and a.RCVCode like '%" + queryParam["POCode"].ToString() + "%' "; |
|
|
|
} |
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) |
|
|
|
{ |
|
|
|
sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' "; |
|
|
|
} |
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString())) |
|
|
|
{ |
|
|
|
sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' "; |
|
|
|
} |
|
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString())) |
|
|
|
{ |
|
|
|
sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' "; |
|
|
|
} |
|
|
|
} |
|
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin") |
|
|
|
{ |
|
|
|
sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'"; |
|
|
|
} |
|
|
|
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor") |
|
|
|
{ |
|
|
|
sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'"; |
|
|
|
} |
|
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam); |
|
|
|
} |
|
|
|
|
|
|
|
//材料出库退料
|
|
|
|
public DataTable GetSubGridJsonCLCKByCreate(string ApplyNegCode, string Sequence, string WorkPoint) |
|
|
|
{ |
|
|
|
DataTable dt = new DataTable(); |
|
|
|
//var queryParam = queryJson.ToJObject();
|
|
|
|
List<DbParameter> parameter = new List<DbParameter>(); |
|
|
|
string sql = @" select a.InvCode,b.InvName,b.InvStd,b.InvUnit,a.Quantity,ISNULL(c.LOTQTY,0) AS CreatedQty,
|
|
|
|
(a.Quantity-ISNULL(c.LOTQTY,0)) as thisCreateQty |
|
|
|
from ICSMOApplyNegDetail a |
|
|
|
left join 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 |
|
|
|
group by b.TransCode,b.TransSequence |
|
|
|
) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence |
|
|
|
WHERE d.Type='3' |
|
|
|
and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
|
|
|
|
sql += " and a.WorkPoint='" + WorkPoint + "'"; |
|
|
|
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 WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
//string VenCode = GetVendorCode(ApplyNegCode, Sequence, WorkPoint);
|
|
|
|
string Pre = ApplyNegCode + Sequence; |
|
|
|
string sql = string.Empty; |
|
|
|
//string VendorLot = queryParam["VendorLot"].ToString();
|
|
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; |
|
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; |
|
|
|
string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString(); |
|
|
|
string sqls = string.Empty; |
|
|
|
for (int i = 0; i < createPageCount; i++) |
|
|
|
{ |
|
|
|
if (i + 1 == createPageCount) |
|
|
|
{ |
|
|
|
if (minPackQty * createPageCount > thisCreateQty) |
|
|
|
{ |
|
|
|
LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); |
|
|
|
sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
|
|
|
|
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
|
|
|
|
LotNo, ApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints); |
|
|
|
//if (SqlHelper.ExecuteNonQuery(sqls) > 0)
|
|
|
|
//{
|
|
|
|
sql += string.Format(@"insert into ICSInventoryLot
|
|
|
|
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint) |
|
|
|
select |
|
|
|
newid(),'{0}',InvCode,'{1}','2999-12-31 00:00:00.000','{2}',ExtensionID,'3','{3}','{4}', getdate(),'{5}' |
|
|
|
from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
|
|
|
|
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence); |
|
|
|
sql += "\r\n"; |
|
|
|
//}
|
|
|
|
|
|
|
|
} |
|
|
|
int count = SqlHelper.CmdExecuteNonQueryLi(sql); |
|
|
|
return count; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
xxxxxxxxxx