You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
581 lines
25 KiB
581 lines
25 KiB
using Newtonsoft.Json.Linq;
|
|
using Newtonsoft.Json;
|
|
using NFine.Code;
|
|
using NFine.Data.Extensions;
|
|
using NFine.Domain._03_Entity.SRM;
|
|
using NFine.Repository;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Data.Common;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Threading;
|
|
using System.Reflection.Emit;
|
|
|
|
namespace NFine.Application.DHAY
|
|
{
|
|
public class ICSAccessoriesMOIApplyApp : RepositoryFactory<ICSVendor>
|
|
{
|
|
public static DataTable Invmes = new DataTable();
|
|
|
|
|
|
|
|
|
|
|
|
#region 删除辅料材料出库单
|
|
public string DeleteICSMOApply(string keyValue)
|
|
{
|
|
//站点信息
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
|
|
sql += string.Format(@"DELETE FROM dbo.ICSMOApply WHERE ApplyCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
#endregion
|
|
|
|
#region 保存发料信息
|
|
public string SaveICSMOApply(string ICSASN)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
string UserName = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string msg = "";
|
|
List<JsonData> parsedData = JsonConvert.DeserializeObject<List<JsonData>>(ICSASN);
|
|
string sql = "";
|
|
string Colspan = "";
|
|
string str1 = "";
|
|
List<string> ExtensionIDList = new List<string>();
|
|
// 获取解析后的数据
|
|
JsonData data = parsedData[0];
|
|
foreach (var detail in data.Detail)
|
|
{
|
|
Colspan ="~" + detail.Batch + "~~~~~~~~~~~~";
|
|
string sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
|
|
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
|
|
bool flag = true;
|
|
foreach (var item in ExtensionIDList)
|
|
{
|
|
if (item == Colspan + WorkPoint)
|
|
{
|
|
flag = false;
|
|
}
|
|
}
|
|
if (ExtensionID == null && flag == true)
|
|
{
|
|
str1 = Guid.NewGuid().ToString();
|
|
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
|
|
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
|
|
str1, Colspan, "", detail.Batch, "", "", "", "", "", "", "", "", "", "", "", "",
|
|
data.User, UserName, WorkPoint);
|
|
}
|
|
else if (ExtensionID != null)
|
|
{
|
|
str1 = ExtensionID.ToString();
|
|
}
|
|
ExtensionIDList.Add(Colspan + WorkPoint);
|
|
|
|
sql += "INSERT INTO ICSMOApply(ID,ApplyCode,WHCode,Sequence,InvCode,Quantity,CreatePerson,CreateDateTime,WorkPoint,Status,ApplyID,ApplyDetailID,ExtensionID,MUSER,MUSERName,MTIME,EATTRIBUTE,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE10,SourceCode,Type)" +
|
|
" select '{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',newID(),newID(),'{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','1'";
|
|
sql = string.Format(sql, detail.ID, data.Code, detail.WHCode, detail.Sequence, detail.InvCode, detail.Quantity, data.User, data.MTIME, WorkPoint, '1', str1, data.User, UserName, data.MTIME, data.Dept, data.CodeType, data.ApplyNegCode, data.Custmer, data.Remarks, detail.DetailReamrk, data.SYproject, "杂发", detail.SourceCode);
|
|
}
|
|
try
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg=ex.Message;
|
|
}
|
|
return msg;
|
|
}
|
|
#region 辅料材料出库单主表信息查询
|
|
public DataTable GetICSMOApply(ref Pagination jqgridparam, string queryJson)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
var queryParam = queryJson.ToJObject();
|
|
string sql = @" SELECT DISTINCT
|
|
a.ApplyCode
|
|
,a.Status
|
|
,a.CreatePerson
|
|
,a.CreateDateTime
|
|
,a.MUSER
|
|
,a.MUSERName
|
|
,a.SourceCode
|
|
,a.EATTRIBUTE
|
|
,a.EATTRIBUTE2
|
|
,a.EATTRIBUTE3
|
|
,a.EATTRIBUTE4
|
|
,a.EATTRIBUTE5
|
|
,a.EATTRIBUTE7
|
|
,a.EATTRIBUTE8
|
|
,a.EATTRIBUTE9
|
|
,a.EATTRIBUTE10
|
|
from dbo.ICSMOApply a
|
|
left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint where 1=1";
|
|
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
sql += " and a.ApplyCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["CreatedBy"].ToString()))
|
|
{
|
|
sql += " and a.CreatePerson like '%" + queryParam["CreatedBy"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
|
|
{
|
|
sql += " and convert(nvarchar(20),a.CreateDateTime,23) >= '" + queryParam["TimeFrom"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TimeArrive"].ToString()))
|
|
{
|
|
sql += " and convert(nvarchar(20),a.CreateDateTime,23) <= '" + queryParam["TimeArrive"].ToString() + "' ";
|
|
}
|
|
}
|
|
sql = string.Format(sql);
|
|
DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
#endregion
|
|
|
|
#region 辅料材料出库单主表信息查询
|
|
public DataTable GetICSMOApplyByApplyCode(string ApplyCode)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @" SELECT DISTINCT
|
|
a.ApplyCode
|
|
,a.Status
|
|
,a.CreatePerson
|
|
,a.CreateDateTime
|
|
,a.MUSER
|
|
,a.MUSERName
|
|
,a.SourceCode
|
|
,a.EATTRIBUTE
|
|
,a.EATTRIBUTE2
|
|
,a.EATTRIBUTE3
|
|
,a.EATTRIBUTE4
|
|
,a.EATTRIBUTE5
|
|
,a.EATTRIBUTE7
|
|
,a.EATTRIBUTE8
|
|
,a.EATTRIBUTE9
|
|
,a.EATTRIBUTE10
|
|
from dbo.ICSMOApply a
|
|
left join ICSWarehouse b on a.WHCode=b.WarehouseCode and a.WorkPoint=b.WorkPoint
|
|
WHERE a.ApplyCode='{0}'";
|
|
sql = string.Format(sql, ApplyCode);
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
#endregion
|
|
#region 主页面子表信息查询
|
|
public DataTable GetICSMOApplyDetail(string ApplyCode, string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @" select a.ID
|
|
,a.ApplyCode
|
|
,a.Sequence
|
|
,a.InvCode
|
|
,a.Quantity
|
|
,a.Amount
|
|
,a.ExtensionID
|
|
,a.MUSER
|
|
,a.MUSERName
|
|
,a.MTIME
|
|
,a.SourceCode
|
|
,IssueQuantity
|
|
,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.EATTRIBUTE
|
|
,a.EATTRIBUTE2
|
|
,a.EATTRIBUTE3
|
|
,a.EATTRIBUTE4
|
|
,a.EATTRIBUTE5
|
|
,a.EATTRIBUTE6
|
|
,a.EATTRIBUTE7
|
|
,a.EATTRIBUTE8
|
|
,a.EATTRIBUTE9
|
|
,a.EATTRIBUTE10
|
|
from ICSMOApply a
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
WHERE a.ApplyCode='" + ApplyCode + "' ";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["POCode"].ToString()))
|
|
{
|
|
sql += " and a.ApplyCode like '%" + queryParam["POCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sql += " and a.InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["CreatedBy"].ToString()))
|
|
{
|
|
sql += " and a.CreatePerson like '%" + queryParam["CreatedBy"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
|
|
{
|
|
sql += " and convert(nvarchar(20),a.CreateDateTime,23) >= '" + queryParam["TimeFrom"].ToString() + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["TimeArrive"].ToString()))
|
|
{
|
|
sql += " and convert(nvarchar(20),a.CreateDateTime,23) <= '" + queryParam["TimeArrive"].ToString() + "' ";
|
|
}
|
|
}
|
|
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
#endregion
|
|
|
|
public string DeleteICSMOApplyByCode(string keyValue)
|
|
{
|
|
//站点信息
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
|
|
sql += string.Format(@"IF EXISTS( select ID from ICSMOApply where ApplyCode IN ({0}) and WorkPoint ='{1}' AND IssueQuantity>0)
|
|
BEGIN
|
|
RAISERROR('该单据已发料,不能删除!',16,1);
|
|
RETURN
|
|
END
|
|
DELETE FROM dbo.ICSMOApply WHERE ApplyCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
|
|
try
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
}
|
|
return msg;
|
|
}
|
|
/// <summary>
|
|
/// 审核单据
|
|
/// </summary>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
public string ApproveICSMOApplyByCode(string keyValue)
|
|
{
|
|
//站点信息
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
|
|
sql += string.Format(@"IF EXISTS( select ID from ICSMOApply where ApplyCode IN ({0}) and WorkPoint ='{1}' AND status!='1')
|
|
BEGIN
|
|
RAISERROR('该单据的状态不是开立状态,不能审核!',16,1);
|
|
RETURN
|
|
END
|
|
UPDATE dbo.ICSMOApply SET Status='2' WHERE ApplyCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
|
|
try
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg=ex.Message;
|
|
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 弃审单据
|
|
/// </summary>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
public string AbandonICSMOApplyByCode(string keyValue)
|
|
{
|
|
//站点信息
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
|
|
sql += string.Format(@"IF EXISTS( select ID from ICSMOApply where ApplyCode IN ({0}) and WorkPoint ='{1}' AND status!='2')
|
|
BEGIN
|
|
RAISERROR('该单据的状态不是审核状态,不能弃审!',16,1);
|
|
RETURN
|
|
END
|
|
IF EXISTS( select ID from ICSMOApply where ApplyCode IN ({0}) and WorkPoint ='{1}' AND IssueQuantity>0)
|
|
BEGIN
|
|
RAISERROR('该单据已发料,不能删除!',16,1);
|
|
RETURN
|
|
END
|
|
UPDATE dbo.ICSMOApply SET Status='1' WHERE ApplyCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
|
|
try
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
|
|
}
|
|
return msg;
|
|
}
|
|
/// <summary>
|
|
/// 关闭单据
|
|
/// </summary>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
public string CloseICSMOApplyByCode(string keyValue)
|
|
{
|
|
//站点信息
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
|
|
sql += string.Format(@"IF EXISTS( select ID from ICSMOApply where ApplyCode IN ({0}) and WorkPoint ='{1}' AND IssueQuantity>0)
|
|
BEGIN
|
|
RAISERROR('该单据已发料,不能关闭!',16,1);
|
|
RETURN
|
|
END
|
|
UPDATE dbo.ICSMOApply SET Status='3' WHERE ApplyCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
|
|
try
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg=ex.Message;
|
|
}
|
|
return msg;
|
|
}
|
|
public string GetBidCode(string WorkPoint)
|
|
{
|
|
WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string BidCide = string.Empty;
|
|
if (!string.IsNullOrEmpty(WorkPoint))
|
|
{
|
|
string DateString = DateTime.Now.ToString("yyyyMMdd");
|
|
|
|
string Pre = "CLCK" + DateString;
|
|
BidCide = GetSerialCode(WorkPoint, "ICSMOApply", "ApplyCode", Pre, 4);
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(BidCide))
|
|
{
|
|
string sqlISHave = @"SELECT ApplyCode FROM ICSMOApply a
|
|
WHERE a.ApplyCode = '{0}'";
|
|
sqlISHave = string.Format(sqlISHave, BidCide);
|
|
DataTable dtIsHave = SqlHelper.GetDataTableBySql(sqlISHave);
|
|
if (dtIsHave.Rows.Count > 0)
|
|
{
|
|
throw new Exception("单号已存在!");
|
|
}
|
|
}
|
|
return BidCide;
|
|
}
|
|
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 SqlHelper.ExecuteScalar(sql).ToString();
|
|
}
|
|
public string UpdateICSMOApply(string ICSASN)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
string UserName = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string msg = "";
|
|
List<JsonData> parsedData = JsonConvert.DeserializeObject<List<JsonData>>(ICSASN);
|
|
string sql = "";
|
|
string Colspan = "";
|
|
string str1 = "";
|
|
List<string> ExtensionIDList = new List<string>();
|
|
// 获取解析后的数据
|
|
JsonData data = parsedData[0];
|
|
|
|
foreach (var detail in data.Detail)
|
|
{
|
|
Colspan = "~" + detail.Batch + "~~~~~~~~~~~~";
|
|
string sqls = string.Format(@"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'", Colspan, WorkPoint);
|
|
object ExtensionID = SqlHelper.ExecuteScalar(sqls);
|
|
bool flag = true;
|
|
foreach (var item in ExtensionIDList)
|
|
{
|
|
if (item == Colspan + WorkPoint)
|
|
{
|
|
flag = false;
|
|
}
|
|
}
|
|
if (ExtensionID == null && flag == true)
|
|
{
|
|
str1 = Guid.NewGuid().ToString();
|
|
sql += string.Format(@"Insert into ICSExtension(ID, Colspan, ProjectCode, BatchCode, Version, Brand, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10, MTIME, MUSER, MUSERName, WorkPoint)
|
|
Values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}',getdate(),'{16}','{17}','{18}' )",
|
|
str1, Colspan, "", detail.Batch, "", "", "", "", "", "", "", "", "", "", "", "",
|
|
data.User, UserName, WorkPoint);
|
|
}
|
|
else if (ExtensionID != null)
|
|
{
|
|
str1 = ExtensionID.ToString();
|
|
}
|
|
ExtensionIDList.Add(Colspan + WorkPoint);
|
|
|
|
sql += @" IF NOT EXISTS(SELECT * FROM dbo.ICSMOApply WHERE ID='{0}')
|
|
BEGIN
|
|
INSERT INTO ICSMOApply(ID,ApplyCode,WHCode,Sequence,InvCode,Quantity,CreatePerson,CreateDateTime,WorkPoint,Status,ApplyID,ApplyDetailID,ExtensionID,MUSER,MUSERName,MTIME,EATTRIBUTE,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE10,SourceCode,Type)
|
|
select '{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',newID(),newID(),'{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','1'
|
|
END
|
|
ELSE
|
|
BEGIN
|
|
UPDATE dbo.ICSMOApply
|
|
SET WHCode='{2}',InvCode='{4}',Quantity='{5}',CreatePerson='{6}',
|
|
CreateDateTime='{7}' ,MTIME='{13}',EATTRIBUTE='{14}',EATTRIBUTE2='{15}',EATTRIBUTE3='{16}',EATTRIBUTE4='{17}',EATTRIBUTE5='{18}',EATTRIBUTE6='{19}',EATTRIBUTE7='{20}',SourceCode='{22}'
|
|
WHERE ID='{0}'
|
|
END";
|
|
|
|
sql = string.Format(sql, detail.ID, data.Code, detail.WHCode, detail.Sequence, detail.InvCode, detail.Quantity, data.User, data.MTIME, WorkPoint, '1', str1, data.User, UserName, data.MTIME, data.Dept, data.CodeType, data.ApplyNegCode, data.Custmer, data.Remarks, detail.DetailReamrk, data.SYproject, "杂发", detail.SourceCode);
|
|
}
|
|
try
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
}
|
|
return msg;
|
|
}
|
|
public DataTable GetICSReturnTemporary(string rfqno)
|
|
{
|
|
string sql = @"SELECT
|
|
a.ID,
|
|
a.ApplyCode,
|
|
a.InvCode,
|
|
b.InvName,
|
|
b.InvStd,
|
|
a.Quantity,
|
|
a.SourceCode,
|
|
a.WHCode,
|
|
a.WHCode as WHCodeHHH,
|
|
a.EATTRIBUTE6,
|
|
a.SourceCode,
|
|
a.Quantity
|
|
,f.BatchCode as Batch
|
|
,c.WarehouseName as WHCodeName
|
|
FROM ICSMOApply a
|
|
LEFT JOIN ICSInventory b ON a.InvCode = b.InvCode
|
|
left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint
|
|
LEFT JOIN dbo.ICSWarehouse c ON a.WHCode=c.WarehouseCode AND a.WorkPoint=c.WorkPoint
|
|
where a.ApplyCode='" + rfqno + "'";
|
|
DataTable table = Repository().FindDataSetBySql(sql).Tables[0];
|
|
DataTable dtCloned = table.Clone();
|
|
foreach (DataColumn col in dtCloned.Columns)
|
|
{
|
|
col.DataType = typeof(string);
|
|
}
|
|
foreach (DataRow row in table.Rows)
|
|
{
|
|
DataRow newrow = dtCloned.NewRow();
|
|
foreach (DataColumn column in dtCloned.Columns)
|
|
{
|
|
newrow[column.ColumnName] = row[column.ColumnName].ToString();
|
|
|
|
}
|
|
dtCloned.Rows.Add(newrow);
|
|
}
|
|
if (Invmes.Rows.Count > 0)
|
|
{
|
|
dtCloned.Merge(Invmes, false);
|
|
}
|
|
return dtCloned;
|
|
}
|
|
// 定义一个类来表示 JSON 数据的结构
|
|
public class JsonData
|
|
{
|
|
public string Dept { get; set; }
|
|
public string CodeType { get; set; }
|
|
public string ApplyNegCode { get; set; }
|
|
public string Custmer { get; set; }
|
|
public string Remarks { get; set; }
|
|
public string Code { get; set; }
|
|
public string MTIME { get; set; }
|
|
public string User { get; set; }
|
|
public string SYproject { get; set; }
|
|
public List<JsonDetail> Detail { get; set; }
|
|
}
|
|
|
|
public class JsonDetail
|
|
{
|
|
public string ID;
|
|
public int Sequence { get; set; }
|
|
public string InvCode { get; set; }
|
|
public decimal Quantity { get; set; }
|
|
public string WHCode { get; set; }
|
|
/// <summary>
|
|
/// 工单号
|
|
/// </summary>
|
|
public string SourceCode { get; set; }
|
|
public string DetailReamrk { get; set; }
|
|
public string Batch { get; set; }
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|