|
|
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 Newtonsoft.Json; using System.Configuration; using Newtonsoft.Json.Linq; using NFine.Domain._03_Entity.WMS; using System.Text; using System.Net; using System.IO; using System.Data.SqlClient; using ICS.Data;
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,a.ApplyNegCode, cast(a.Sequence as int) as 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='1' 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'";
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 (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin") { sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'"; } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor") { sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'"; } return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam); }
public DataTable GetSubGridJson(string ApplyNegCode, string Sequence, 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(b.LotNoCount,0)>0 THEN '已入库' ELSE '未入库' END AS RKState 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 WHERE 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.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 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' group by b.TransCode,b.TransSequence ) c on a.ApplyNegCode=c.TransCode and a.Sequence=c.TransSequence WHERE 1 =1 and a.ApplyNegCode='" + ApplyNegCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'"; 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) { 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 sqls = string.Empty; string Colspan = ""; 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, WorkPoints); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); 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}' )",
ExtensionID, 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); } 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,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','1','{3}','{4}', getdate(),'{5}','{9}' from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal( Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY)/ minPackQty* LOTQTY, queryParam["ExpirationDate"].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 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, cast(a.Sequence as int) as 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 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' 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 (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.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
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' group by b.TransCode,b.TransSequence ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence 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 = ""; 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, WorkPoints); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); 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}' )",
ExtensionID, 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); } for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } } string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints); 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}','2','{3}','{4}', getdate(),'{5}','{9}' from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal( Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY)/ minPackQty* LOTQTY, queryParam["ExpirationDate"].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 a.ID,a.MOCode, cast(a.Sequence as int) as 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 ,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.CreateDateTime,a.ERPStatus 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 ";
sql += " WHERE 1=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.MOCode like '%" + queryParam["POCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString())) { sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["InvName"].ToString())) { sql += " and b.InvName like '%" + queryParam["InvName"].ToString() + "%' "; } if (!string.IsNullOrWhiteSpace(queryParam["BatchCode"].ToString())) { sql += " and f.BatchCode like '%" + queryParam["BatchCode"].ToString() + "%' "; } } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin") { sql += " and a.WorkPoint='" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location + "'"; } if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor") { sql += " and a.VenCode='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'"; } //sql += " order by a.MOCode, cast(a.Sequence as int)";
// sql += " order by a.MTIME desc ,a.MOCode asc,cast(a.Sequence as int) asc";
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 a.InvCode,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 , 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 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' group by b.TransCode,b.TransSequence ) c on a.MOCode=c.TransCode and a.Sequence=c.TransSequence left join dbo.ICSExtension d on a.ExtensionID=d.ID and a.WorkPoint=d.WorkPoint WHERE 1 =1 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 sqls = string.Empty; string Colspan = ""; 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, WorkPoints); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); 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}' )",
ExtensionID, 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); } for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } }
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
LotNo, MOCode, Sequence, MUSER, MUSERNAME, WorkPoints); //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
//{
sql += string.Format(@"insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','3','{3}','{4}', getdate(),'{5}','{9}' from ICSMO where MOCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, MOCode, Sequence, ExtensionID, Convert.ToDecimal( Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY)/ minPackQty* LOTQTY, queryParam["ExpirationDate"].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, cast(a.Sequence as int) as 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 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' 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 (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.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' group by b.TransCode,b.TransSequence ) c on a.SDNCode=c.TransCode and a.Sequence=c.TransSequence left join dbo.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) { 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 sqls = string.Empty; string Colspan = ""; 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, WorkPoints); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); 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}' )",
ExtensionID, 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); } for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } }
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}')",
LotNo, SDNCode, Sequence, MUSER, MUSERNAME, WorkPoints); //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
//{
sql += string.Format(@"
insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','4','{3}','{4}', getdate(),'{5}','{9}' from ICSSDN where Type='2' and SDNCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, SDNCode, Sequence, ExtensionID, Convert.ToDecimal( Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY)/ minPackQty* LOTQTY, queryParam["ExpirationDate"].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, cast(a.Sequence as int) as 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 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' 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 (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.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' group by b.TransCode,b.TransSequence ) c on a.InCode=c.TransCode and a.Sequence=c.TransSequence left join dbo.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) { 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 = "QT" + InCode + (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 = ""; 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, WorkPoints); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); 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}' )",
ExtensionID, 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); } for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } }
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
LotNo, InCode, Sequence, MUSER, MUSERNAME, WorkPoints); //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
//{
sql += string.Format(@"
insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','5','{3}','{4}', getdate(),'{5}','{9}' from ICSOtherIn where InCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, InCode, Sequence, ExtensionID, Convert.ToDecimal( Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY)/ minPackQty* LOTQTY, queryParam["ExpirationDate"].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, cast(a.Sequence as int) as 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 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' 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 (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 a.ID, d.POCode,d.Sequence as POSequence,a.DNCode, cast(a.Sequence as int) as 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 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' 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 (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, cast(a.Sequence as int) as 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 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' 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 (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, cast(a.Sequence as int) as 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 ,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 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' 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 (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 a.InvCode,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
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' group by b.TransCode,b.TransSequence ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
WHERE 1 =1 and a.ODNCode='" + ODNCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'"; 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.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
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' group by b.TransCode,b.TransSequence ) c on a.RCVCode=c.TransCode and a.Sequence=c.TransSequence
WHERE 1 =1 and a.RCVCode='" + RCVCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'"; 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.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' group by b.TransCode,b.TransSequence ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence left join dbo.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.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 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' group by b.TransCode,b.TransSequence ) c on a.ReturnCode=c.TransCode and a.Sequence=c.TransSequence
WHERE 1 =1 and a.ReturnCode='" + ReturnCode + "' and a.Sequence='" + Sequence + "'";
sql += " and a.WorkPoint='" + WorkPoint + "'"; 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 = ""; 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, WorkPoints); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); 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}' )",
ExtensionID, 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); }
for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } }
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
LotNo, ReturnCode, Sequence, MUSER, MUSERNAME, WorkPoints); //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
//{
sql += string.Format(@"
insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','6','{3}','{4}', getdate(),'{5}','{9}' from ICSReturn where ReturnCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ReturnCode, Sequence, ExtensionID, Convert.ToDecimal( Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY)/ minPackQty* LOTQTY, queryParam["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 SubmitFormSHDH(string DNCode, string Sequence, string keyValue, string WorkPoint) { var queryParam = keyValue.ToJObject(); string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString()); decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString()); decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString()); decimal LOTQTY = minPackQty; string Pre = "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 = ""; 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, WorkPoints); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); 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}' )",
ExtensionID, 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); } for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } }
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints); 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, WorkPoints, DNCode, Sequence, ExtensionID, Convert.ToDecimal( Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY)/ minPackQty* LOTQTY, queryParam["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 SubmitFormWWSHDH(string ODNCode, string Sequence, string keyValue, string WorkPoint) { var queryParam = keyValue.ToJObject(); string WorkPoints = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); int createPageCount = Convert.ToInt32(queryParam["createPageCount"].ToString()); decimal minPackQty = Convert.ToDecimal(queryParam["minPackQty"].ToString()); decimal thisCreateQty = Convert.ToDecimal(queryParam["thisCreateQty"].ToString()); decimal LOTQTY = minPackQty; string Pre = "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 sqls = string.Empty; string Colspan = ""; 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, WorkPoints); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); 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}' )",
ExtensionID, 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); }
for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } }
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints); 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, WorkPoints, ODNCode, Sequence, ExtensionID, Convert.ToDecimal( Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY)/ minPackQty* LOTQTY, queryParam["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 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 = "";
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}'", Colspan); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); 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}' )",
ExtensionID, 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); } for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } }
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
LotNo, RCVCode, Sequence, MUSER, MUSERNAME, WorkPoints); 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, WorkPoints, RCVCode, Sequence, ExtensionID, Convert.ToDecimal( Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY)/ minPackQty* LOTQTY, queryParam["ExpirationDate"].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, cast(a.Sequence as int) as 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 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' 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 (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 , cast(a.Sequence as int) as 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 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' 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 (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,cast(a.Sequence as int) as 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='12' 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 (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 = ""; 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, WorkPoints); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); 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}' )",
ExtensionID, 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); } for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } }
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
LotNo, DNCode, Sequence, MUSER, MUSERNAME, WorkPoints); //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
//{
sql += string.Format(@"
insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','10','{3}','{4}', getdate(),'{5}','{9}' from ICSDeliveryNotice where DNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, DNCode, Sequence, ExtensionID, Convert.ToDecimal( Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY)/ minPackQty* LOTQTY, queryParam["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 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 + Sequence; string sql = string.Empty; string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName; string PRODUCTDATE = queryParam["PRODUCTDATE"].ToString(); string sqls = string.Empty; string Colspan = ""; 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, WorkPoints); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); 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}' )",
ExtensionID, 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); } for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } }
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
LotNo, ODNCode, Sequence, MUSER, MUSERNAME, WorkPoints); //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
//{
sql += string.Format(@"
insert into ICSInventoryLot (ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','11','{3}','{4}', getdate(),'{5}','{9}' from ICSODeliveryNotice where ODNCode='{6}' and Sequence='{7}' and WorkPoint='{5}'",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ODNCode, Sequence, ExtensionID, Convert.ToDecimal( Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY)/ minPackQty* LOTQTY, queryParam["ExpirationDate"].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.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 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' group by b.TransCode,b.TransSequence ) c on a.DNCode=c.TransCode and a.Sequence=c.TransSequence
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.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 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' group by b.TransCode,b.TransSequence ) c on a.ODNCode=c.TransCode and a.Sequence=c.TransSequence
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.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 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' 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 + "'"; 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 = ""; 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, WorkPoints); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); 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}' )",
ExtensionID, 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); } 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,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','12','{3}','{4}', getdate(),'{5}','{9}' from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal( Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY)/ minPackQty* LOTQTY, queryParam["ExpirationDate"].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,cast(a.Sequence as int) as 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' 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 (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.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 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' 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 + "'"; 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 = ""; 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, WorkPoints); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); 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}' )",
ExtensionID, 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); } 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); 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}','13','{3}','{4}', getdate(),'{5}','{9}' from ICSMOApplyNegDetail where ApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, ApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal( Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY)/ minPackQty* LOTQTY, queryParam["ExpirationDate"].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,cast(a.Sequence as int) as 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 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' 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 (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.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
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' group by b.TransCode,b.TransSequence ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence 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 = ""; 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, WorkPoints); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); 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}' )",
ExtensionID, 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); } for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } }
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints); 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}','14','{3}','{4}', getdate(),'{5}','{9}' from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal( Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY)/ minPackQty* LOTQTY, queryParam["ExpirationDate"].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,cast(a.Sequence as int) as 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 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' 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 (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.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 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' group by b.TransCode,b.TransSequence ) c on a.OApplyNegCode=c.TransCode and a.Sequence=c.TransSequence 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 = ""; 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, WorkPoints); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); 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}' )",
ExtensionID, 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); } for (int i = 0; i < createPageCount; i++) { if (i + 1 == createPageCount) { if (minPackQty * createPageCount > thisCreateQty) { LOTQTY = thisCreateQty - (minPackQty * (createPageCount - 1)); } }
string LotNo = GetSerialCode(WorkPoint, "ICSInventoryLot", "LotNO", Pre, 5); sql += string.Format(@"Insert into ICSInventoryLotDetail(LotNo, TransCode,TransSequence,MUSER,MUSERName,MTIME,WorkPoint)
Values('{0}','{1}','{2}','{3}','{4}',getdate(),'{5}' )",
LotNo, OApplyNegCode, Sequence, MUSER, MUSERNAME, WorkPoints); //if (SqlHelper.ExecuteNonQuery(sqls) > 0)
//{
sql += string.Format(@"insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',InvCode,'{1}','{10}','{2}','{8}','15','{3}','{4}', getdate(),'{5}','{9}' from ICSOApplyNegDetail where OApplyNegCode='{6}' and Sequence='{7}' and WorkPoint='{5}' ",
LotNo, PRODUCTDATE, LOTQTY, MUSER, MUSERNAME, WorkPoints, OApplyNegCode, Sequence, ExtensionID, Convert.ToDecimal( Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY)/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()); sql += "\r\n"; //}
} int count = SqlHelper.CmdExecuteNonQueryLi(sql); return count; }
public DataTable SelectICSExtensionEnable(string BeginTime, string EndTime) { string sql = @"select ColCode from ICSExtensionEnable
where Enable=0 order by cast(EATTRIBUTE1 as int)";
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 from ICSMOPick a left join ICSMO d on a.MODetailID=d.MODetailID 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='16' 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 (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.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 from ICSMOPick a left join ICSMO d on a.MODetailID=d.MODetailID 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='16' group by b.TransCode,b.TransSequence ) c on d.MOCode=c.TransCode and d.Sequence+'-'+a.Sequence=c.TransSequence 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; 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 = "";
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, WorkPoints); object ExtensionID = SqlHelper.ExecuteScalar(sqls); if (ExtensionID == null) { ExtensionID = Guid.NewGuid(); 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}' )",
ExtensionID, 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); } 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, FGGDMOCode, Sequence, MUSER, MUSERNAME, WorkPoints); sql += string.Format(@"insert into ICSInventoryLot
(ID,LotNo,InvCode,ProductDate,ExpirationDate,Quantity,ExtensionID,Type,MUSER,MUSERName,MTIME,WorkPoint,Amount) select newid(),'{0}',a.InvCode,'{1}','{10}','{2}','{8}','16','{3}','{4}', getdate(),'{5}','{9}' 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, ExtensionID, Convert.ToDecimal( Convert.ToDecimal(queryParam["Amount"].ToString())/ minPackQty* LOTQTY)/ minPackQty* LOTQTY, queryParam["ExpirationDate"].ToString()); sql += "\r\n"; } int count = SqlHelper.CmdExecuteNonQueryLi(sql); return count; }
public object GetDecimalDigits() { try { string sql = string.Empty; sql = @"select Figure from ICSConfiguration where Code='Figure001' and Enable='1'"; object Figure = SqlHelper.ExecuteScalar(sql); return Figure; } catch (Exception ex) { throw new Exception(ex.Message.ToString()); } }
public object GetBatchEnable(string InvCode) { string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; string sql = @"select BatchEnable from ICSInventory where InvCode='{0}' and WorkPoint='{1}'"; sql = string.Format(sql, InvCode, WorkPoint); object Enable= SqlHelper.ExecuteScalar(sql); return Enable; }
//工单生成条码 上传功能 倒冲U8
public string CallU8ManufactureReceiveDoc(string Code, string Sequence) { 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; var MTIME = System.DateTime.Now.ToString("s"); string msg = ""; string connstr = SqlHelper.DataCenterConnString; SqlConnection conn = new System.Data.SqlClient.SqlConnection(connstr); conn.Open(); SqlTransaction sqlTran = conn.BeginTransaction(); SqlCommand cmd = new SqlCommand(); cmd.Transaction = sqlTran; cmd.Connection = conn; try { List<ICSManufactureReceiveDocASKDC> asn = new List<ICSManufactureReceiveDocASKDC>(); ICSManufactureReceiveDocASKDC ass = new ICSManufactureReceiveDocASKDC(); #region 根据工单号+行号取出批次数量
string sqlLotBC = @"select distinct f.BatchCode from ICSInventoryLot a
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.ICSBackflushBCLog d on d.TransCode=c.TransCode and d.TransSequence=c.TransSequence and f.BatchCode=d.BatchCode where c.TransCode='{0}' and c.TransSequence='{1}' and a.WorkPoint='{2}' and isnull(d.ID,'')=''";
sqlLotBC = string.Format(sqlLotBC, Code, Sequence, WorkPoint); DataTable dtLotBC = SqlCommandHelper.SQlReturnData(sqlLotBC, cmd); if (dtLotBC.Rows.Count<=0) { throw new Exception("该工单,暂无可上传批次!"); } // DataTable dtLotBC = Repository().FindTableBySql(sqlLotBC.ToString());
var BCNum = dtLotBC.Rows.Count; var LotAllBC = ""; string sqlBKLog = ""; foreach (DataRow dr in dtLotBC.Rows) { LotAllBC += dr["BatchCode"].ToString() + "|"; sqlBKLog += @" Insert into ICSBackflushBCLog(ID, TransCode,TransSequence,BatchCode,MUSER,MUSERName,MTIME,WorkPoint)
Values(newid(),'{0}','{1}','{2}','{3}','{4}','{5}','{6}')";
sqlBKLog = string.Format(sqlBKLog, Code, Sequence, dr["BatchCode"].ToString(), MUSER, MUSERNAME, MTIME, WorkPoint);
} SqlCommandHelper.CmdExecuteNonQuery(sqlBKLog, cmd); LotAllBC = "|" + LotAllBC.TrimEnd('|') + "|"; #endregion
#region 查询传给U8的表头信息
string sqlHead = @"select * from dbo.ICSMO a where a.MOCode='{0}' and a.Sequence='{1}' and a.WorkPoint='{2}'"; sqlHead = string.Format(sqlHead, Code, Sequence, WorkPoint); DataTable dtHead = SqlCommandHelper.SQlReturnData(sqlHead, cmd); // DataTable dtHead = Repository().FindTableBySql(sqlHead.ToString());
#endregion
#region 查询传给U8的表体信息
string sqlSubject = @"select b.Sequence as Seq,b.PickID,b.InvCode,b.WHCode,b.EATTRIBUTE2,b.EATTRIBUTE1,b.Amount ,c.ClassCode
from dbo.ICSMO a left join dbo.ICSMOPick b on a.MODetailID=b.MODetailID and a.WorkPoint=b.WorkPoint and b.EATTRIBUTE1 <>'1' inner join dbo.ICSInventory c on b.InvCode=c.InvCode and b.WorkPoint=c.WorkPoint where a.MOCode='{0}' and a.Sequence='{1}' and a.WorkPoint='{2}'";
sqlSubject = string.Format(sqlSubject, Code, Sequence, WorkPoint); DataTable dtSubject = SqlCommandHelper.SQlReturnData(sqlSubject, cmd); if (dtSubject.Rows.Count <= 0) { throw new Exception("该工单下暂无可上传的子行!"); } // DataTable dtSubject = Repository().FindTableBySql(sqlSubject.ToString());
var Identification = Guid.NewGuid().ToString(); foreach (DataRow item in dtSubject.Rows) { //根据物料汇总条码的批次
var OffspringBc = ""; string SqlBackflush = @"select a.LotNo,a.Quantity,c.BatchCode from dbo.ICSWareHouseLotInfo a
left join dbo.ICSInventoryLot b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint left join dbo.ICSExtension c on b.ExtensionID=c.ID and a.WorkPoint=c.WorkPoint where a.InvCode='{0}' and a.WorkPoint='{1}' and a.WarehouseCode='{2}' and a.Quantity<>0 order by InDate asc";
SqlBackflush = string.Format(SqlBackflush, item["InvCode"].ToString(), WorkPoint, item["WHCode"].ToString()); DataTable DtBackflush = SqlCommandHelper.SQlReturnData(SqlBackflush, cmd);
//DataTable DtBackflush = Repository().FindTableBySql(SqlBackflush.ToString());
var InvAllNum = Convert.ToDecimal(item["EATTRIBUTE2"]) * BCNum;
//判断这个物料是不是10或者20开头 如是需wms库存中先扣除
if (item["InvCode"].ToString().StartsWith("10") || item["InvCode"].ToString().StartsWith("20")) { if (DtBackflush.Rows.Count <= 0) { throw new Exception("料号:" + item["InvCode"].ToString() + "库存数量不足,无法上传!"); } string sqlBackKC = string.Empty;
//在这里做倒冲
// decimal AllThisMakeNum = 0;
foreach (DataRow itemDeatil in DtBackflush.Rows) { if (InvAllNum == 0) { break; } decimal ThisMakeNum = InvAllNum > Convert.ToDecimal(itemDeatil["Quantity"]) ? Convert.ToDecimal(itemDeatil["Quantity"]) : InvAllNum; if (InvAllNum != 0) {
sqlBackKC += @"update ICSWareHouseLotInfo set Quantity=Quantity-'{5}' where LotNo='{3}'
insert into ICSWareHouseLotInfolog (ID,Identification,TransCode,TransSequence,LotNo,InvCode,FromWarehouseCode,FromLocationCode,ToWarehouseCode,ToLocationCode,Quantity,Memo,Lock,TransType,BusinessCode,ERPUpload,MUSER,MUSERName,MTIME,WorkPoint) select newid(),'{0}','{1}','{2}','{3}','{4}',WarehouseCode,LocationCode,'','','{5}','','0','12','30','1','{6}','{7}','{8}','{9}' from ICSWareHouseLotInfo where LotNo='{3}' and WorkPoint='{9}'";
sqlBackKC = string.Format(sqlBackKC, Identification, Code, Sequence, itemDeatil["LotNo"].ToString(), item["InvCode"].ToString(), ThisMakeNum, MUSER, MUSERNAME, MTIME, WorkPoint);
InvAllNum = InvAllNum - ThisMakeNum; //AllThisMakeNum += ThisMakeNum;
//if (InvAllNum- AllThisMakeNum<0)
//{
// throw new Exception("料号:" + item["InvCode"].ToString() + "库存数量不足,无法上传!");
//}
//OffspringBc += item["BatchCode"].ToString() + "|";
} ICSManufactureReceiveDocASKDCS DetailList = new ICSManufactureReceiveDocASKDCS(); DetailList.Seq = item["Seq"].ToString(); DetailList.PickID = item["PickID"].ToString(); DetailList.InvCode = item["InvCode"].ToString(); DetailList.WHCode = item["WHCode"].ToString(); DetailList.Quantity = ThisMakeNum; DetailList.Amount = Convert.ToDecimal(item["Amount"]); DetailList.ProjectCode = ""; DetailList.Brand = ""; DetailList.BatchCode = itemDeatil["BatchCode"].ToString(); DetailList.cFree1 = ""; DetailList.cFree2 = ""; DetailList.cFree3 = ""; DetailList.cFree4 = ""; DetailList.cFree5 = ""; DetailList.cFree6 = ""; DetailList.cFree7 = ""; DetailList.cFree8 = ""; DetailList.cFree9 = ""; DetailList.cFree10 = ""; ass.details.Add(DetailList); } if (InvAllNum > 0) { throw new Exception("料号:" + item["InvCode"].ToString() + "库存数量不足,无法上传!"); } SqlCommandHelper.CmdExecuteNonQuery(sqlBackKC, cmd);
} else { ICSManufactureReceiveDocASKDCS DetailList = new ICSManufactureReceiveDocASKDCS(); DetailList.Seq = item["Seq"].ToString(); DetailList.PickID = item["PickID"].ToString(); DetailList.InvCode = item["InvCode"].ToString(); DetailList.WHCode = item["WHCode"].ToString(); DetailList.Quantity = Convert.ToDecimal(item["EATTRIBUTE2"]) * BCNum; DetailList.Amount = Convert.ToDecimal(item["Amount"]); DetailList.ProjectCode = ""; DetailList.Brand = ""; DetailList.BatchCode = ""; DetailList.cFree1 = ""; DetailList.cFree2 = ""; DetailList.cFree3 = ""; DetailList.cFree4 = ""; DetailList.cFree5 = ""; DetailList.cFree6 = ""; DetailList.cFree7 = ""; DetailList.cFree8 = ""; DetailList.cFree9 = ""; DetailList.cFree10 = ""; ass.details.Add(DetailList); } //OffspringBc = "|" + OffspringBc.TrimEnd('|') + "|";
} #endregion
ass.User = MUSER; ass.MTime = MTIME; ass.WorkPoint = WorkPoint; ass.DepCode = dtHead.Rows[0]["DepCode"].ToString(); ass.BatchCode = LotAllBC; ass.MOCode = Code; asn.Add(ass);
string input = JsonConvert.SerializeObject(asn); string APIURL = ConfigurationManager.ConnectionStrings["ERPAPIURL"].ConnectionString + "ManufactureReceiveDocASKDC/Create"; string result = HttpPost(APIURL, input); 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") { throw new Exception(MessAge); }
cmd.Transaction.Commit(); } catch (Exception ex) {
cmd.Transaction.Rollback(); msg = ex.Message; } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } conn.Dispose(); } return msg; }
//接口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 string DeleteLoadingItemLot(string keyValue) { string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; string msg = string.Empty; string sqls= string.Empty; keyValue = keyValue.TrimEnd(','); string[] pairs = keyValue.Split(','); foreach (string pair in pairs) { string sql = string.Format(@"SELECT * FROM dbo.ICSInspection
WHERE LotNo IN (SELECT LotNO FROM dbo.ICSInventoryLot WHERE LotNo IN ({0})) and WorkPoint in ('{1}')", pair.ToString(), WorkPoint);
DataTable dtASN = SqlHelper.GetDataTableBySql(sql); if (dtASN != null && dtASN.Rows.Count > 0) { msg = "所选条码" + pair.ToString() + "已生成检验单,无法删除!"; } sql = string.Format(@"SELECT * FROM dbo.ICSWareHouseLotInfo WHERE LotNO IN (SELECT LotNO FROM dbo.ICSInventoryLot WHERE LotNo = {0}) and WorkPoint in ('{1}')", pair.ToString(), WorkPoint); DataTable dtCarton = SqlHelper.GetDataTableBySql(sql); if (dtCarton != null && dtCarton.Rows.Count > 0) { msg += "所选条码" + pair.ToString() + "已入库,无法删除!"; }
sql = string.Format(@"select d.BatchCode from ICSInventoryLot a inner join dbo.ICSInventoryLotDetail b on a.LotNo=b.LotNo and a.WorkPoint=b.WorkPoint
inner join ICSExtension c on a.ExtensionID=c.ID and a.WorkPoint=c.WorkPoint left join ICSBackflushBCLog d on b.TransCode=d.TransCode and b.TransSequence=d.TransSequence and c.BatchCode=d.BatchCode and a.WorkPoint=d.WorkPoint where a.LotNo={0}", pair.ToString(), WorkPoint);
DataTable dtLoad = SqlHelper.GetDataTableBySql(sql); if (dtLoad.Rows[0]["BatchCode"].ToString() != "" ) { msg += "所选条码"+ pair.ToString() + "已上传,无法删除!"; }
if (string.IsNullOrEmpty(msg)) { sqls += @"
DELETE FROM ICSInventoryLotDetail WHERE LotNO IN (select LotNO from ICSInventoryLot where LotNo ={0} ) and WorkPoint ='{1}' DELETE FROM dbo.ICSInventoryLot WHERE LotNo ={0} and WorkPoint ='{1}'";
//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);
sqls = string.Format(sqls,pair.ToString(), WorkPoint); } } if (sqls!="") { SqlHelper.CmdExecuteNonQueryLi(sqls); }
return msg;
}
} }
|