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.
4850 lines
204 KiB
4850 lines
204 KiB
using NFine.Data.Extensions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using NFine.Code;
|
|
using NFine.Repository;
|
|
using System.Data.Common;
|
|
using NFine.Domain._03_Entity.SRM;
|
|
using ICS.Application.Entity;
|
|
using Newtonsoft.Json;
|
|
using System.Configuration;
|
|
using System.Data.SqlClient;
|
|
using ICS.Data;
|
|
using Newtonsoft.Json.Linq;
|
|
using NFine.Domain._03_Entity.WMS;
|
|
|
|
namespace NFine.Application.WMS
|
|
{
|
|
public class BasicSettingsApp : RepositoryFactory<ICSVendor>
|
|
{
|
|
/// <summary>
|
|
/// 删除库位
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteStack(string keyValue)
|
|
{
|
|
//站点信息
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
|
|
//keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
foreach (var item in res)
|
|
{
|
|
JObject jo = (JObject)item;
|
|
sql = string.Format(@"
|
|
IF EXISTS(SELECT * FROM dbo.ICSWareHouseLotInfo a
|
|
LEFT JOIN dbo.ICSLocation b ON a.LocationCode=b.LocationCode and a.WorkPoint=b.WorkPoint
|
|
where b.ID = '{0}' and a.Quantity>0)
|
|
BEGIN
|
|
RAISERROR('选中库位{2}在库存中已经有库存,请先确认!',16,1);
|
|
RETURN
|
|
END
|
|
DELETE FROM dbo.ICSLocation WHERE ID = '{0}' and WorkPoint ='{1}'", jo["ID"].ToString(), WorkPoint,jo["LocationCode"].ToString());
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
//throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除周转箱
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteBoxes(string keyValue)
|
|
{
|
|
//站点信息
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
|
|
//keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
foreach (var item in res)
|
|
{
|
|
JObject jo = (JObject)item;
|
|
sql = $@"
|
|
IF EXISTS(SELECT * FROM dbo.ICSWorkingCapitalBoxAccount a
|
|
where a.BoxNumber='{jo["BoxNumber"]}' )
|
|
BEGIN
|
|
RAISERROR('选中库周转箱已经维护台账信息,请先确认!', 16, 1);
|
|
RETURN
|
|
END
|
|
DELETE FROM dbo.ICSWorkingCapitalBox WHERE ID = '{jo["ID"]}' ";
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
//throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除模具档案
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteMould(string keyValue)
|
|
{
|
|
//站点信息
|
|
string msg = "";
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
|
|
//keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
foreach (var item in res)
|
|
{
|
|
JObject jo = (JObject)item;
|
|
sql = $@"
|
|
IF EXISTS(SELECT Id FROM dbo.ICSMouldAccount a
|
|
where a.MouldNumber='{jo["MouldNumber"]}')
|
|
BEGIN
|
|
RAISERROR('选中模具已经维护台账信息,请先确认!', 16, 1);
|
|
RETURN
|
|
END
|
|
DELETE FROM dbo.ICSMould WHERE ID = '{jo["ID"]}' ";
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
//throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
|
|
|
|
return msg;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 删除模具台账
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteMouldAccount(string keyValue)
|
|
{
|
|
//站点信息
|
|
string msg = "";
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(keyValue);
|
|
//keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
foreach (var item in res)
|
|
{
|
|
JObject jo = (JObject)item;
|
|
sql = $@"
|
|
IF EXISTS(SELECT Id FROM dbo.ICSMouldLog a
|
|
where a.MouldCode='{jo["MouldCode"]}')
|
|
BEGIN
|
|
RAISERROR('选中模具已经存在使用记录,请先确认!', 16, 1);
|
|
RETURN
|
|
END
|
|
DELETE FROM dbo.ICSMouldAccount WHERE ID = '{jo["ID"]}' ";
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
//throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
|
|
|
|
return msg;
|
|
}
|
|
/// <summary>
|
|
/// 删除不良原因
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteBadCode(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.ICSBadCode WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
/// <summary>
|
|
/// 获取库房信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetWarehouse()
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string sql = @"
|
|
select '' as WarehouseCode,'' as WarehouseName
|
|
union all
|
|
SELECT [WarehouseCode],[WarehouseName] FROM [ICSWarehouse] WITH (NOLOCK) WHERE 1=1 ";
|
|
//string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
|
|
//if (role != "admin")
|
|
//{
|
|
// sql += " and b.WorkPoint='" + WorkPoint + "'";
|
|
//}
|
|
sql += " and WorkPoint='" + WorkPoint + "'";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取周转箱类型
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetType(string tableName)
|
|
{
|
|
string sql =$@"
|
|
select '' as Type,'' as TypeName
|
|
union all
|
|
SELECT Code AS Type,Name as TypeName FROM [ICSType] WITH (NOLOCK) WHERE TableCode='{tableName}' AND ColumnCode='Type' ";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
/// <summary>
|
|
/// 获取周转箱编码信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetBoxNumber()
|
|
{
|
|
string sql = @"select '' as BoxNumber
|
|
union all
|
|
SELECT BoxNumber FROM [ICSWorkingCapitalBox] ";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取模具编码信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetMouldNumber()
|
|
{
|
|
string sql = @"select '' as MouldNumber
|
|
union all
|
|
SELECT MouldNumber FROM [ICSMould] ";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取模具代码信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetMouldCode()
|
|
{
|
|
string sql = @"select '' as MouldCode
|
|
union all
|
|
SELECT MouldCode FROM [ICSMouldAccount] ";
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增库位
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string InsertStack(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string StackSql = @"select * from ICSWarehouse where WarehouseCode='{0}' and WorkPoint='{1}'";
|
|
StackSql = string.Format(StackSql, queryParam["Warehouse"].ToString(), WorkPoint);
|
|
DataTable dt = SqlHelper.GetDataTableBySql(StackSql);
|
|
string sql = string.Empty;
|
|
sql = @"IF ((SELECT 1 FROM ICSLocation WHERE LocationCode='{0}' AND LocationName='{1}' AND WHID='{2}' AND WorkPoint='{5}' ) IS NULL)
|
|
BEGIN
|
|
INSERT INTO dbo.ICSLocation
|
|
( ID ,LocationCode ,LocationName ,WHID ,MUSER ,
|
|
MUSERName ,MTIME ,WorkPoint ,Region,Row,GoodsShelf ,Tier,Grid) Values(NEWID(),'{0}','{1}','{2}','{3}','{4}',GETDATE(),'{5}','{6}','{7}','{8}','{9}','{10}')
|
|
END
|
|
ELSE
|
|
BEGIN
|
|
RAISERROR('库位已存在',16,1);
|
|
END ";
|
|
sql = string.Format(sql, queryParam["StackCode"].ToString(), queryParam["StackName"].ToString(), dt.Rows[0]["ID"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["Qu"].ToString(), queryParam["Pai"].ToString(), queryParam["Jia"].ToString(), queryParam["Ceng"].ToString(), queryParam["Ge"].ToString());
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
return msg;
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 周转箱信息
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string InsertBoxes(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
sql = $@"IF ((SELECT 1 FROM ICSWorkingCapitalBox WHERE BoxNumber='{queryParam["BoxNumber"]}') IS NULL)
|
|
BEGIN
|
|
INSERT INTO [dbo].[ICSWorkingCapitalBox] ([ID], [BoxNumber], [BoxName], [Type], [Version], [Specification], [Describe], [FirstCleanCycle], [SecondCleanCycle], [ThirdCleanCycle], [MTIME], [MUser], [MUSERName])
|
|
VALUES (NEWID(), '{queryParam["BoxNumber"]}', '{queryParam["BoxName"]}', '{queryParam["Type"]}', '{queryParam["Version"]}', '{queryParam["Specification"]}', '{queryParam["Describe"]}', {queryParam["FirstCleanCycle"]}, {queryParam["SecondCleanCycle"]}, {queryParam["ThirdCleanCycle"]}, GETDATE(), '{MUSER}', '{MUSERNAME}');
|
|
|
|
END
|
|
ELSE
|
|
BEGIN
|
|
RAISERROR('周转箱编码已存在,操作失败',16,1);
|
|
END ";
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
return msg;
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增模具信息
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string InsertMould(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
sql = $@"IF ((SELECT 1 FROM ICSMould WHERE MouldNumber='{queryParam["MouldNumber"]}') IS NULL)
|
|
BEGIN
|
|
INSERT INTO [dbo].[ICSMould] ([ID], [MouldNumber], [MouldName], [Type], [Specification], [Unit],[EATTRIBUTE1], [MTIME], [MUser], [MUSERName])
|
|
VALUES (NEWID(), '{queryParam["MouldNumber"]}', '{queryParam["MouldName"]}', '{queryParam["Type"]}', '{queryParam["Specification"]}', '{queryParam["Unit"]}', '{queryParam["Phone"]}',GETDATE(), '{MUSER}', '{MUSERNAME}');
|
|
|
|
END
|
|
ELSE
|
|
BEGIN
|
|
RAISERROR('模具编码已存在,操作失败',16,1);
|
|
END ";
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
return msg;
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
/// <summary>
|
|
/// 新增不良代码
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string InsertBadCode(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
sql = @"INSERT INTO dbo.ICSBadCode
|
|
( ID ,BadCode ,BadDesc ,MUSER ,
|
|
MUSERName ,MTIME ,WorkPoint,BCGroupID ) Values(NEWID(),'{0}','{1}','{2}','{3}',GETDATE(),'{4}','NULL')";
|
|
sql = string.Format(sql, queryParam["BadCode"].ToString(), queryParam["BadDesc"].ToString(), MUSER, MUSERNAME, WorkPoint);
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
/// <summary>
|
|
/// 修改不良代码
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string UpdateBadCode(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
sql = @"UPDATE dbo.ICSBadCode set BadCode='{0}',BadDesc='{1}',MUSER='{2}',MUSERName='{3}',MTIME=GetDate(),WorkPoint='{4}' WHERE ID='{5}'";
|
|
sql = string.Format(sql, queryParam["BadCode"].ToString(), queryParam["BadDesc"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
/// <summary>
|
|
/// 修改库位
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string UpdateStack(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string StackSql = @"select * from ICSWarehouse where WarehouseCode='{0}'";
|
|
StackSql = string.Format(StackSql, queryParam["Warehouse"].ToString());
|
|
DataTable dt = SqlHelper.GetDataTableBySql(StackSql);
|
|
string sql = string.Empty;
|
|
sql = @"UPDATE dbo.ICSLocation set LocationCode='{0}',LocationName='{1}',WHID='{2}',MUSER='{3}',MUSERName='{4}',MTIME=GETDATE(),WorkPoint='{5}',Region='{7}',Row='{8}',GoodsShelf ='{9}',Tier='{10}',Grid='{11}' WHERE ID='{6}'";
|
|
sql = string.Format(sql, queryParam["StackCode"].ToString(), queryParam["StackName"].ToString(), dt.Rows[0]["ID"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString(), queryParam["Qu"].ToString(), queryParam["Pai"].ToString(), queryParam["Jia"].ToString(), queryParam["Ceng"].ToString(), queryParam["Ge"].ToString());
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改周转箱信息
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string UpdateBoxes(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string msg = "";
|
|
|
|
string sql = string.Empty;
|
|
sql = $@"UPDATE [dbo].[ICSWorkingCapitalBox] SET [BoxName] = '{queryParam["BoxName"]}', [Type] = '{queryParam["Type"]}', [Version] = '{queryParam["Version"]}', [Specification] = '{queryParam["Specification"]}', [Describe] = '{queryParam["Describe"]}', [FirstCleanCycle] = {queryParam["FirstCleanCycle"]}, [SecondCleanCycle] = {queryParam["SecondCleanCycle"]}, [ThirdCleanCycle] = {queryParam["ThirdCleanCycle"]}, [MTIME] = GETDATE(), [MUser] = '{MUSER}', [MUSERName] = '{MUSERNAME}' WHERE ID='{queryParam["ID"]}';";
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改模具信息
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string UpdateMould(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string msg = "";
|
|
|
|
string sql = string.Empty;
|
|
sql = $@"UPDATE [dbo].[ICSMould] SET [MouldName] = '{queryParam["MouldName"]}', [Type] = '{queryParam["Type"]}', [Unit] = '{queryParam["Unit"]}', [Specification] = '{queryParam["Specification"]}', [EATTRIBUTE1] = '{queryParam["Phone"]}', [MTIME] = GETDATE(), [MUser] = '{MUSER}', [MUSERName] = '{MUSERNAME}' WHERE ID='{queryParam["ID"]}';";
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 修改模具状态信息
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string UpdateMouldStatus(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string msg = "";
|
|
|
|
string sql = string.Empty;
|
|
sql = $@"UPDATE [dbo].[ICSMouldAccount] SET [MajorStates] = '禁用', [SubStates] = '{queryParam["Status"]}' WHERE ID='{queryParam["ID"]}';
|
|
INSERT INTO [dbo].[ICSMouldLog] ([ID], [MouldCode], [MouldNumber], [Status], [DailyUses], [StartDate], [MTIME], [MUser], [MUSERName], [UsageCount]) SELECT NEWID(),MouldCode,MouldNumber,'{queryParam["Status"]}',0,GETDATE(),GETDATE(),'{MUSER}','{MUSERNAME}',0 FROM ICSMouldAccount WHERE ID='{queryParam["ID"]}';";
|
|
try
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
/// <summary>
|
|
/// 新增类型
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string InsertICSType(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
sql = @"INSERT INTO dbo.ICSType
|
|
( ID ,TableCode ,ColumnCode ,Code,Name, Enable,MTIME,MUSER ,MUSERName ,WorkPoint )
|
|
Values(NEWID(),'{0}','{1}','{2}','{3}','{4}',GETDATE(),'{5}','{6}','{7}')
|
|
";
|
|
sql = string.Format(sql, queryParam["TableCode"].ToString(), queryParam["ColumnCode"].ToString(), queryParam["Code"].ToString(), queryParam["Name"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint);
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改类型
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string UpdateICSType(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
|
|
string sql = string.Empty;
|
|
sql = @"UPDATE dbo.ICSType set TableCode='{0}',ColumnCode='{1}',Code='{2}',Name='{3}',Enable='{4}',MTIME=GETDATE(),MUSER='{5}',MUSERName='{6}',WorkPoint='{7}' WHERE ID='{8}'";
|
|
sql = string.Format(sql, queryParam["TableCode"].ToString(), queryParam["ColumnCode"].ToString(), queryParam["Code"].ToString(), queryParam["Name"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
/// <summary>
|
|
/// 删除类型
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteICSType(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.ICSType WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 修改参数配置
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string UpdateICSConfiguration(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
|
|
string sql = string.Empty;
|
|
sql = @"UPDATE dbo.ICSConfiguration set Code='{0}',Name='{1}',Enable='{2}',Figure='{3}',MTIME=GETDATE(),MUSER='{4}',MUSERName='{5}',WorkPoint='{6}' WHERE ID='{7}'";
|
|
sql = string.Format(sql, queryParam["Code"].ToString(), queryParam["Name"].ToString(), queryParam["Enable"].ToString(), queryParam["Figure"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增参数配置
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string InsertICSConfiguration(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
sql = @"INSERT INTO dbo.ICSConfiguration
|
|
( ID ,Code ,Name ,Enable,Figure,MTIME,MUSER ,MUSERName ,WorkPoint )
|
|
Values(NEWID(),'{0}','{1}','{2}','{3}',GETDATE(),'{4}','{5}','{6}')
|
|
";
|
|
sql = string.Format(sql, queryParam["Code"].ToString(), queryParam["Name"].ToString(), queryParam["Enable"].ToString(), queryParam["Figure"].ToString(), MUSER, MUSERNAME, WorkPoint);
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除参数配置
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteICSConfiguration(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.ICSConfiguration WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 修改启用配置
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string UpdateICSExtensionEnable(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
|
|
string sql = string.Empty;
|
|
sql = @"UPDATE dbo.ICSExtensionEnable set ColCode='{0}',ColName='{1}',Enable='{2}',MTIME=GETDATE(),MUSER='{3}',MUSERName='{4}',WorkPoint='{5}' WHERE ID='{6}'";
|
|
sql = string.Format(sql, queryParam["ColCode"].ToString(), queryParam["ColName"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改启用配置
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string UpdateICSColumnEnable(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
|
|
string sql = string.Empty;
|
|
sql = @"UPDATE dbo.ICSColumnEnable set TableCode = '{0}',ColumnCode='{1}',Code='{2}',Name='{3}',Enable='{4}',MTIME=GETDATE(),MUSER='{5}',MUSERName='{6}',WorkPoint='{7}' WHERE ID='{8}'";
|
|
sql = string.Format(sql, queryParam["TableCode"].ToString(), queryParam["ColumnCode"].ToString(), queryParam["Code"].ToString().Replace("EATTRIBUTE", ""), queryParam["Name"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增启用配置
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string InsertICSExtensionEnable(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
sql = @"INSERT INTO dbo.ICSExtensionEnable
|
|
( ID ,ColCode ,ColName ,Enable,MTIME,MUSER ,MUSERName ,WorkPoint )
|
|
Values(NEWID(),'{0}','{1}','{2}',GETDATE(),'{3}','{4}','{5}')
|
|
";
|
|
sql = string.Format(sql, queryParam["ColCode"].ToString(), queryParam["ColName"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint);
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增启用配置
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string InsertICSColumnEnable(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
sql = @"INSERT INTO dbo.ICSColumnEnable
|
|
( ID ,TableCode,ColumnCode,Code ,Name ,Enable,MTIME,MUSER ,MUSERName ,WorkPoint )
|
|
Values(NEWID(),'{0}','{1}','{2}','{3}','{4}',GETDATE(),'{5}','{6}','{7}')
|
|
";
|
|
sql = string.Format(sql, queryParam["TableCode"].ToString(),queryParam["Code"].ToString(), queryParam["Code"].ToString().Replace("EATTRIBUTE", ""), queryParam["Name"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint);
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除启用配置
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteICSExtensionEnable(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.ICSExtensionEnable WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除单据启用配置
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteICSColumnEnable(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.ICSColumnEnable WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
//不良代码
|
|
public DataTable GetICSBadCodeGroup(ref Pagination jqgridparam, string queryJson)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @" select ID,BCGCode,BCGDesc,MUSER,MUSERName,MTIME,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,
|
|
EATTRIBUTE9,EATTRIBUTE10 from ICSBadCodeGroup ";
|
|
sql += " WHERE 1=1";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BadCode"].ToString()))
|
|
{
|
|
sql += " and BCGCode like '%" + queryParam["BadCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BadCodeName"].ToString()))
|
|
{
|
|
sql += " and BCGDesc like '%" + queryParam["BadCodeName"].ToString() + "%' ";
|
|
}
|
|
}
|
|
sql = string.Format(sql);
|
|
DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
//不良原因
|
|
public DataTable GetICSBadReasonGroup(ref Pagination jqgridparam, string queryJson)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @" select ID,BRGCode,BRGDesc,MUSER,MUSERName,MTIME,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,
|
|
EATTRIBUTE9,EATTRIBUTE10 from ICSBadReasonGroup ";
|
|
sql += " WHERE 1=1";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BadReason"].ToString()))
|
|
{
|
|
sql += " and BRGCode like '%" + queryParam["BadReason"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["BadReasonName"].ToString()))
|
|
{
|
|
sql += " and BRGDesc like '%" + queryParam["BadReasonName"].ToString() + "%' ";
|
|
}
|
|
}
|
|
sql = string.Format(sql);
|
|
DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
//不良代码子表
|
|
public DataTable GetICSBadCodeGroupdetil(string ID, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"select BCGroupID,BadCode,BadDesc,MUSERName,MTIME,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,
|
|
EATTRIBUTE9,EATTRIBUTE10 from ICSBadCode
|
|
where BCGroupID='" + ID + "' ";
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
public DataTable GetICSBadCode(string BRGCode, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
|
|
|
|
|
|
|
|
|
|
string sql = @"select BRGroupID,BadReasonCode,BadReasonDesc,MUSERName,MTIME from ICSBadReason
|
|
WHERE BRGroupID='" + BRGCode + "' ";
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 不良原因子表查询
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetICSBadReason(string BRGroupID, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"select BRGroupID,BadReasonCode,BadReasonDesc,MUSERName,MTIME,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,
|
|
EATTRIBUTE9,EATTRIBUTE10 from ICSBadReason
|
|
WHERE BRGroupID='" + BRGroupID + "' ";
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
/// <summary>
|
|
/// 不良原因子表查询2
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetICSBadReason2(string BRGCode, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"select BRGroupID,BadReasonCode,BadReasonDesc,MUSERName,MTIME from ICSBadReason
|
|
WHERE BRGroupID='" + BRGCode + "' ";
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
public void DeleteBCItem(string ID)
|
|
{
|
|
string sql = "DELETE FROM dbo.ICSBadCode WHERE ID='" + ID + "'";
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
|
|
public void DeleteItem(string ID)
|
|
{
|
|
string sql = "DELETE FROM dbo.ICSBadReason WHERE ID='" + ID + "'";
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
//不良代码新增
|
|
public void SubICSBadCodeGroupAdd(ICSBadReason main, string BRGCode, string BRGDesc)
|
|
{
|
|
string sql = string.Empty;
|
|
string sqls = string.Empty;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string NewID = Common.GuId();
|
|
List<ICSBadReason> list_Item1 = new List<ICSBadReason>();
|
|
if (main.arrayShellFabricItem != null)
|
|
{
|
|
list_Item1 = JsonConvert.DeserializeObject<List<ICSBadReason>>(main.arrayShellFabricItem);
|
|
}
|
|
string connString = SqlHelper.DataCenterConnString;
|
|
SqlConnection conn = new SqlConnection(connString);
|
|
conn.Open();
|
|
SqlTransaction sqlTran = conn.BeginTransaction();
|
|
SqlCommand cmd = new SqlCommand();
|
|
cmd.Transaction = sqlTran;
|
|
cmd.Connection = conn;
|
|
sql = @"IF EXISTS( select BCGCode from ICSBadCodeGroup where BCGCode='{0}')
|
|
BEGIN
|
|
RAISERROR('系统中已存在相同编号的不良代码编号!',16,1);
|
|
RETURN
|
|
END
|
|
INSERT INTO dbo.ICSBadCodeGroup
|
|
( ID ,BCGCode ,BCGDesc, MTIME,MUSER ,MUSERName ,WorkPoint )
|
|
Values('{5}','{0}','{1}',GETDATE(),'{2}','{3}','{4}')";
|
|
sql = string.Format(sql, BRGCode, BRGDesc, MUSER, MUSERNAME, WorkPoint, NewID);
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
foreach (ICSBadReason Item in list_Item1)
|
|
{
|
|
sqls = @"IF EXISTS( select BadCode from ICSBadCode where BadCode=@BadReasonCode)
|
|
BEGIN
|
|
RAISERROR('系统中已存在相同编号的不良代码编号!',16,1);
|
|
RETURN
|
|
END
|
|
INSERT INTO dbo.ICSBadCode
|
|
( ID ,BCGroupID,BadCode ,BadDesc, MTIME,MUSER ,MUSERName ,WorkPoint )
|
|
Values(@ID,'{0}',@BadReasonCode,@BadReasonDesc,GETDATE(),'{1}','{2}','{3}')";
|
|
sqls = string.Format(sqls, NewID, MUSER, MUSERNAME, WorkPoint);
|
|
SqlParameter[] sp_Item =
|
|
{
|
|
new SqlParameter("@ID",DbType.String){ Value= Item.ID},
|
|
new SqlParameter("@BadReasonCode",DbType.String){ Value= Item.BadReasonCode},
|
|
new SqlParameter("@BadReasonDesc",DbType.String){ Value= Item.BadReasonDesc},
|
|
|
|
};
|
|
SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
|
|
|
|
}
|
|
cmd.Transaction.Commit();
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
cmd.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
if (conn.State == ConnectionState.Open)
|
|
{
|
|
conn.Close();
|
|
}
|
|
conn.Dispose();
|
|
}
|
|
}
|
|
|
|
//不良原因新增
|
|
public void SubICSBadReasonGroupAdd(ICSBadReason main, string BRGCode, string BRGDesc)
|
|
{
|
|
string sql = string.Empty;
|
|
string sqls = string.Empty;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string NewID = Common.GuId();
|
|
List<ICSBadReason> list_Item1 = new List<ICSBadReason>();
|
|
if (main.arrayShellFabricItem != null)
|
|
{
|
|
list_Item1 = JsonConvert.DeserializeObject<List<ICSBadReason>>(main.arrayShellFabricItem);
|
|
}
|
|
string connString = SqlHelper.DataCenterConnString;
|
|
SqlConnection conn = new SqlConnection(connString);
|
|
conn.Open();
|
|
SqlTransaction sqlTran = conn.BeginTransaction();
|
|
SqlCommand cmd = new SqlCommand();
|
|
cmd.Transaction = sqlTran;
|
|
cmd.Connection = conn;
|
|
sql = @"IF EXISTS( select BRGCode from ICSBadReasonGroup where BRGCode='{0}')
|
|
BEGIN
|
|
RAISERROR('系统中已存在相同编号的不良原因组编号!',16,1);
|
|
RETURN
|
|
end
|
|
INSERT INTO dbo.ICSBadReasonGroup
|
|
( ID ,BRGCode ,BRGDesc, MTIME,MUSER ,MUSERName ,WorkPoint )
|
|
Values('{5}','{0}','{1}',GETDATE(),'{2}','{3}','{4}')";
|
|
sql = string.Format(sql, BRGCode, BRGDesc, MUSER, MUSERNAME, WorkPoint, NewID);
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
foreach (ICSBadReason Item in list_Item1)
|
|
{
|
|
sqls = @"IF EXISTS(select BadReasonCode from ICSBadReason where BadReasonCode=@BadReasonCode)
|
|
BEGIN
|
|
RAISERROR('系统中已存在相同编号的不良原因编号!',16,1);
|
|
RETURN
|
|
end
|
|
INSERT INTO dbo.ICSBadReason
|
|
( ID ,BRGroupID,BadReasonCode ,BadReasonDesc, MTIME,MUSER ,MUSERName ,WorkPoint )
|
|
Values(@ID,'{0}',@BadReasonCode,@BadReasonDesc,GETDATE(),'{1}','{2}','{3}')";
|
|
sqls = string.Format(sqls, NewID, MUSER, MUSERNAME, WorkPoint);
|
|
SqlParameter[] sp_Item = {
|
|
new SqlParameter("@ID",DbType.String){ Value= Item.ID},
|
|
new SqlParameter("@BadReasonCode",DbType.String){ Value= Item.BadReasonCode},
|
|
new SqlParameter("@BadReasonDesc",DbType.String){ Value= Item.BadReasonDesc},
|
|
|
|
};
|
|
SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
|
|
|
|
}
|
|
cmd.Transaction.Commit();
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
cmd.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
if (conn.State == ConnectionState.Open)
|
|
{
|
|
conn.Close();
|
|
}
|
|
conn.Dispose();
|
|
}
|
|
}
|
|
|
|
public DataTable GetICSBadCodeGroupdetil2(string ID)
|
|
{
|
|
string sql = string.Empty;
|
|
DataTable dt = null;
|
|
sql = string.Format(@"select * from ICSBadCode where BCGroupID='{0}'", ID);
|
|
dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
public DataTable GetICSBadReason2(string BID)
|
|
{
|
|
string sql = string.Empty;
|
|
DataTable dt = null;
|
|
sql = string.Format(@"select * from ICSBadReason where BRGroupID='{0}'", BID);
|
|
dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
public void UpdateICSBadCodeGroup(ICSBadReason main, string BID, string BRGCode, string BRGDesc)
|
|
{
|
|
string sql = string.Empty;
|
|
string sqls = string.Empty;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
List<ICSBadReason> list_Item1 = new List<ICSBadReason>();
|
|
if (main.arrayShellFabricItem != null)
|
|
{
|
|
list_Item1 = JsonConvert.DeserializeObject<List<ICSBadReason>>(main.arrayShellFabricItem);
|
|
}
|
|
string connString = SqlHelper.DataCenterConnString;
|
|
SqlConnection conn = new SqlConnection(connString);
|
|
conn.Open();
|
|
SqlTransaction sqlTran = conn.BeginTransaction();
|
|
SqlCommand cmd = new SqlCommand();
|
|
cmd.Transaction = sqlTran;
|
|
cmd.Connection = conn;
|
|
sql = @"UPDATE dbo.ICSBadCodeGroup set BCGCode='{0}',BCGDesc='{1}',MTIME=GETDATE(),MUSER='{2}',MUSERName='{3}',WorkPoint='{4}' WHERE ID='{5}'";
|
|
sql = string.Format(sql, BRGCode, BRGDesc, MUSER, MUSERNAME, WorkPoint, BID);
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
foreach (ICSBadReason Item in list_Item1)
|
|
{
|
|
sqls = @" IF NOT EXISTS(SELECT * FROM ICSBadCode WHERE ID=@ID)
|
|
BEGIN
|
|
INSERT INTO ICSBadCode( ID,BCGroupID,BadCode,BadDesc,MTIME,MUSER,MUSERName,WorkPoint)
|
|
VALUES (@ID,'{0}',@BadReasonCode,@BadReasonDesc,getdate(),'{1}','{2}','{3}')
|
|
END
|
|
ELSE
|
|
BEGIN
|
|
UPDATE dbo.ICSBadCode set BCGroupID='{0}',BadCode=@BadReasonCode,BadDesc=@BadReasonDesc,MTIME=GETDATE(),MUSER='{1}',MUSERName='{2}',WorkPoint='{3}' WHERE ID=@ID
|
|
end
|
|
";
|
|
sqls = string.Format(sqls, BID, MUSER, MUSERNAME, WorkPoint);
|
|
SqlParameter[] sp_Item = {
|
|
new SqlParameter("@ID",DbType.String){ Value= Item.ID},
|
|
new SqlParameter("@BadReasonCode",DbType.String){ Value= Item.BadReasonCode},
|
|
new SqlParameter("@BadReasonDesc",DbType.String){ Value= Item.BadReasonDesc},
|
|
|
|
};
|
|
SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
|
|
|
|
}
|
|
cmd.Transaction.Commit();
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
cmd.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
if (conn.State == ConnectionState.Open)
|
|
{
|
|
conn.Close();
|
|
}
|
|
conn.Dispose();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 周转箱使用记录查询
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetBoxesRecord(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var queryParam = queryJson.ToJObject();
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT a.BoxCode ,a.BoxNumber,a.Picture,a.MTIME,a.MUSERName,b.BoxName FROM ICSWorkingCapitalBoxLog a
|
|
left JOIN ICSWorkingCapitalBoxAccount b ON a.BoxCode=b.BoxCode WHERE 1=1 ";
|
|
if (queryParam["BoxCode"]!=null&& queryParam["BoxCode"].ToString()!="")
|
|
{
|
|
sql = sql + $@"and a.BoxCode='{queryParam["BoxCode"]}' ";
|
|
}
|
|
if (queryParam["BoxName"] != null && queryParam["BoxName"].ToString() != "")
|
|
{
|
|
sql = sql + $@" and a.BoxCode='{queryParam["BoxName"]}'";
|
|
}
|
|
if (queryParam["BoxNumber"] != null && queryParam["BoxNumber"].ToString() != "")
|
|
{
|
|
sql = sql + $@" and a.BoxNumber='{queryParam["BoxNumber"]}'";
|
|
}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 周转箱台账信息
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetBoxesAccountRecord(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
var queryParam = queryJson.ToJObject();
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT [ID], [BoxCode], [BoxNumber], [BoxName], [States], [Describe], [DailyUses], [TotalUses], [TotalClearn], [CleanDate], [Cleaner], [Picture], [MUser], [MUSERName], [MTIME] from ICSWorkingCapitalBoxAccount WHERE 1=1 ";
|
|
if (queryParam["BoxCode"] != null && queryParam["BoxCode"].ToString() != "")
|
|
{
|
|
sql = sql + $@"and a.BoxCode='{queryParam["BoxCode"]}' ";
|
|
}
|
|
if (queryParam["BoxName"] != null && queryParam["BoxName"].ToString() != "")
|
|
{
|
|
sql = sql + $@" and a.BoxCode='{queryParam["BoxName"]}'";
|
|
}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 模具使用记录查询
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetMouldRecord(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
var queryParam = queryJson.ToJObject();
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT a.MouldCode,a.Status,a.EOPCode,a.Picture ,a.MouldNumber,a.DailyUses,b.MouldName,
|
|
(case when a.status = '保养' then a.StartDate else null end) as MaintenanceDate,
|
|
(case when a.status = '保养' then a.MUSERName else null end) as MaintenancePerson,
|
|
(case when a.status = '维修' then a.StartDate else null end) as MaintainDate,
|
|
(case when a.status = '维修' then a.MUSERName else null end) as MaintainPerson,
|
|
(case when a.status not in('保养','维修') then a.MTime else null end) as UseDate,
|
|
(case when a.status not in('保养','维修') then a.MUSERName else null end) as UsePerson
|
|
FROM ICSMouldLog a
|
|
left JOIN ICSMouldAccount b ON a.MouldCode=b.MouldCode WHERE 1=1 ";
|
|
if (queryParam["MouldCode"] != null && queryParam["MouldCode"].ToString() != "")
|
|
{
|
|
sql = sql + $@"and a.MouldCode='{queryParam["MouldCode"]}' ";
|
|
}
|
|
if (queryParam["MouldNumber"] != null && queryParam["MouldNumber"].ToString() != "")
|
|
{
|
|
sql = sql + $@"and a.MouldNumber='{queryParam["MouldNumber"]}' ";
|
|
}
|
|
if (queryParam["MouldName"] != null && queryParam["MouldName"].ToString() != "")
|
|
{
|
|
sql = sql + $@" and a.MouldCode='{queryParam["MouldName"]}'";
|
|
}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 模具台账信息
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetMouldAccountRecord(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
var queryParam = queryJson.ToJObject();
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT [ID], [MouldCode], [MouldNumber], [MouldName], [MajorStates], [SubStates], [UpperLimit], [LowerLimit], [DailyUses],
|
|
[TotalUses], [Users], [UserDate], [Picture], [MUser], [MUSERName], [MTIME], [EATTRIBUTE1] FROM ICSMouldAccount WHERE 1=1 ";
|
|
if (queryParam["MouldCode"] != null && queryParam["MouldCode"].ToString() != "")
|
|
{
|
|
sql = sql + $@"and MouldCode='{queryParam["MouldCode"]}' ";
|
|
}
|
|
if (queryParam["MouldNumber"] != null && queryParam["MouldNumber"].ToString() != "")
|
|
{
|
|
sql = sql + $@"and MouldNumber='{queryParam["MouldNumber"]}' ";
|
|
}
|
|
if (queryParam["MouldName"] != null && queryParam["MouldName"].ToString() != "")
|
|
{
|
|
sql = sql + $@" and MouldCode='{queryParam["MouldName"]}'";
|
|
}
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
public void UpdateICSBadReasonGroup(ICSBadReason main, string BID, string BRGCode, string BRGDesc)
|
|
{
|
|
string sql = string.Empty;
|
|
string sqls = string.Empty;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
List<ICSBadReason> list_Item1 = new List<ICSBadReason>();
|
|
if (main.arrayShellFabricItem != null)
|
|
{
|
|
list_Item1 = JsonConvert.DeserializeObject<List<ICSBadReason>>(main.arrayShellFabricItem);
|
|
}
|
|
string connString = SqlHelper.DataCenterConnString;
|
|
SqlConnection conn = new SqlConnection(connString);
|
|
conn.Open();
|
|
SqlTransaction sqlTran = conn.BeginTransaction();
|
|
SqlCommand cmd = new SqlCommand();
|
|
cmd.Transaction = sqlTran;
|
|
cmd.Connection = conn;
|
|
sql = @"UPDATE dbo.ICSBadReasonGroup set BRGCode='{0}',BRGDesc='{1}',MTIME=GETDATE(),MUSER='{2}',MUSERName='{3}',WorkPoint='{4}' WHERE ID='{5}'";
|
|
sql = string.Format(sql, BRGCode, BRGDesc, MUSER, MUSERNAME, WorkPoint, BID);
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
foreach (ICSBadReason Item in list_Item1)
|
|
{
|
|
sqls = @" IF NOT EXISTS(SELECT * FROM ICSBadReason WHERE ID=@ID)
|
|
BEGIN
|
|
INSERT INTO ICSBadReason( ID,BRGroupID,BadReasonCode,BadReasonDesc,MTIME,MUSER,MUSERName,WorkPoint)
|
|
VALUES (@ID,'{0}',@BadReasonCode,@BadReasonDesc,getdate(),'{1}','{2}','{3}')
|
|
END
|
|
ELSE
|
|
BEGIN
|
|
UPDATE dbo.ICSBadReason set BRGroupID='{0}',BadReasonCode=@BadReasonCode,BadReasonDesc=@BadReasonDesc,MTIME=GETDATE(),MUSER='{1}',MUSERName='{2}',WorkPoint='{3}' WHERE ID=@ID
|
|
end
|
|
";
|
|
sqls = string.Format(sqls, BID, MUSER, MUSERNAME, WorkPoint);
|
|
SqlParameter[] sp_Item = {
|
|
new SqlParameter("@ID",DbType.String){ Value= Item.ID},
|
|
new SqlParameter("@BadReasonCode",DbType.String){ Value= Item.BadReasonCode},
|
|
new SqlParameter("@BadReasonDesc",DbType.String){ Value= Item.BadReasonDesc},
|
|
|
|
};
|
|
SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
|
|
|
|
}
|
|
cmd.Transaction.Commit();
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
cmd.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
if (conn.State == ConnectionState.Open)
|
|
{
|
|
conn.Close();
|
|
}
|
|
conn.Dispose();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除不良代码组
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteICSBadCodeGroup(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.ICSBadCodeGroup WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
sql += string.Format(@"DELETE FROM dbo.ICSBadCode WHERE BCGroupID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 删除不良原因组
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteICSBadReasonGroup(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.ICSBadReasonGroup WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
sql += string.Format(@"DELETE FROM dbo.ICSBadReason WHERE BRGroupID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 初次加载查询检验项目组
|
|
/// </summary>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetICSInspectionGroup(ref Pagination jqgridparam, string queryJson)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"select ID,GroupCode,GroupName,Enable,MUSER,MUSERName,MTIME from ICSInspectionGroup ";
|
|
sql += " WHERE 1=1";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ListCode"].ToString()))
|
|
{
|
|
sql += " and GroupCode like '%" + queryParam["ListCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["ListName"].ToString()))
|
|
{
|
|
sql += " and GroupName like '%" + queryParam["ListName"].ToString() + "%' ";
|
|
}
|
|
}
|
|
sql = string.Format(sql);
|
|
DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 检验项目子表查询
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable ICSInspectionList(string GroupCode, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"select GroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable,MUSERName,MTIME,EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,
|
|
EATTRIBUTE9,EATTRIBUTE10
|
|
from ICSInspectionList
|
|
WHERE GroupID='" + GroupCode + "' ";
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
/// <summary>
|
|
/// 根据id删除自动表
|
|
/// </summary>
|
|
/// <param name="ID"></param>
|
|
public void DeleteList(string ID)
|
|
{
|
|
string sql = "DELETE FROM dbo.ICSInspectionList WHERE ID='" + ID + "'";
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 检查项目组修改
|
|
/// </summary>
|
|
/// <param name="main"></param>
|
|
/// <param name="BID"></param>
|
|
/// <param name="GroupCode"></param>
|
|
/// <param name="GroupName"></param>
|
|
/// <param name="Enable"></param>
|
|
public void UpdateICSInspectionGroup(ICSInspectionList main, string BID, string GroupCode, string GroupName, string Enable)
|
|
{
|
|
string sql = string.Empty;
|
|
string sqls = string.Empty;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
List<ICSInspectionList> list_Item1 = new List<ICSInspectionList>();
|
|
if (main.arrayShellFabricItem != null)
|
|
{
|
|
list_Item1 = JsonConvert.DeserializeObject<List<ICSInspectionList>>(main.arrayShellFabricItem);
|
|
}
|
|
string connString = SqlHelper.DataCenterConnString;
|
|
SqlConnection conn = new SqlConnection(connString);
|
|
conn.Open();
|
|
SqlTransaction sqlTran = conn.BeginTransaction();
|
|
SqlCommand cmd = new SqlCommand();
|
|
cmd.Transaction = sqlTran;
|
|
cmd.Connection = conn;
|
|
sql = @"UPDATE dbo.ICSInspectionGroup set GroupCode='{0}',GroupName='{1}',Enable='{2}',MTIME=GETDATE(),MUSER='{3}',MUSERName='{4}',WorkPoint='{5}' WHERE ID='{6}'";
|
|
sql = string.Format(sql, GroupCode, GroupName, Enable, MUSER, MUSERNAME, WorkPoint, BID);
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
foreach (ICSInspectionList Item in list_Item1)
|
|
{
|
|
sqls = @" IF NOT EXISTS(SELECT * FROM ICSInspectionList WHERE ID=@ID)
|
|
BEGIN
|
|
INSERT INTO ICSInspectionList( ID,GroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable,MTIME,MUSER,MUSERName,WorkPoint)
|
|
VALUES (@ID,'{0}',@ListCode,@ListName,@Unit,@SetValueMax,@SetValueMin,@Enable,getdate(),'{1}','{2}','{3}')
|
|
END
|
|
ELSE
|
|
BEGIN
|
|
UPDATE dbo.ICSInspectionList set GroupID='{0}',ListCode=@ListCode,ListName=@ListName,Unit=@Unit,SetValueMax=@SetValueMax,SetValueMin=@SetValueMin,Enable=@Enable,MTIME=GETDATE(),MUSER='{1}',MUSERName='{2}',WorkPoint='{3}' WHERE ID=@ID
|
|
end
|
|
";
|
|
sqls = string.Format(sqls, BID, MUSER, MUSERNAME, WorkPoint);
|
|
SqlParameter[] sp_Item = {
|
|
new SqlParameter("@ID",DbType.String){ Value= Item.ID},
|
|
new SqlParameter("@ListCode",DbType.String){ Value= Item.ListCode},
|
|
new SqlParameter("@ListName",DbType.String){ Value= Item.ListName},
|
|
new SqlParameter("@Unit",DbType.String){ Value= Item.Unit},
|
|
new SqlParameter("@SetValueMax",DbType.String){ Value= Item.SetValueMax},
|
|
new SqlParameter("@SetValueMin",DbType.String){ Value= Item.SetValueMin},
|
|
new SqlParameter("@Enable",DbType.String){ Value= Item.Enable},
|
|
|
|
};
|
|
SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
|
|
|
|
}
|
|
cmd.Transaction.Commit();
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
cmd.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
if (conn.State == ConnectionState.Open)
|
|
{
|
|
conn.Close();
|
|
}
|
|
conn.Dispose();
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 检查项目组新增
|
|
/// </summary>
|
|
/// <param name="main"></param>
|
|
/// <param name="BRGCode"></param>
|
|
/// <param name="BRGDesc"></param>
|
|
public void ICSInspectionGroupAdd(ICSInspectionList main, string GroupCode, string GroupName, string Enable)
|
|
{
|
|
string sql = string.Empty;
|
|
string sqls = string.Empty;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string ID = Guid.NewGuid().ToString();
|
|
List<ICSInspectionList> list_Item1 = new List<ICSInspectionList>();
|
|
if (main.arrayShellFabricItem != null)
|
|
{
|
|
list_Item1 = JsonConvert.DeserializeObject<List<ICSInspectionList>>(main.arrayShellFabricItem);
|
|
}
|
|
string connString = SqlHelper.DataCenterConnString;
|
|
SqlConnection conn = new SqlConnection(connString);
|
|
conn.Open();
|
|
SqlTransaction sqlTran = conn.BeginTransaction();
|
|
SqlCommand cmd = new SqlCommand();
|
|
cmd.Transaction = sqlTran;
|
|
cmd.Connection = conn;
|
|
sql = @"
|
|
IF EXISTS(select GroupCode from ICSInspectionGroup where GroupCode='{0}')
|
|
BEGIN
|
|
RAISERROR('系统中已存在相同编号的检查项目组编号!',16,1);
|
|
RETURN
|
|
end
|
|
INSERT INTO dbo.ICSInspectionGroup
|
|
( ID ,GroupCode ,GroupName,Enable, MTIME,MUSER ,MUSERName ,WorkPoint )
|
|
Values('{6}','{0}','{1}','{2}',GETDATE(),'{3}','{4}','{5}')";
|
|
sql = string.Format(sql, GroupCode, GroupName, Enable, MUSER, MUSERNAME, WorkPoint,ID);
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
foreach (ICSInspectionList Item in list_Item1)
|
|
{
|
|
sqls = @"
|
|
IF EXISTS(select ListCode from ICSInspectionList where ListCode=@ListCode)
|
|
BEGIN
|
|
RAISERROR('系统中已存在相同编号的检验项目代码!',16,1);
|
|
RETURN
|
|
end
|
|
INSERT INTO dbo.ICSInspectionList
|
|
( ID ,GroupID,ListCode ,ListName, Unit,SetValueMax ,SetValueMin,Enable,MTIME,MUSER ,MUSERName ,WorkPoint )
|
|
Values(@ID,'{0}',@ListCode,@ListName,@Unit,@SetValueMax,@SetValueMin,@Enable,getdate(),'{1}','{2}','{3}')";
|
|
sqls = string.Format(sqls, ID, MUSER, MUSERNAME, WorkPoint);
|
|
SqlParameter[] sp_Item = {
|
|
new SqlParameter("@ID",DbType.String){ Value= Item.ID},
|
|
new SqlParameter("@ListCode",DbType.String){ Value= Item.ListCode},
|
|
new SqlParameter("@ListName",DbType.String){ Value= Item.ListName},
|
|
new SqlParameter("@Unit",DbType.String){ Value= Item.Unit},
|
|
new SqlParameter("@SetValueMax",DbType.String){ Value= Item.SetValueMax},
|
|
new SqlParameter("@SetValueMin",DbType.String){ Value= Item.SetValueMin},
|
|
new SqlParameter("@Enable",DbType.String){ Value= Item.Enable},
|
|
|
|
};
|
|
SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
|
|
|
|
}
|
|
cmd.Transaction.Commit();
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
cmd.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
if (conn.State == ConnectionState.Open)
|
|
{
|
|
conn.Close();
|
|
}
|
|
conn.Dispose();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 动态子表修改加载页面
|
|
/// </summary>
|
|
/// <param name="GroupCode"></param>
|
|
/// <returns></returns>
|
|
public DataTable ICSInspectionList2(string GroupCode)
|
|
{
|
|
string sql = string.Empty;
|
|
DataTable dt = null;
|
|
sql = string.Format(@"SELECT ID,GroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,
|
|
case when Enable='1' then '是' else '否' end as Enable,
|
|
MUSER,MUSERName,MTIME,WorkPoint,EATTRIBUTE1 FROM
|
|
dbo.ICSInspectionList where GroupID='{0}'", GroupCode);
|
|
dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除不良原因组
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteICSInspectionGroup(string keyValue)
|
|
{
|
|
//站点信息
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
string sqls = string.Empty;
|
|
sql = string.Format(@"DELETE FROM dbo.ICSInspectionGroup WHERE GroupCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
sqls = string.Format(@"DELETE FROM dbo.ICSInspectionList WHERE GroupID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
SqlHelper.ExecuteNonQuery(sqls);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增料品属性
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string InsertICSInventory(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
sql = @"INSERT INTO dbo.ICSInventory
|
|
( ID ,InvCode ,InvName ,InvDesc,InvStd,InvUnit,AmountUnit ,ClassCode ,ClassName ,InvRate,InvVersion,InvBrand,InvIQC ,InvFQC ,EffectiveEnable,EffectiveDays,BatchEnable,LotEnable ,PrintEnable ,WHUser,MTIME,MUSER ,MUSERName ,WorkPoint ,AmountEnable)
|
|
Values(NEWID(),'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}',GETDATE(),'{19}','{20}','{21}','{22}')
|
|
";
|
|
sql = string.Format(sql,
|
|
queryParam["InvCode"].ToString(),
|
|
queryParam["InvName"].ToString(),
|
|
queryParam["InvDesc"].ToString(),
|
|
queryParam["InvStd"].ToString(),
|
|
queryParam["InvUnit"].ToString(),
|
|
queryParam["AmountUnit"].ToString(),
|
|
queryParam["ClassCode"].ToString(),
|
|
queryParam["ClassName"].ToString(),
|
|
queryParam["InvRate"].ToString(),
|
|
queryParam["InvVersion"].ToString(),
|
|
queryParam["InvBrand"].ToString(),
|
|
queryParam["InvIQC"].ToString(),
|
|
queryParam["InvFQC"].ToString(),
|
|
queryParam["EffectiveEnable"].ToString(),
|
|
queryParam["EffectiveDays"].ToString(),
|
|
queryParam["BatchEnable"].ToString(),
|
|
queryParam["LotEnable"].ToString(),
|
|
queryParam["PrintEnable"].ToString(),
|
|
queryParam["WHUser"].ToString(),
|
|
MUSER, MUSERNAME, WorkPoint, queryParam["AmountEnable"].ToString());
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
/// <summary>
|
|
/// 新增周转箱台账信息
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string InsertBoxAccount(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
sql = $@"IF ((SELECT 1 FROM ICSWorkingCapitalBoxAccount WHERE BoxCode='{queryParam["BoxCode"]}') IS NULL)
|
|
|
|
BEGIN
|
|
INSERT INTO[dbo].[ICSWorkingCapitalBoxAccount]([ID], [BoxCode], [BoxNumber], [BoxName], [States], [Describe], [DailyUses], [TotalUses], [TotalClearn], [MUser], [MUSERName], [MTIME]) VALUES(NEWID(), '{queryParam["BoxCode"]}', '{queryParam["BoxNumber"]}', '{queryParam["BoxName"]}', '正常', '{queryParam["Describe"]}', 0, 0, 0, '{MUSER}', '{MUSERNAME}', GETDATE())
|
|
|
|
END
|
|
ELSE
|
|
|
|
BEGIN
|
|
|
|
RAISERROR('周转箱代码码已存在,操作失败', 16, 1);
|
|
END ";
|
|
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增模具账信息
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string InsertMouldAccount(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
sql = $@"IF ((SELECT 1 FROM ICSMouldAccount WHERE MouldCode='{queryParam["MouldCode"]}') IS NULL)
|
|
|
|
BEGIN
|
|
INSERT INTO[dbo].[ICSMouldAccount]([ID], [MouldCode], [MouldNumber], [MouldName], [MajorStates],[UpperLimit], [LowerLimit], [Picture], [MUser], [MUSERName], [MTIME],[DailyUses],[TotalUses]) VALUES(NEWID(), '{queryParam["MouldCode"]}', '{queryParam["MouldNumber"]}', '{queryParam["MouldName"]}','{queryParam["Status"]}',{queryParam["UpperLimit"]}, {queryParam["LowerLimit"]},'{queryParam["Picture"]}','{MUSER}', '{MUSERNAME}', GETDATE(),0,0)
|
|
|
|
END
|
|
ELSE
|
|
|
|
BEGIN
|
|
|
|
RAISERROR('模具代码已存在,操作失败', 16, 1);
|
|
END ";
|
|
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 修改料品属性
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string UpdateICSInventory(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
|
|
string sql = string.Empty;
|
|
sql = @"UPDATE dbo.ICSInventory set
|
|
InvCode='{0}'
|
|
,InvName='{1}'
|
|
,InvDesc='{2}'
|
|
,InvStd='{3}'
|
|
,InvUnit='{4}'
|
|
,AmountUnit='{5}'
|
|
,ClassCode='{6}'
|
|
,ClassName='{7}'
|
|
,InvRate='{8}'
|
|
,InvVersion='{9}'
|
|
,InvBrand='{10}'
|
|
,InvIQC='{11}'
|
|
,InvFQC='{12}'
|
|
,EffectiveEnable='{13}'
|
|
,EffectiveDays='{14}'
|
|
,BatchEnable='{15}'
|
|
,LotEnable='{16}'
|
|
,PrintEnable='{17}'
|
|
,AmountEnable='{23}'
|
|
,WHUser='{18}'
|
|
,MTIME=GETDATE()
|
|
,MUSER='{19}'
|
|
,MUSERName='{20}'
|
|
,WorkPoint='{21}'
|
|
WHERE ID='{22}'";
|
|
sql = string.Format(sql,
|
|
queryParam["InvCode"].ToString(),
|
|
queryParam["InvName"].ToString(),
|
|
queryParam["InvDesc"].ToString(),
|
|
queryParam["InvStd"].ToString(),
|
|
queryParam["InvUnit"].ToString(),
|
|
queryParam["AmountUnit"].ToString(),
|
|
queryParam["ClassCode"].ToString(),
|
|
queryParam["ClassName"].ToString(),
|
|
queryParam["InvRate"].ToString(),
|
|
queryParam["InvVersion"].ToString(),
|
|
queryParam["InvBrand"].ToString(),
|
|
queryParam["InvIQC"].ToString(),
|
|
queryParam["InvFQC"].ToString(),
|
|
queryParam["EffectiveEnable"].ToString(),
|
|
queryParam["EffectiveDays"].ToString(),
|
|
queryParam["BatchEnable"].ToString(),
|
|
queryParam["LotEnable"].ToString(),
|
|
queryParam["PrintEnable"].ToString(),
|
|
queryParam["WHUser"].ToString(),
|
|
MUSER, MUSERNAME, WorkPoint,
|
|
queryParam["ID"].ToString(), queryParam["AmountEnable"].ToString());
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
/// <summary>
|
|
/// 修改周转箱台账
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string UpdateBoxAccount(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string msg = "";
|
|
|
|
string sql = string.Empty;
|
|
sql = $@"UPDATE [dbo].[ICSWorkingCapitalBoxAccount] SET [BoxNumber] = '{queryParam["BoxNumber"]}', [BoxName] = '{queryParam["BoxName"]}', [Describe] = '{queryParam["Describe"]}' WHERE ID='{queryParam["ID"]}'";
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改模具台账
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string UpdateMouldAccount(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string msg = "";
|
|
|
|
string sql = string.Empty;
|
|
if (!string.IsNullOrEmpty(queryParam["Picture"].ToString()))
|
|
{
|
|
sql = $@"UPDATE [dbo].[ICSMouldAccount] SET [MouldNumber] = '{queryParam["MouldNumber"]}', [MouldName] = '{queryParam["MouldName"]}', [MajorStates] = '{queryParam["Status"]}', [UpperLimit] = {queryParam["UpperLimit"]}, [LowerLimit] = {queryParam["LowerLimit"]}, [Picture] = '{queryParam["Picture"]}' WHERE ID='{queryParam["ID"]}'";
|
|
}
|
|
else
|
|
{
|
|
sql = $@"UPDATE [dbo].[ICSMouldAccount] SET [MouldNumber] = '{queryParam["MouldNumber"]}', [MouldName] = '{queryParam["MouldName"]}', [MajorStates] = '{queryParam["Status"]}', [UpperLimit] = {queryParam["UpperLimit"]}, [LowerLimit] = {queryParam["LowerLimit"]} WHERE ID='{queryParam["ID"]}'";
|
|
}
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改PDA版本
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string UpdatePDAVersion(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
|
|
string sql = string.Empty;
|
|
sql = @"UPDATE ICSVersions SET Version='{2}',URL='{3}',MUSERCode='{4}',MUSERName='{5}',MTIME=CONVERT(nvarchar(50),GETDATE(),120) WHERE guid='{0}' AND WorkPointCode IN('{1}')";
|
|
sql = string.Format(sql,
|
|
queryParam["guid"].ToString(),
|
|
WorkPoint,
|
|
queryParam["Version"].ToString(),
|
|
queryParam["URL"].ToString(),
|
|
MUSER,
|
|
MUSERNAME);
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取下拉料品号获取其他信息
|
|
/// </summary>
|
|
|
|
public DataTable GetInputValue(string ID)
|
|
{
|
|
try
|
|
{
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"select InvCode,InvName,InvDesc,InvStd,InvUnit,AmountUnit, ClassCode,ClassName,InvRate,InvVersion,InvBrand,InvIQC,
|
|
InvFQC,EffectiveEnable,EffectiveDays,BatchEnable,LotEnable,PrintEnable,WHUser,AmountEnable
|
|
from ICSInventory
|
|
WHERE 1=1 AND ID='{0}' ";
|
|
sql = string.Format(sql, ID);
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message.ToString());
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 删除料品属性
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteICSInventory(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.ICSInventory WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除条码
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteICSLotNo(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.ICSInventoryLot WHERE LotNo IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除周转箱台账信息
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteBoxAccount(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.ICSWorkingCapitalBoxAccount WHERE ID IN ({0})", keyValue.TrimEnd(','));
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取料品信息
|
|
/// </summary>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetICSInventoryInfo(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"select ID, InvCode,InvName,InvDesc,InvStd,InvUnit,AmountUnit,ClassCode,ClassName,InvRate,InvVersion,InvBrand,
|
|
InvIQC,InvFQC,EffectiveEnable,EffectiveDays,BatchEnable,LotEnable,PrintEnable,WHUser
|
|
from ICSInventory where WorkPoint='{0}' ";
|
|
sql = string.Format(sql, WorkPoint);
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sql += " and InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
}
|
|
|
|
// DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取仓库信息
|
|
/// </summary>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetICSWarehouseInfo(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"select ID,WarehouseCode,WarehouseName ,Enable,BatchEnable,Asset,Proxy,InCost from ICSWarehouse where WorkPoint='{0}' ";
|
|
sql = string.Format(sql, WorkPoint);
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["WHCode"].ToString()))
|
|
{
|
|
sql += " and WarehouseCode like '%" + queryParam["WHCode"].ToString() + "%' ";
|
|
}
|
|
}
|
|
|
|
DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增料品仓库批次关系
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string InsertICSInventoryBatchEnable(string keyValue, string keyValue2)
|
|
{
|
|
List<string> InvCodeList = keyValue.Substring(1, keyValue.Length - 3).Split(',').ToList<string>();
|
|
List<string> WarehouseCodeList = keyValue2.Substring(1, keyValue2.Length - 3).Split(',').ToList<string>();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
foreach (var item in InvCodeList)
|
|
{
|
|
foreach (var itemwh in WarehouseCodeList)
|
|
{
|
|
sql += @"IF EXISTS(select InvCode,WHCode from ICSInventoryBatchEnable where InvCode={0} and WHCode={1})
|
|
BEGIN
|
|
RAISERROR('请勿重复绑定料品仓库关系!',16,1);
|
|
RETURN
|
|
end
|
|
INSERT INTO dbo.ICSInventoryBatchEnable
|
|
( ID ,InvCode ,WHCode ,BatchEnable,MTIME,MUSER ,MUSERName ,WorkPoint )
|
|
Values(NEWID(),{0},{1},'{2}',GETDATE(),'{3}','{4}','{5}')
|
|
";
|
|
sql = string.Format(sql, item, itemwh, '1'.ToString(), MUSER, MUSERNAME, WorkPoint);
|
|
|
|
}
|
|
}
|
|
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改料品仓库批次关系
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string UpdateICSInventoryBatchEnable(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
|
|
string sql = string.Empty;
|
|
sql = @"UPDATE dbo.ICSInventoryBatchEnable set InvCode='{0}',WHCode='{1}',BatchEnable='{2}',MTIME=GETDATE(),MUSER='{3}',MUSERName='{4}',WorkPoint='{5}' WHERE ID='{6}'";
|
|
sql = string.Format(sql, queryParam["InvCode"].ToString(), queryParam["WHCode"].ToString(), queryParam["BatchEnable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除料品仓库批次关系
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteICSInventoryBatchEnable(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.ICSInventoryBatchEnable WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取库位信息
|
|
/// </summary>
|
|
/// <param name="jqgridparam"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetICSLocation(string queryJson, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"select ID,LocationCode,LocationName,WHID,MUSER,MUSERName,MTIME,WorkPoint from ICSLocation where WorkPoint='{0}' ";
|
|
sql = string.Format(sql, WorkPoint);
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["LocationCode"].ToString()))
|
|
{
|
|
sql += " and LocationCode like '%" + queryParam["LocationCode"].ToString() + "%' ";
|
|
}
|
|
}
|
|
|
|
//DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增料品仓库批次关系
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string InsertICSInventoryLocation(string keyValue, string keyValue2)
|
|
{
|
|
List<string> InvCodeList = keyValue.Substring(1, keyValue.Length - 3).Split(',').ToList<string>();
|
|
List<string> LocationCodeList = keyValue2.Substring(1, keyValue2.Length - 3).Split(',').ToList<string>();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
try
|
|
{
|
|
foreach (var item in InvCodeList)
|
|
{
|
|
foreach (var itemwh in LocationCodeList)
|
|
{
|
|
sql += @"IF EXISTS(select InvCode,LocationCode from ICSInventoryLocation where InvCode={0} and LocationCode={1})
|
|
BEGIN
|
|
RAISERROR('请勿重复绑定料品库位关系!',16,1);
|
|
RETURN
|
|
end
|
|
INSERT INTO dbo.ICSInventoryLocation
|
|
( ID ,InvCode ,LocationCode ,Enable,MTIME,MUSER ,MUSERName ,WorkPoint )
|
|
Values(NEWID(),{0},{1},'{2}',GETDATE(),'{3}','{4}','{5}')
|
|
";
|
|
sql = string.Format(sql, item, itemwh, '1'.ToString(), MUSER, MUSERNAME, WorkPoint);
|
|
|
|
}
|
|
}
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改料品库位绑定关系
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string UpdateICSInventoryLocation(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
|
|
string sql = string.Empty;
|
|
sql = @"UPDATE dbo.ICSInventoryLocation set InvCode='{0}',LocationCode='{1}',Enable='{2}',MTIME=GETDATE(),MUSER='{3}',MUSERName='{4}',WorkPoint='{5}' WHERE ID='{6}'";
|
|
sql = string.Format(sql, queryParam["InvCode"].ToString(), queryParam["LocationCode"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除料品仓库批次关系
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteICSInventoryLocation(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.ICSInventoryLocation WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增包装、容器
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
/// 20230717 lacy.xu Modifly 新增允许料品混装、允许项目号混装、允许批次混装、允许复用
|
|
public string InsertICSContainer(string keyValue)
|
|
{
|
|
string msg = "";
|
|
try
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
string sql = string.Empty;
|
|
sql = @"IF EXISTS(select ContainerCODE from ICSContainer where ContainerCODE='{1}' )
|
|
RAISERROR('容器:{1},已存在!',16,1)
|
|
else
|
|
INSERT INTO dbo.ICSContainer
|
|
( ID ,ContainerID ,ContainerCODE ,ContainerName,Memo,MTIME,MUSER ,MUSERName ,WorkPoint
|
|
,InventoryMixed,ProjectMixed,BatchMixed,Multiplex,ContainerType)
|
|
Values(NEWID(),'{0}','{1}','{2}','{3}',GETDATE(),'{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')
|
|
";
|
|
sql = string.Format(sql, queryParam["ContainerID"].ToString(), queryParam["ContainerCODE"].ToString(), queryParam["ContainerName"].ToString(), queryParam["Memo"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["InventoryMixed"].ToString(), queryParam["ProjectMixed"].ToString(), queryParam["BatchMixed"].ToString(), queryParam["Multiplex"].ToString(), queryParam["ContainerType"].ToString());
|
|
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 修改包装、容器
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
/// 20230717 lacy.xu Modifly 新增允许料品混装、允许项目号混装、允许批次混装、允许复用
|
|
public string UpdateICSContainer(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
|
|
string sql = string.Empty;
|
|
// sql = @" IF EXISTS(select ContainerCODE from ICSContainer where ContainerCODE='{1}' )
|
|
// RAISERROR('容器:{1},已存在!',16,1)
|
|
//UPDATE dbo.ICSContainer set ContainerID='{0}',ContainerCODE='{1}',ContainerName='{2}',Memo='{3}',MTIME=GETDATE(),MUSER='{4}',MUSERName='{5}',WorkPoint='{6}',InventoryMixed='{8}',ProjectMixed='{9}',BatchMixed='{10}',Multiplex='{11}' WHERE ID='{7}'";
|
|
sql = @"UPDATE dbo.ICSContainer set ContainerID='{0}',ContainerCODE='{1}',ContainerName='{2}',Memo='{3}',MTIME=GETDATE(),MUSER='{4}',MUSERName='{5}',WorkPoint='{6}',InventoryMixed='{8}',ProjectMixed='{9}',BatchMixed='{10}',Multiplex='{11}',ContainerType='{12}' WHERE ID='{7}'";
|
|
sql = string.Format(sql, queryParam["ContainerID"].ToString(), queryParam["ContainerCODE"].ToString(), queryParam["ContainerName"].ToString(), queryParam["Memo"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString(), queryParam["InventoryMixed"].ToString(), queryParam["ProjectMixed"].ToString(), queryParam["BatchMixed"].ToString(), queryParam["Multiplex"].ToString(), queryParam["ContainerType"].ToString());
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
msg = ex.Message;
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除包装、容器
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteICSContainer(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.ICSContainer WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
//try
|
|
//{
|
|
// SqlHelper.ExecuteNonQuery(sql);
|
|
//}
|
|
//catch (Exception ex)
|
|
//{
|
|
// throw new Exception(ex.Message);
|
|
//}
|
|
//return msg;
|
|
string msg = "";
|
|
string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "ICSContainerCon/Untie";
|
|
string result =DeciliterApp.HttpPost(APIURL, keyValue);
|
|
JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
|
|
string MessAge = Obj["Message"].ToString();
|
|
string Success = Obj["Success"].ToString();
|
|
if (Success.ToUpper() == "FALSE")
|
|
{
|
|
msg = MessAge;
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增包装、容器关联条码
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string InsertICSContainerLot(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
sql = @"INSERT INTO dbo.ICSContainerLot
|
|
( ID ,ContainerID ,LotNo ,MTIME,MUSER ,MUSERName ,WorkPoint )
|
|
Values(NEWID(),'{0}','{1}',getdate(),'{2}','{3}','{4}')
|
|
";
|
|
sql = string.Format(sql, queryParam["ContainerID"].ToString(), queryParam["LotNo"].ToString(), MUSER, MUSERNAME, WorkPoint);
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 修改包装、容器
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string UpdateICSContainerLot(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
|
|
string sql = string.Empty;
|
|
sql = @"UPDATE dbo.ICSContainerLot set ContainerID='{0}',LotNo='{1}',MTIME=GETDATE(),MUSER='{2}',MUSERName='{3}',WorkPoint='{4}' WHERE ID='{5}'";
|
|
sql = string.Format(sql, queryParam["ContainerID"].ToString(), queryParam["LotNo"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
/// <summary>
|
|
/// 删除包装、容器
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteICSContainerLot(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.ICSContainerLot WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
//try
|
|
//{
|
|
// SqlHelper.ExecuteNonQuery(sql);
|
|
//}
|
|
//catch (Exception ex)
|
|
//{
|
|
// throw new Exception(ex.Message);
|
|
//}
|
|
//return msg;
|
|
string msg = "";
|
|
string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "ICSContainerLot/Untie";
|
|
string result = DeciliterApp.HttpPost(APIURL, keyValue);
|
|
JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
|
|
string MessAge = Obj["Message"].ToString();
|
|
string Success = Obj["Success"].ToString();
|
|
if (Success.ToUpper() == "FALSE")
|
|
{
|
|
msg = MessAge;
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取料品信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetInvCode()
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string sql = @"
|
|
select '' as InvCode,'' as InvName
|
|
union all
|
|
SELECT InvCode,InvName FROM ICSInventory WITH (NOLOCK) WHERE 1=1 ";
|
|
string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
|
|
if (role != "admin")
|
|
{
|
|
sql += " and b.WorkPoint='" + WorkPoint + "'";
|
|
}
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取不良代码信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetBCGroup()
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string sql = @"select '' as ID,'' as BCGDesc
|
|
union all
|
|
SELECT ID,BCGDesc FROM ICSBadCodeGroup WITH (NOLOCK) WHERE 1=1 ";
|
|
string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
|
|
if (role != "admin")
|
|
{
|
|
sql += " and b.WorkPoint='" + WorkPoint + "'";
|
|
}
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取不良原因信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable BRGroupID()
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string sql = @"select '' as ID,'' as BRGDesc
|
|
union all
|
|
SELECT ID,BRGDesc FROM ICSBadReasonGroup WITH (NOLOCK) WHERE 1=1 ";
|
|
string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
|
|
if (role != "admin")
|
|
{
|
|
sql += " and b.WorkPoint='" + WorkPoint + "'";
|
|
}
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增料品不良信息
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string InsertInventoryBadGroup(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
sql = @"INSERT INTO dbo.ICSInventoryBadGroup
|
|
( ID,InvCode,BCGroupID,BRGroupID,Enable,MUSER,MUSERName,MTIME,WorkPoint)
|
|
Values(NEWID(),'{0}','{1}','{2}','{3}','{4}','{5}',getdate(),'{6}')";
|
|
sql = string.Format(sql, queryParam["InvCode"].ToString(), queryParam["BCGroupID"].ToString(), queryParam["BRGroupID"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint);
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改料品不良信息
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string UpdateInventoryBadGroup(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
sql = @"UPDATE dbo.ICSInventoryBadGroup set BCGroupID='{0}',BRGroupID='{1}',Enable='{2}',MUSER='{3}',MUSERName='{4}',MTIME=GetDate(),WorkPoint='{5}' WHERE ID='{6}'";
|
|
sql = string.Format(sql, queryParam["BCGroupID"].ToString(), queryParam["BRGroupID"].ToString(), queryParam["Enable"].ToString(), MUSER, MUSERNAME, WorkPoint, queryParam["ID"].ToString());
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除料品不良信息
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteInventoryBadGroup(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.ICSInventoryBadGroup WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
//库位导入
|
|
public string SetData_PR(String savePath)
|
|
{
|
|
//数据获取
|
|
try
|
|
{
|
|
int index = 1;
|
|
string msg = "";
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
SqlConnection conn = SqlHelper.GetDataCenterConn();
|
|
string sql = "";
|
|
int count = 0;
|
|
DataTable data = FileToExcel.ExcelToTable(savePath);
|
|
foreach (DataRow dr in data.Rows)
|
|
{
|
|
index++;
|
|
var StackCode = "";
|
|
var StackName = "";
|
|
//string GUID = Guid.NewGuid().ToString();
|
|
string KuFang = dr["库房编码"].ToString().Trim().ToUpper();
|
|
string Qu = dr["区"].ToString().Trim().ToUpper();
|
|
string Pai = dr["排"].ToString().Trim().ToUpper();
|
|
string Jia = dr["货架"].ToString().Trim().ToUpper();
|
|
string Ceng = dr["层"].ToString().Trim().ToUpper();
|
|
string Ge = dr["格"].ToString().Trim().ToUpper();
|
|
if (KuFang == "" || KuFang == null)
|
|
{
|
|
throw new Exception("第 " + index + " 行库房编码不能为空!");
|
|
}
|
|
if (Qu == "" && Pai == "" && Jia == "" && Ceng == "" && Ge == "")
|
|
{
|
|
throw new Exception("第 " + index + " 区、排、货架、层、格至少填写一项!");
|
|
}
|
|
string sqlWH = @"select ID from ICSWarehouse where WarehouseCode='{0}' and WorkPoint='{1}'";
|
|
sqlWH = string.Format(sqlWH, KuFang, WorkPoint);
|
|
DataTable dd = SqlHelper.CmdExecuteDataTable(sqlWH);
|
|
if (dd == null || dd.Rows.Count <= 0)
|
|
{
|
|
throw new Exception("库房编码: " + KuFang + " 不存在!");
|
|
}
|
|
string WHID = dd.Rows[0]["ID"].ToString();
|
|
StackCode = KuFang;
|
|
StackName = KuFang + "仓库";
|
|
if (Qu != "")
|
|
{
|
|
StackCode += "-" + Qu;
|
|
StackName += Qu + "区";
|
|
}
|
|
if (Pai != "")
|
|
{
|
|
StackCode += "-" + Pai;
|
|
StackName += Pai + "排";
|
|
}
|
|
if (Jia != "")
|
|
{
|
|
StackCode += "-" + Jia;
|
|
StackName += Jia + "货架";
|
|
}
|
|
if (Ceng != "")
|
|
{
|
|
StackCode += "-" + Ceng;
|
|
StackName += Ceng + "层";
|
|
}
|
|
if (Ge != "")
|
|
{
|
|
StackCode += "-" + Ge;
|
|
StackName += Ge + "格";
|
|
}
|
|
string sqls = @"select LocationCode from ICSLocation where LocationCode='{0}' and WorkPoint='{1}'";
|
|
sqls = string.Format(sqls, StackCode, WorkPoint);
|
|
DataTable dnum = SqlHelper.CmdExecuteDataTable(sqls);
|
|
if (dnum != null && dnum.Rows.Count > 0)
|
|
{
|
|
throw new Exception("库位: " + StackCode + " 已存在!");
|
|
}
|
|
else
|
|
{
|
|
sql += @"Insert INto ICSLocation
|
|
( ID, LocationCode, LocationName, WHID, MUSER, MUSERName, MTIME, WorkPoint, EATTRIBUTE1, Region, Row, GoodsShelf, Tier, Grid)
|
|
Values (newid(),'{0}','{1}','{2}','{3}','{4}',getdate(),'{5}','','{6}','{7}','{8}','{9}','{10}')";
|
|
}
|
|
sql = string.Format(sql, StackCode, StackName, WHID, MUSER, MUSERNAME, WorkPoint, Qu, Pai, Jia, Ceng, Ge);
|
|
|
|
}
|
|
count = SqlHelper.CmdExecuteNonQueryLi(sql);
|
|
if (count > 0)
|
|
{
|
|
msg = "导入成功";
|
|
}
|
|
else
|
|
{
|
|
return "无有效的导入数据。";
|
|
|
|
}
|
|
return msg;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return ex.Message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//周转箱导入
|
|
public string SetDataBoxes(String savePath)
|
|
{
|
|
//数据获取
|
|
try
|
|
{
|
|
int index = 1;
|
|
string msg = "";
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
SqlConnection conn = SqlHelper.GetDataCenterConn();
|
|
string sql = "";
|
|
int count = 0;
|
|
DataTable data = FileToExcel.ExcelToTable(savePath);
|
|
foreach (DataRow dr in data.Rows)
|
|
{
|
|
index++;
|
|
string BoxNumber = dr["周转箱编码"].ToString().Trim().ToUpper();
|
|
string BoxName = dr["周转箱名称"].ToString().Trim().ToUpper();
|
|
string Type = dr["类型"].ToString().Trim().ToUpper();
|
|
string Version = dr["型号"].ToString().Trim().ToUpper();
|
|
string Specification = dr["规格"].ToString().Trim().ToUpper();
|
|
string Describe = dr["描述"].ToString().Trim().ToUpper();
|
|
string FirstCleanCycle = dr["第一次清洗周期"].ToString().Trim().ToUpper();
|
|
string SecondCleanCycle = dr["第二次清洗周期"].ToString().Trim().ToUpper();
|
|
string ThirdCleanCycle = dr["第三次清洗周期"].ToString().Trim().ToUpper();
|
|
if (BoxNumber == "" || BoxNumber == null)
|
|
{
|
|
throw new Exception("第 " + index + " 周转箱编码不能为空!");
|
|
}
|
|
if (BoxName == "" || BoxNumber == null)
|
|
{
|
|
throw new Exception("第 " + index + " 周转箱名称不能为空");
|
|
}
|
|
if (Type == "" || Type == null)
|
|
{
|
|
throw new Exception("第 " + index + " 周转类型不能伟空");
|
|
}
|
|
if (FirstCleanCycle == "" || FirstCleanCycle == null|| SecondCleanCycle == "" || SecondCleanCycle == null || ThirdCleanCycle == "" || ThirdCleanCycle == null)
|
|
{
|
|
throw new Exception("第 " + index + "清洗周期不能为空");
|
|
}
|
|
string sqlWH = $@"select id from ICSWorkingCapitalBox where BoxNumber='{BoxNumber}'";
|
|
DataTable dd = SqlHelper.CmdExecuteDataTable(sqlWH);
|
|
if (dd != null && dd.Rows.Count > 0)
|
|
{
|
|
throw new Exception("周转箱编码: " + BoxNumber + " 已存在!");
|
|
}
|
|
sql += $@"INSERT INTO [dbo].[ICSWorkingCapitalBox] ([ID], [BoxNumber], [BoxName], [Type], [Version], [Specification], [Describe], [FirstCleanCycle], [SecondCleanCycle], [ThirdCleanCycle], [MTIME], [MUser], [MUSERName])
|
|
VALUES (NEWID(), '{BoxNumber}', '{BoxName}', '{Type}', '{Version}', '{Specification}', '{Describe}', {FirstCleanCycle}, {SecondCleanCycle}, {ThirdCleanCycle}, GETDATE(), '{MUSER}', '{MUSERNAME}'); ";
|
|
|
|
}
|
|
count = SqlHelper.CmdExecuteNonQueryLi(sql);
|
|
if (count > 0)
|
|
{
|
|
msg = "导入成功";
|
|
}
|
|
else
|
|
{
|
|
return "无有效的导入数据。";
|
|
|
|
}
|
|
return msg;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return ex.Message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//周转箱台账导入
|
|
public string SetDataBoxAccount(String savePath)
|
|
{
|
|
//数据获取
|
|
try
|
|
{
|
|
int index = 1;
|
|
string msg = "";
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
SqlConnection conn = SqlHelper.GetDataCenterConn();
|
|
string sql = "";
|
|
int count = 0;
|
|
DataTable data = FileToExcel.ExcelToTable(savePath);
|
|
foreach (DataRow dr in data.Rows)
|
|
{
|
|
index++;
|
|
string BoxNumber = dr["周转箱编码"].ToString().Trim().ToUpper();
|
|
string BoxName = dr["名称"].ToString().Trim().ToUpper();
|
|
string BoxCode = dr["周转箱代码"].ToString().Trim().ToUpper();
|
|
string Describe = dr["描述"].ToString().Trim().ToUpper();
|
|
if (BoxNumber == "" || BoxNumber == null)
|
|
{
|
|
throw new Exception("第 " + index + " 周转箱编码不能为空!");
|
|
}
|
|
if (BoxName == "" || BoxNumber == null)
|
|
{
|
|
throw new Exception("第 " + index + " 周转箱名称不能为空");
|
|
}
|
|
if (BoxCode == "" || BoxCode == null)
|
|
{
|
|
throw new Exception("第 " + index + " 周转代码不能伟空");
|
|
}
|
|
string sqlWH = $@"select id from ICSWorkingCapitalBox where BoxNumber='{BoxNumber}'";
|
|
DataTable dd = SqlHelper.CmdExecuteDataTable(sqlWH);
|
|
if (dd == null || dd.Rows.Count <= 0)
|
|
{
|
|
throw new Exception("周转箱编码: " + BoxNumber + " 不存在!");
|
|
}
|
|
string sqlCode = $@"select id from ICSWorkingCapitalBoxAccount where BoxCode='{BoxCode}'";
|
|
DataTable code = SqlHelper.CmdExecuteDataTable(sqlCode);
|
|
if (code != null && code.Rows.Count > 0)
|
|
{
|
|
throw new Exception("周转箱代码: " + BoxCode + " 已存在!");
|
|
}
|
|
sql += $@"INSERT INTO [dbo].[ICSWorkingCapitalBoxAccount] ([ID], [BoxCode], [BoxNumber], [BoxName], [States], [Describe], [DailyUses], [TotalUses], [TotalClearn], [MUser], [MUSERName], [MTIME]) VALUES (NEWID(), '{BoxCode}', '{BoxNumber}', '{BoxName}', '正常', '{Describe}',0, 0, 0, '{MUSER}', '{MUSERNAME}', GETDATE());";
|
|
|
|
}
|
|
count = SqlHelper.CmdExecuteNonQueryLi(sql);
|
|
if (count > 0)
|
|
{
|
|
msg = "导入成功";
|
|
}
|
|
else
|
|
{
|
|
return "无有效的导入数据。";
|
|
|
|
}
|
|
return msg;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return ex.Message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//模具档案导入
|
|
public string SetDataMould(String savePath)
|
|
{
|
|
//数据获取
|
|
try
|
|
{
|
|
int index = 1;
|
|
string msg = "";
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
SqlConnection conn = SqlHelper.GetDataCenterConn();
|
|
string sql = "";
|
|
int count = 0;
|
|
DataTable data = FileToExcel.ExcelToTable(savePath);
|
|
foreach (DataRow dr in data.Rows)
|
|
{
|
|
index++;
|
|
string MouldNumber = dr["模具编码"].ToString().Trim().ToUpper();
|
|
string MouldName = dr["模具名称"].ToString().Trim().ToUpper();
|
|
string Type = dr["类型"].ToString().Trim().ToUpper();
|
|
string Specification = dr["规格"].ToString().Trim().ToUpper();
|
|
string Unit = dr["单位"].ToString().Trim().ToUpper();
|
|
string Phone = dr["联系电话"].ToString().Trim().ToUpper();
|
|
if (MouldNumber == "" || MouldNumber == null)
|
|
{
|
|
throw new Exception("第 " + index + " 模具编码不能为空!");
|
|
}
|
|
if (MouldName == "" || MouldName == null)
|
|
{
|
|
throw new Exception("第 " + index + " 模具名称不能为空");
|
|
}
|
|
if (Type == "" || Type == null)
|
|
{
|
|
throw new Exception("第 " + index + " 类型不能伟空");
|
|
}
|
|
if (Specification == "" || Specification == null)
|
|
{
|
|
throw new Exception("第 " + index + "规格不能为空!");
|
|
}
|
|
if (Unit == "" || Unit == null)
|
|
{
|
|
throw new Exception("第 " + index + " 单位不能为空");
|
|
}
|
|
|
|
string sqlWH = $@"select id from ICSMould where MouldNumber='{MouldNumber}'";
|
|
DataTable dd = SqlHelper.CmdExecuteDataTable(sqlWH);
|
|
if (dd != null && dd.Rows.Count > 0)
|
|
{
|
|
throw new Exception("模具编码: " + MouldNumber + " 已存在!");
|
|
}
|
|
|
|
sql += $@"INSERT INTO [dbo].[ICSMould] ([ID], [MouldNumber], [MouldName], [Type], [Specification], [Unit], [MTIME], [MUser], [MUSERName], [EATTRIBUTE1]) VALUES (NEWID(), '{MouldNumber}', '{MouldName}', '{Type}', '{Specification}', '{Unit}',GETDATE(), '{MUSER}', '{MUSERNAME}','{Phone}');";
|
|
|
|
}
|
|
count = SqlHelper.CmdExecuteNonQueryLi(sql);
|
|
if (count > 0)
|
|
{
|
|
msg = "导入成功";
|
|
}
|
|
else
|
|
{
|
|
return "无有效的导入数据。";
|
|
|
|
}
|
|
return msg;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return ex.Message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//模具台账导入
|
|
public string SetDataMouldAccount(String savePath)
|
|
{
|
|
//数据获取
|
|
try
|
|
{
|
|
int index = 1;
|
|
string msg = "";
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
SqlConnection conn = SqlHelper.GetDataCenterConn();
|
|
string sql = "";
|
|
int count = 0;
|
|
DataTable data = FileToExcel.ExcelToTable(savePath);
|
|
foreach (DataRow dr in data.Rows)
|
|
{
|
|
index++;
|
|
string MouldNumber = dr["模具编码"].ToString().Trim().ToUpper();
|
|
string MouldName = dr["模具名称"].ToString().Trim().ToUpper();
|
|
string Status = dr["状态"].ToString().Trim().ToUpper();
|
|
string MouldCode = dr["模具代码"].ToString().Trim().ToUpper();
|
|
string Limit = dr["下限值"].ToString().Trim().ToUpper();
|
|
string Upper = dr["上限值"].ToString().Trim().ToUpper();
|
|
if (MouldNumber == "" || MouldNumber == null)
|
|
{
|
|
throw new Exception("第 " + index + " 模具编码不能为空!");
|
|
}
|
|
if (MouldName == "" || MouldName == null)
|
|
{
|
|
throw new Exception("第 " + index + " 模具名称不能为空");
|
|
}
|
|
if (Status == "" || Status == null)
|
|
{
|
|
throw new Exception("第 " + index + " 状态不能为空");
|
|
}
|
|
if (MouldCode == "" || MouldCode == null)
|
|
{
|
|
throw new Exception("第 " + index + "模具代码不能为空!");
|
|
}
|
|
if (Limit == "" || Limit == null)
|
|
{
|
|
throw new Exception("第 " + index + " 上限不能为空");
|
|
}
|
|
if (Upper == "" || Upper == null)
|
|
{
|
|
throw new Exception("第 " + index + " 下限不能为空");
|
|
}
|
|
|
|
string sqlWH = $@"select id from ICSMould where MouldNumber='{MouldNumber}'";
|
|
DataTable dd = SqlHelper.CmdExecuteDataTable(sqlWH);
|
|
if (dd == null || dd.Rows.Count <= 0)
|
|
{
|
|
throw new Exception("模具编码: " + MouldNumber + " 不存在!");
|
|
}
|
|
string salCode = $@"select id from ICSMouldAccount where MouldCode='{MouldCode}'";
|
|
DataTable ddCode = SqlHelper.CmdExecuteDataTable(salCode);
|
|
if (ddCode != null && ddCode.Rows.Count > 0)
|
|
{
|
|
throw new Exception("模具代码: " + MouldNumber + " 已存在!");
|
|
}
|
|
|
|
sql += $@"INSERT INTO [dbo].[ICSMouldAccount] ([ID], [MouldCode], [MouldNumber], [MouldName], [MajorStates], [SubStates], [UpperLimit], [LowerLimit], [DailyUses], [TotalUses], [Users], [UserDate], [Picture], [MUser], [MUSERName], [MTIME]) VALUES (NEWID(), '{MouldCode}', '{MouldNumber}', '{MouldName}', '{Status}', null, {Upper}, {Limit}, 0, 0, null, null, null, '{MUSER}', '{MUSERNAME}', GETDATE());";
|
|
}
|
|
count = SqlHelper.CmdExecuteNonQueryLi(sql);
|
|
if (count > 0)
|
|
{
|
|
msg = "导入成功";
|
|
}
|
|
else
|
|
{
|
|
return "无有效的导入数据。";
|
|
|
|
}
|
|
return msg;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return ex.Message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
///启用的料品库位绑定关系
|
|
/// </summary>
|
|
public string EnableInventoryLocation(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(@"update ICSInventoryLocation set Enable='1' where ID in ({0}) and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
///禁用的料品库位绑定关系
|
|
/// </summary>
|
|
public string ForbiddenInventoryLocation(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(@"update ICSInventoryLocation set Enable='0' where ID in ({0}) and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
///启用的料品仓库绑定关系
|
|
/// </summary>
|
|
public string EnableBatchEnable(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(@"update ICSInventoryBatchEnable set BatchEnable='1' where ID in ({0}) and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
///禁用的料品仓库绑定关系
|
|
/// </summary>
|
|
public string ForbiddenBatchEnable(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(@"update ICSInventoryBatchEnable set BatchEnable='0' where ID in ({0}) and WorkPoint='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
public string CreateLableDataSource(string Sys_LableDataSource)
|
|
{
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
string SqlTxt = "";
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(Sys_LableDataSource);
|
|
foreach (var item in res)
|
|
{
|
|
JObject jo = (JObject)item;
|
|
if (jo["DbParas"].ToString().Trim() != "")
|
|
{
|
|
string[] dbvs = jo["DbParas"].ToString().Trim().Split(',');
|
|
List<string> vs = new List<string>();
|
|
foreach (string s in dbvs)
|
|
{
|
|
if (!string.IsNullOrEmpty(s))
|
|
{
|
|
vs.Add(s);
|
|
}
|
|
}
|
|
SqlTxt = string.Format(jo["FormatSqlTxt"].ToString(), vs.ToArray());
|
|
}
|
|
else
|
|
{
|
|
SqlTxt = jo["FormatSqlTxt"].ToString();
|
|
}
|
|
|
|
sql += @"INSERT INTO dbo.Sys_LableDataSource
|
|
(ID,WorkPointCode,OtherDataBaseID,WorkPointDataFlag,SysDataFlag,SqlTxt,SourceName,FormatSqlTxt,Paras,DbParas,LinkCols,CreateUserID,CreateDate,ModifyUserID,ModifyDate,Link2Cols )
|
|
Values(NEWID(),'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}',getdate(),'{11}',getdate(),'{12}')";
|
|
sql = string.Format(sql, WorkPoint, jo["OtherDataBaseID"].ToString(), jo["WorkPointDataFlag"].ToString(), jo["SysDataSourceFlag"].ToString(), SqlTxt, jo["SourceName"].ToString(), jo["FormatSqlTxt"].ToString(), jo["Paras"].ToString(), jo["DbParas"].ToString(), jo["LinkCols"].ToString(), MUSER, MUSER, jo["Link2Cols"].ToString());
|
|
}
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//throw new Exception(ex.Message);
|
|
msg = ex.Message;
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
|
|
public DataTable GetTXT(string ID)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"SELECT
|
|
ID,
|
|
WorkPointCode,
|
|
OtherDataBaseID,
|
|
WorkPointDataFlag,
|
|
SysDataFlag,
|
|
SqlTxt,
|
|
SourceName,
|
|
FormatSqlTxt,
|
|
Paras,
|
|
DbParas,
|
|
LinkCols,
|
|
CreateUserID,
|
|
CreateDate,
|
|
ModifyUserID,
|
|
ModifyDate,
|
|
Link2Cols
|
|
FROM
|
|
dbo.Sys_LableDataSource where ID='" + ID + "'";
|
|
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
public string updateLableDataSource(string Sys_LableDataSource)
|
|
{
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
string SqlTxt = "";
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(Sys_LableDataSource);
|
|
foreach (var item in res)
|
|
{
|
|
JObject jo = (JObject)item;
|
|
if (jo["DbParas"].ToString().Trim() != "")
|
|
{
|
|
string[] dbvs = jo["DbParas"].ToString().Trim().Split(',');
|
|
List<string> vs = new List<string>();
|
|
foreach (string s in dbvs)
|
|
{
|
|
if (!string.IsNullOrEmpty(s))
|
|
{
|
|
vs.Add(s);
|
|
}
|
|
}
|
|
SqlTxt = string.Format(jo["FormatSqlTxt"].ToString(), vs.ToArray());
|
|
}
|
|
else
|
|
{
|
|
SqlTxt = jo["FormatSqlTxt"].ToString();
|
|
}
|
|
|
|
sql += @"UPDATE dbo.Sys_LableDataSource set WorkPointCode='{0}',OtherDataBaseID='{1}',WorkPointDataFlag='{2}',SysDataFlag='{3}',SqlTxt='{4}',SourceName='{5}',FormatSqlTxt='{6}',Paras='{7}',DbParas='{8}',LinkCols='{9}',ModifyUserID='{10}',ModifyDate=getdate(),Link2Cols='{11}' WHERE ID='{12}'";
|
|
sql = string.Format(sql, WorkPoint, jo["OtherDataBaseID"].ToString(), jo["WorkPointDataFlag"].ToString(), jo["SysDataSourceFlag"].ToString(), SqlTxt, jo["SourceName"].ToString(), jo["FormatSqlTxt"].ToString(), jo["Paras"].ToString(), jo["DbParas"].ToString(), jo["LinkCols"].ToString(), MUSER, jo["Link2Cols"].ToString(), jo["ID"].ToString());
|
|
}
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
public string DeleteLableDataSource(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.Sys_LableDataSource WHERE ID IN ({0}) ", keyValue.TrimEnd(','));
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
|
|
public DataTable GetLableType()
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
string sql = @"
|
|
select '' as F_ItemCode,'' as F_ItemName
|
|
union all
|
|
SELECT DISTINCT a.F_ItemCode,isnull(a.F_ItemName,'') as F_ItemName FROM dbo.Sys_SRM_ItemsDetail a left join Sys_SRM_Items b on a.F_ItemId=b.F_Id where b.F_EnCode='BQ001'";
|
|
string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
|
|
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
public DataTable GetSys_LablesID()
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
string sql = @"
|
|
select '' as ID,'' as LableName
|
|
union all
|
|
select distinct ID,LableName from Sys_Lables";
|
|
string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
|
|
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
public string CreateLables(string txtLableName, string sel_LableType, string sel_LableSourceID)
|
|
{
|
|
string UserId = NFine.Code.OperatorProvider.Provider.GetCurrent().UserId;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
|
|
string LableCode = "";
|
|
string SqlTxt = string.Format(@"SELECT MAX(A.LableCode) AS LableCode FROM Sys_Lables A "); ;
|
|
DataSet ds = SqlHelper.GetDataSetBySql(SqlTxt);
|
|
DataTable dts = ds.Tables[0];
|
|
if (dts != null && dts.Rows.Count > 0)
|
|
{
|
|
string lot = dts.Rows[0]["LableCode"].ToString();
|
|
LableCode = (Convert.ToInt64(lot) + 1).ToString().PadLeft(5, '0');
|
|
}
|
|
else
|
|
{
|
|
LableCode = "00001";
|
|
}
|
|
sql += @" INSERT INTO dbo.Sys_Lables
|
|
(ID,WorkPointCode,LableType,LableCode,LableName,LableXml,LableSourceID,CreateUserID,CreateDate,ModifyUserID,ModifyDate,FileAddress )
|
|
Values(NEWID(),'{0}','{1}','{2}','{3}','','{4}','{5}',getdate(),'{6}',getdate(),'')";
|
|
sql = string.Format(sql, WorkPoint, sel_LableType, LableCode, txtLableName, sel_LableSourceID, UserId, UserId);
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
|
|
public DataTable GetLabelTXT(string ID)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"select ID,WorkPointCode,LableType,LableCode,LableName,LableXml,LableSourceID,CreateUserID,CreateDate,ModifyUserID,ModifyDate,FileAddress from Sys_Lables where ID='" + ID + "'";
|
|
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
public string updateLables(string ID, string txtLableName, string sel_LableType, string sel_LableSourceID)
|
|
{
|
|
string UserId = NFine.Code.OperatorProvider.Provider.GetCurrent().UserId;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
sql += @"update Sys_Lables set LableType='{0}' ,LableName='{1}' ,LableSourceID='{2}',ModifyUserID='{3}',ModifyDate=getdate() where ID='{4}'";
|
|
sql = string.Format(sql, sel_LableType, txtLableName, sel_LableSourceID, UserId, ID);
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
public string DeleteICSLabelTemplate(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.Sys_Lables WHERE ID IN ({0}) ", keyValue.TrimEnd(','));
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
//获取父容器
|
|
public DataTable GetContainerID()
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
string sql = @"
|
|
select '' as ID,'' as ContainerName
|
|
union all
|
|
SELECT DISTINCT a.ID,a.ContainerName FROM dbo.ICSContainer a ";
|
|
string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
|
|
if (role != "admin")
|
|
{
|
|
sql += " and b.WorkPoint in(" + WorkPoint + ")";
|
|
}
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
//获取父容器
|
|
public DataTable GetContainerType()
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
string sql = @"
|
|
select '' as F_ItemName,'' as F_ItemCode
|
|
union all
|
|
SELECT a.F_ItemName,a.F_ItemCode FROM Sys_SRM_ItemsDetail a
|
|
LEFT JOIN Sys_SRM_Items b ON a.F_ItemId = b.F_Id
|
|
WHERE b.F_EnCode = 'ContainerType' and a.F_EnabledMark='1' ";
|
|
string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
|
|
if (role != "admin")
|
|
{
|
|
sql += " and b.WorkPoint in(" + WorkPoint + ")";
|
|
}
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
public int UpLoadLabelFile(string ID, string fileName)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
string sql = "";
|
|
sql = string.Format(@"update Sys_Lables set FileAddress='{0}'
|
|
where ID='{1}'",
|
|
fileName, ID);
|
|
|
|
StringBuilder Str = new StringBuilder(sql);
|
|
return Repository().ExecuteBySql(Str);
|
|
}
|
|
|
|
public int UpLoadFiles(string LotNo, string fileName)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
string sql = "";
|
|
sql = string.Format(@"update ICSInspection set FileName='{0}'
|
|
where LotNo='{1}' and Enable='1'",
|
|
fileName, LotNo);
|
|
|
|
StringBuilder Str = new StringBuilder(sql);
|
|
return Repository().ExecuteBySql(Str);
|
|
}
|
|
|
|
//包装容器
|
|
public DataTable GetSendContainer(ref Pagination jqgridparam, string queryJson)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"select top 0 ID,ContainerID,ContainerCode,ContainerName,Memo,MUSER,MUSERName,MTIME,WorkPoint from ICSContainer";
|
|
sql += " WHERE 1=1";
|
|
|
|
sql = string.Format(sql);
|
|
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
public DataTable GetContainerInfo(string Code)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @" select ID,ContainerID,ContainerCode,ContainerName,Memo,MUSER,MUSERName,MTIME,WorkPoint from ICSContainer where ContainerCode='{0}'";
|
|
sql = string.Format(sql, Code);
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
public DataTable GetBindContainerID(string SireCode)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @" select ID from ICSContainer where ContainerCode='{0}'";
|
|
sql = string.Format(sql, SireCode);
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
|
|
public string BindingContainerID(string keyValue)
|
|
{
|
|
// string msg = "";
|
|
// try
|
|
// {
|
|
// string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
// string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
// string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
// string sql = string.Empty;
|
|
// JArray res = (JArray)JsonConvert.DeserializeObject(ICSMTDOC);
|
|
// foreach (var item in res)
|
|
// {
|
|
// JObject jo = (JObject)item;
|
|
// sql += @"
|
|
// IF NOT EXISTS(SELECT ContainerCode FROM ICSContainer WHERE ContainerCode='{1}' )
|
|
// BEGIN
|
|
// RAISERROR('容器:{1} 不存在!',16,1);
|
|
// RETURN
|
|
// END
|
|
// IF EXISTS(select ContainerID from ICSContainer where ContainerCode='{1}' and isnull(ContainerID,'')<>'')
|
|
// BEGIN
|
|
// RAISERROR('容器:{1},已绑定父容器!',16,1);
|
|
// RETURN
|
|
// END
|
|
// update ICSContainer set ContainerID='{0}' WHERE ContainerCode = '{1}' and WorkPoint ='{2}'";
|
|
// sql = string.Format(sql, SireID, jo["ContainerCode"].ToString(), WorkPoint);
|
|
// }
|
|
|
|
// if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
// {
|
|
|
|
// }
|
|
// else
|
|
// {
|
|
// msg = "绑定失败";
|
|
// }
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// msg = ex.Message;
|
|
// }
|
|
|
|
// return msg;
|
|
string msg = "";
|
|
string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "ICSContainerCon/Create";
|
|
string result = DeciliterApp.HttpPost(APIURL, keyValue);
|
|
JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
|
|
string MessAge = Obj["Message"].ToString();
|
|
string Success = Obj["Success"].ToString();
|
|
if (Success.ToUpper() == "FALSE")
|
|
{
|
|
msg = MessAge;
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
//包装容器关联条码
|
|
public DataTable GetSendContainerLot(ref Pagination jqgridparam, string queryJson)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"
|
|
select top 0 a.ID, a.LotNo,a.InvCode,b.InvName,b.InvStd,b.InvUnit, a.ProductDate,a.Quantity from ICSInventoryLot a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint";
|
|
|
|
sql = string.Format(sql);
|
|
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 回车后获取信息
|
|
/// </summary>
|
|
/// <param name="LotNo"></param>
|
|
/// <returns>20230719 lacy.xu modifly 增加自由项</returns>
|
|
public DataTable GetContainerLotInfo(string LotNo)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @" select a.ID, a.LotNo,a.InvCode,b.InvName,b.InvStd,b.InvUnit, a.ProductDate,a.Quantity
|
|
,c.ProjectCode,c.BatchCode,Version,Brand,c.cFree1,c.cFree2,c.cFree3,c.cFree4,c.cFree5,c.cFree6,c.cFree7
|
|
,c.cFree8,c.cFree9,c.cFree10
|
|
from ICSInventoryLot a
|
|
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSExtension c ON a.ExtensionID=c.ID AND a.WorkPoint=c.WorkPoint
|
|
where a.LotNo='{0}'";
|
|
sql = string.Format(sql, LotNo);
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
public string BindingContainerLotID(string keyValue)
|
|
{
|
|
// string msg = "";
|
|
// try
|
|
// {
|
|
// string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
// string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
// string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
// string sql = string.Empty;
|
|
// JArray res = (JArray)JsonConvert.DeserializeObject(ICSMTDOC);
|
|
// foreach (var item in res)
|
|
// {
|
|
// JObject jo = (JObject)item;
|
|
// sql += @"
|
|
// IF NOT EXISTS(SELECT ContainerCode FROM ICSContainer WHERE ContainerCode='{5}')
|
|
// BEGIN
|
|
// RAISERROR('容器:{5} 不存在!',16,1);
|
|
// RETURN
|
|
// END
|
|
// IF NOT EXISTS(select LotNo from ICSInventoryLot where LotNo='{1}')
|
|
// BEGIN
|
|
// RAISERROR('条码:{1},不存在!',16,1);
|
|
// RETURN
|
|
// END
|
|
// IF EXISTS(select LotNo from ICSContainerLot where LotNo ='{1}')
|
|
// BEGIN
|
|
// RAISERROR('条码:{1},已绑定容器!',16,1);
|
|
// RETURN
|
|
// END
|
|
// INSERT INTO ICSContainerLot
|
|
// (ID,ContainerID,LotNo,MUSER,MUSERName,WorkPoint,MTIME )
|
|
// Values(NEWID(),'{0}','{1}','{2}','{3}','{4}',getdate())";
|
|
// sql = string.Format(sql, SireID, jo["LotNo"].ToString(), MUSER, MUSERNAME, WorkPoint, SireCode);
|
|
// }
|
|
|
|
// if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
// {
|
|
|
|
// }
|
|
// else
|
|
// {
|
|
// msg = "绑定失败";
|
|
// }
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// msg = ex.Message;
|
|
// }
|
|
|
|
// return msg;
|
|
string msg = "";
|
|
string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "ICSContainerLot/Create";
|
|
string result = DeciliterApp.HttpPost(APIURL, keyValue);
|
|
JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
|
|
string MessAge = Obj["Message"].ToString();
|
|
string Success = Obj["Success"].ToString();
|
|
if (Success.ToUpper() == "FALSE")
|
|
{
|
|
msg = MessAge;
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 删除站点
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteWorkPoint(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.sys_WorkPoint WHERE ID IN ({0}) ", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增站点
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string InsertWorkPoint(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
string pwd = SqlHelper.ToMd5(queryParam["DataBasePwd"].ToString());
|
|
sql = @"INSERT INTO dbo.sys_WorkPoint
|
|
( ID ,WorkPointCode ,WorkPointName ,ServerName,DataBaseName,DataBaseUser,DataBasePwd, StartFlag,CreateDate,CreateUserCode )
|
|
Values(NEWID(),'{0}','{1}','{2}','{3}','{4}','{5}','{6}',GETDATE(),'{7}')
|
|
";
|
|
sql = string.Format(sql, queryParam["WorkPointCode"].ToString(), queryParam["WorkPointName"].ToString(), queryParam["ServerName"].ToString(),
|
|
queryParam["DataBaseName"].ToString(), queryParam["DataBaseUser"].ToString(), pwd, queryParam["StartFlag"].ToString(), MUSER);
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改站点
|
|
/// </summary>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public string UpdateWorkPoint(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
|
|
string pwd = SqlHelper.ToMd5(queryParam["DataBasePwd"].ToString());
|
|
string sql = string.Empty;
|
|
sql = @"UPDATE dbo.sys_WorkPoint set WorkPointCode='{0}',WorkPointName='{1}',ServerName='{2}',DataBaseName='{3}',StartFlag='{4}'
|
|
,DataBaseUser='{5}',DataBasePwd='{6}',ModifyDate=GETDATE(),ModifyUserCode='{7}' WHERE ID='{8}'";
|
|
sql = string.Format(sql, queryParam["WorkPointCode"].ToString(), queryParam["WorkPointName"].ToString(), queryParam["ServerName"].ToString(),
|
|
queryParam["DataBaseName"].ToString(), queryParam["StartFlag"].ToString(), queryParam["DataBaseUser"].ToString(), pwd
|
|
, MUSER, queryParam["ID"].ToString());
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
public Sys_WorkPoint GetWorkPoint(string Id)
|
|
{
|
|
Sys_WorkPoint model = new Sys_WorkPoint();
|
|
string sql = string.Empty;
|
|
sql = string.Format(@"SELECT ID,
|
|
WorkPointCode,
|
|
WorkPointName,
|
|
ServerName,
|
|
DataBaseName,
|
|
DataBaseUser,
|
|
DataBasePwd,
|
|
StartFlag,
|
|
CreateUserCode,
|
|
CreateDate,
|
|
ModifyUserCode,
|
|
ModifyDate
|
|
FROM Sys_WorkPoint
|
|
WHERE ID='{0}'", Id);
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
model.ID = dt.Rows[0]["ID"].ToString();
|
|
model.WorkPointCode = dt.Rows[0]["WorkPointCode"].ToString();
|
|
model.WorkPointName = dt.Rows[0]["WorkPointName"].ToString();
|
|
model.ServerName = dt.Rows[0]["ServerName"].ToString();
|
|
model.DataBaseName = dt.Rows[0]["DataBaseName"].ToString();
|
|
model.DataBaseUser = dt.Rows[0]["DataBaseUser"].ToString();
|
|
model.DataBasePwd = SqlHelper.FromMd5(dt.Rows[0]["DataBasePwd"].ToString());
|
|
model.StartFlag = dt.Rows[0]["StartFlag"].ToString();
|
|
}
|
|
return model;
|
|
}
|
|
|
|
|
|
public DataTable GetICSInventoryLotInfo(string ID)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @" SELECT a.ID,
|
|
a.LotNo,
|
|
a.InvCode,
|
|
a.ProductDate,
|
|
a.ExpirationDate,
|
|
a.Quantity,
|
|
a.Amount,
|
|
a.ExtensionID,
|
|
a.Type,
|
|
a.PrintTimes,
|
|
a.LastPrintUser,
|
|
a.LastPrintTime,
|
|
a.MUSER,
|
|
a.MUSERName,
|
|
a.MTIME,
|
|
a.WorkPoint,
|
|
a.EATTRIBUTE1,
|
|
b.InvName,
|
|
b.InvUnit,
|
|
c.Enable
|
|
FROM
|
|
dbo.ICSInventoryLot a left join ICSInventory b on a.InvCode=b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
left join ICSInspection c on a.LotNo=c.LotNo AND a.WorkPoint=b.WorkPoint and c.Enable='1'
|
|
WHERE a.ID='" + ID + "'";
|
|
sql += " and a.WorkPoint='" + WorkPoint + "'";
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
public int UpdateExpirationDate(string ID, string ExpirationDate, string Inv,string LotNo, string InvCode, string Quantity)
|
|
{
|
|
decimal QualifiedQuantity = 0;
|
|
decimal UnqualifiedQuantity = 0;
|
|
if (Inv=="1"){QualifiedQuantity = Convert.ToDecimal(Quantity);}else {UnqualifiedQuantity = Convert.ToDecimal(Quantity); }
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string sqls = string.Empty;
|
|
sqls = @"update ICSInspection set Enable='0' WHERE LotNO='{0}' and Enable='1' and WorkPoint='{1}'";
|
|
sqls = string.Format(sqls, LotNo, WorkPoint);
|
|
SqlHelper.CmdExecuteNonQueryLi(sqls);
|
|
|
|
string sql = string.Empty;
|
|
sql += @"UPDATE ICSInventoryLot SET ExpirationDate='{0}' where ID='{1}' AND WorkPoint='{2}'";
|
|
sql += @"INSERT INTO dbo.ICSInspection
|
|
( ID ,LotNo ,InvCode ,Quantity,QualifiedQuantity,UnqualifiedQuantity,WaiveQuantity,Type,Result,ExpirationDate,Enable,MUSER,MUSERName,MTIME,WorkPoint )
|
|
Values(NEWID(),'{3}','{4}','{5}','{6}','{7}',0,'4','{8}','{0}','1','{9}','{10}',GETDATE(),'{2}')";
|
|
sql = string.Format(sql, ExpirationDate,ID, WorkPoint, LotNo, InvCode, Quantity, QualifiedQuantity, UnqualifiedQuantity, Inv, MUSER, MUSERNAME);
|
|
int count = SqlHelper.CmdExecuteNonQueryLi(sql);
|
|
return count;
|
|
}
|
|
|
|
//修改多语言
|
|
public string UpdateSys_Language(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
|
|
string sql = string.Empty;
|
|
sql = @"UPDATE Sys_Language set Code='{0}',CnValue='{1}',TwValue='{2}',EnValue='{3}' WHERE ID='{4}'";
|
|
sql = string.Format(sql, queryParam["Code"].ToString(), queryParam["CnValue"].ToString(), queryParam["TwValue"].ToString(), queryParam["EnValue"].ToString(), queryParam["ID"].ToString());
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
//新增多语言
|
|
public string InsertSys_Language(string keyValue)
|
|
{
|
|
var queryParam = keyValue.ToJObject();
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
sql = @" IF EXISTS(SELECT * FROM Sys_Language WHERE Code='{0}' )
|
|
begin
|
|
RAISERROR('代码重复请重新输入!',16,1)
|
|
end
|
|
INSERT INTO Sys_Language
|
|
( ID ,Code ,CnValue ,TwValue,EnValue )
|
|
Values(NEWID(),'{0}','{1}','{2}','{3}')
|
|
";
|
|
sql = string.Format(sql, queryParam["Code"].ToString(), queryParam["CnValue"].ToString(), queryParam["TwValue"].ToString(), queryParam["EnValue"].ToString());
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "新增失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
|
|
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();
|
|
}
|
|
|
|
|
|
|
|
public DataTable GetSys_Language(string ID)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"select ID,Code,CnValue,TwValue,EnValue from Sys_Language
|
|
WHERE 1 =1 and ID='" + ID + "' ";
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 删除多语言
|
|
/// </summary>
|
|
/// <param name="keyValue">传入ID</param>
|
|
/// <returns></returns>
|
|
public string DeleteSys_Language(string keyValue)
|
|
{
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
sql = string.Format(@"DELETE FROM Sys_Language WHERE ID IN ({0})", keyValue.TrimEnd(','));
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
//料品检验项目
|
|
public DataTable GetICSInventoryInspectionGroup(ref Pagination jqgridparam, string queryJson)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"select ID,InvCode,GroupCode,GroupName,
|
|
case when Enable='1' then '是' else '否' end as Enable,
|
|
EATTRIBUTE1,EATTRIBUTE2,EATTRIBUTE3,EATTRIBUTE4,EATTRIBUTE5,EATTRIBUTE6,EATTRIBUTE7,EATTRIBUTE8,
|
|
EATTRIBUTE9,EATTRIBUTE10
|
|
MUSER,MUSERName,MTIME,WorkPoint from ICSInventoryInspectionGroup ";
|
|
sql += " WHERE 1=1";
|
|
if (!string.IsNullOrWhiteSpace(queryJson))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
|
|
{
|
|
sql += " and InvCode like '%" + queryParam["InvCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["GroupCode"].ToString()))
|
|
{
|
|
sql += " and GroupCode like '%" + queryParam["GroupCode"].ToString() + "%' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(queryParam["GroupName"].ToString()))
|
|
{
|
|
sql += " and GroupName like '%" + queryParam["GroupName"].ToString() + "%' ";
|
|
}
|
|
}
|
|
sql = string.Format(sql);
|
|
DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
//料品检验项目子表
|
|
public DataTable ICSInventoryInspectionList(string ID, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @" select ID,InvGroupID,ListCode,ListName,Unit,SetValueMax, SetValueMin,
|
|
CASE WHEN Enable=0 THEN '否' else '是' END Enable,
|
|
MUSERName,MTIME,WorkPoint from ICSInventoryInspectionList
|
|
WHERE InvGroupID='" + ID + "'";
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
|
|
|
|
// 删除料品检验项目子表
|
|
|
|
public string DeleteICSInventoryInspectionGroup(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.ICSInventoryInspectionGroup WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
sql += string.Format(@"DELETE FROM dbo.ICSInventoryInspectionList WHERE InvGroupID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
public DataTable Getinv(string invcode, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
DataTable table = new DataTable();
|
|
string wherestr = "";
|
|
if (!string.IsNullOrEmpty(invcode))
|
|
{
|
|
wherestr += " and invcode like '%" + invcode + "%'";
|
|
}
|
|
string sql = "select ID,InvCode,InvName,InvDesc,InvUnit,WorkPoint from ICSInventory where workpoint='" + WorkPoint + "'" + wherestr;
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
|
|
}
|
|
|
|
public DataTable GetGroupCode()
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
|
|
string sql = @"select '' as ID,'' as GroupName
|
|
union all
|
|
SELECT distinct ID,GroupName FROM ICSInspectionGroup where WorkPoint='{0}'";
|
|
sql = string.Format(sql, WorkPoint);
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
public void DeleteINvItem(string ID)
|
|
{
|
|
string sql = "DELETE FROM dbo.ICSInventoryInspectionList WHERE ID='" + ID + "'";
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
}
|
|
|
|
public DataTable GetICSInventoryInspectionList(string ListCode, ref Pagination jqgridparam)
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"select ID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable,MUSERName,MTIME from ICSInventoryInspectionList
|
|
WHERE ListCode='" + ListCode + "' ";
|
|
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
|
|
}
|
|
|
|
|
|
public DataTable GetInspectionListInfo(string ID)
|
|
{
|
|
DataTable dt = new DataTable();
|
|
//var queryParam = queryJson.ToJObject();
|
|
List<DbParameter> parameter = new List<DbParameter>();
|
|
string sql = @"
|
|
select ID,ListCode,ListName,Unit,SetValueMax,SetValueMin, CASE WHEN Enable=0 THEN '否' else '是' END Enable
|
|
from ICSInspectionList where GroupID='{0}'";
|
|
sql = string.Format(sql, ID);
|
|
return Repository().FindTableBySql(sql.ToString());
|
|
}
|
|
|
|
|
|
|
|
//新增
|
|
public void SubICSInventoryInspectionGroupAdd(ICSInventoryInspectionGroup main, string ID, string InvCode)
|
|
{
|
|
string sql = string.Empty;
|
|
string sqls = string.Empty;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string NewID = Common.GuId();
|
|
List<ICSInventoryInspectionGroup> list_Item1 = new List<ICSInventoryInspectionGroup>();
|
|
if (main.arrayShellFabricItem != null)
|
|
{
|
|
list_Item1 = JsonConvert.DeserializeObject<List<ICSInventoryInspectionGroup>>(main.arrayShellFabricItem);
|
|
}
|
|
string connString = SqlHelper.DataCenterConnString;
|
|
SqlConnection conn = new SqlConnection(connString);
|
|
conn.Open();
|
|
SqlTransaction sqlTran = conn.BeginTransaction();
|
|
SqlCommand cmd = new SqlCommand();
|
|
cmd.Transaction = sqlTran;
|
|
cmd.Connection = conn;
|
|
sql = @"
|
|
INSERT INTO dbo.ICSInventoryInspectionGroup
|
|
( ID ,InvCode ,GroupCode ,GroupName ,
|
|
Enable ,MUSER ,MUSERName ,MTIME ,WorkPoint )
|
|
SELECT '{0}','{1}',GroupCode,GroupName,Enable,'{2}','{3}',getdate(),'{4}'
|
|
FROM dbo.ICSInspectionGroup
|
|
WHERE ID='{5}'";
|
|
sql = string.Format(sql, NewID, InvCode, MUSER, MUSERNAME, WorkPoint, ID);
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
foreach (ICSInventoryInspectionGroup Item in list_Item1)
|
|
{
|
|
sqls = @"
|
|
INSERT INTO dbo.ICSInventoryInspectionList
|
|
( ID ,InvGroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable , MTIME,MUSER ,MUSERName ,WorkPoint )
|
|
Values(newid(),'{0}',@ListCode,@ListName,@Unit,@SetValueMax,@SetValueMin,@Enable,GETDATE(),'{1}','{2}','{3}')";
|
|
sqls = string.Format(sqls, NewID, MUSER, MUSERNAME, WorkPoint);
|
|
SqlParameter[] sp_Item = {
|
|
new SqlParameter("@ID",DbType.String){ Value= Item.ID},
|
|
new SqlParameter("@ListCode",DbType.String){ Value= Item.ListCode},
|
|
new SqlParameter("@ListName",DbType.String){ Value= Item.ListName},
|
|
new SqlParameter("@Unit",DbType.String){ Value= Item.Unit},
|
|
new SqlParameter("@SetValueMax",DbType.String){ Value= Item.SetValueMax},
|
|
new SqlParameter("@SetValueMin",DbType.String){ Value= Item.SetValueMin},
|
|
new SqlParameter("@Enable",DbType.String){ Value= Item.Enable},
|
|
|
|
};
|
|
SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
|
|
|
|
}
|
|
cmd.Transaction.Commit();
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
cmd.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
if (conn.State == ConnectionState.Open)
|
|
{
|
|
conn.Close();
|
|
}
|
|
conn.Dispose();
|
|
}
|
|
}
|
|
|
|
|
|
public DataTable GetICSInventoryInspectionList2(string BID)
|
|
{
|
|
string sql = string.Empty;
|
|
DataTable dt = null;
|
|
sql = string.Format(@" select ID,ListCode,ListName,Unit,SetValueMax,SetValueMin, CASE WHEN Enable='1' THEN '是' else '否' END Enable from ICSInventoryInspectionList where InvGroupID='{0}'", BID);
|
|
dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
|
|
//修改
|
|
public void UpdateICSInventoryInspectionGroup(ICSInventoryInspectionGroup main, string BID, string ID, string InvCode)
|
|
{
|
|
string sql = string.Empty;
|
|
string sqls = string.Empty;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
|
|
List<ICSInventoryInspectionGroup> list_Item1 = new List<ICSInventoryInspectionGroup>();
|
|
if (main.arrayShellFabricItem != null)
|
|
{
|
|
list_Item1 = JsonConvert.DeserializeObject<List<ICSInventoryInspectionGroup>>(main.arrayShellFabricItem);
|
|
}
|
|
string connString = SqlHelper.DataCenterConnString;
|
|
SqlConnection conn = new SqlConnection(connString);
|
|
conn.Open();
|
|
SqlTransaction sqlTran = conn.BeginTransaction();
|
|
SqlCommand cmd = new SqlCommand();
|
|
cmd.Transaction = sqlTran;
|
|
cmd.Connection = conn;
|
|
sql = @"update b set b.InvCode='{0}',b.GroupCode=a.GroupCode,b.GroupName=a.GroupName,b.Enable=a.Enable,b.MTIME=GETDATE(),b.MUSER='{1}',b.MUSERName='{2}',b.WorkPoint='{3}' from ICSInspectionGroup a ,ICSInventoryInspectionGroup b where a.ID='{4}' and b.ID='{5}'";
|
|
sql = string.Format(sql, InvCode, MUSER, MUSERNAME, WorkPoint, ID,BID);
|
|
try
|
|
{
|
|
if (SqlHelper.ExecuteNonQuery(sql) > 0)
|
|
{
|
|
foreach (ICSInventoryInspectionGroup Item in list_Item1)
|
|
{
|
|
sqls = @" IF NOT EXISTS(SELECT * FROM ICSInventoryInspectionList WHERE ID=@ID)
|
|
BEGIN
|
|
INSERT INTO dbo.ICSInventoryInspectionList
|
|
( ID ,InvGroupID,ListCode,ListName,Unit,SetValueMax,SetValueMin,Enable , MTIME,MUSER ,MUSERName ,WorkPoint )
|
|
Values(@ID,'{0}',@ListCode,@ListName,@Unit,@SetValueMax,@SetValueMin,@Enable,GETDATE(),'{1}','{2}','{3}')
|
|
END
|
|
ELSE
|
|
BEGIN
|
|
UPDATE dbo.ICSInventoryInspectionList set InvGroupID='{0}',ListCode=@ListCode,ListName=@ListName,Unit=@Unit,SetValueMax=@SetValueMax,SetValueMin=@SetValueMin,Enable=@Enable,MTIME=GETDATE(),MUSER='{1}',MUSERName='{2}',WorkPoint='{3}' WHERE ID=@ID
|
|
end
|
|
";
|
|
sqls = string.Format(sqls, BID, MUSER, MUSERNAME, WorkPoint);
|
|
SqlParameter[] sp_Item = {
|
|
new SqlParameter("@ID",DbType.String){ Value= Item.ID},
|
|
new SqlParameter("@ListCode",DbType.String){ Value= Item.ListCode},
|
|
new SqlParameter("@ListName",DbType.String){ Value= Item.ListName},
|
|
new SqlParameter("@Unit",DbType.String){ Value= Item.Unit},
|
|
new SqlParameter("@SetValueMax",DbType.String){ Value= Item.SetValueMax},
|
|
new SqlParameter("@SetValueMin",DbType.String){ Value= Item.SetValueMin},
|
|
new SqlParameter("@Enable",DbType.String){ Value= Item.Enable},
|
|
|
|
};
|
|
SqlCommandHelper.CmdExecuteNonQuery(sqls, sp_Item, cmd);
|
|
|
|
}
|
|
cmd.Transaction.Commit();
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
cmd.Transaction.Rollback();
|
|
throw new Exception(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
if (conn.State == ConnectionState.Open)
|
|
{
|
|
conn.Close();
|
|
}
|
|
conn.Dispose();
|
|
}
|
|
}
|
|
|
|
|
|
//库位导入
|
|
public string UploadFileInvBadGroup(String savePath)
|
|
{
|
|
//数据获取
|
|
try
|
|
{
|
|
int index = 1;
|
|
string msg = "";
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string MTIME = DateTime.Now.ToString();
|
|
SqlConnection conn = SqlHelper.GetDataCenterConn();
|
|
string sql = "";
|
|
int count = 0;
|
|
DataTable data = FileToExcel.ExcelToTable(savePath);
|
|
foreach (DataRow dr in data.Rows)
|
|
{
|
|
index++;
|
|
var Enable = "";
|
|
string InvCode = dr["料品代码"].ToString().Trim().ToUpper();
|
|
string BCGroupCode = dr["不良代码组代码"].ToString().Trim().ToUpper();
|
|
string BRGroupCode = dr["不良原因组代码"].ToString().Trim().ToUpper();
|
|
string Enables = dr["是否启用"].ToString().Trim().ToUpper();
|
|
|
|
if (InvCode == "" || InvCode == null)
|
|
{
|
|
throw new Exception("第 " + index + " 行料品代码不能为空!");
|
|
}
|
|
if (BCGroupCode == "" || BCGroupCode == null)
|
|
{
|
|
throw new Exception("第 " + index + " 行不良代码组代码不能为空!");
|
|
}
|
|
if (BRGroupCode == "" || BRGroupCode == null)
|
|
{
|
|
throw new Exception("第 " + index + " 行不良原因组代码不能为空!");
|
|
}
|
|
if (Enables == "" || Enables == null)
|
|
{
|
|
throw new Exception("第 " + index + " 行是否启用不能为空!");
|
|
}
|
|
string sqlWH = @"select ID from dbo.ICSInventory where InvCode='{0}' and WorkPoint='{1}'";
|
|
sqlWH += @" select ID from ICSBadCodeGroup where BCGCode='{2}' and WorkPoint='{1}'";
|
|
sqlWH += @" select ID from ICSBadReasonGroup where BRGCode='{3}' and WorkPoint='{1}'";
|
|
sqlWH += @" select a.ID from ICSInventoryBadGroup a
|
|
inner join ICSBadCodeGroup b on a.BCGroupID=b.ID and a.WorkPoint=b.WorkPoint
|
|
inner join ICSBadReasonGroup c on a.BRGroupID=c.ID and a.WorkPoint=b.WorkPoint
|
|
where a.InvCode='{0}' and b.BCGCode='{2}'and c.BRGCode='{3}' and a.WorkPoint='{1}'";
|
|
sqlWH = string.Format(sqlWH, InvCode, WorkPoint, BCGroupCode, BRGroupCode);
|
|
DataSet ds = SqlHelper.GetDataSetBySql(sqlWH);
|
|
|
|
if (ds.Tables[0] == null || ds.Tables[0].Rows.Count <= 0)
|
|
{
|
|
throw new Exception("料品代码: " + InvCode + " 不存在!");
|
|
}
|
|
if (ds.Tables[1] == null || ds.Tables[1].Rows.Count <= 0)
|
|
{
|
|
throw new Exception("不良代码组代码: " + BCGroupCode + " 不存在!");
|
|
}
|
|
if (ds.Tables[2] == null || ds.Tables[2].Rows.Count <= 0)
|
|
{
|
|
throw new Exception("不良原因组代码: " + BRGroupCode + " 不存在!");
|
|
}
|
|
if (ds.Tables[3].Rows.Count > 0)
|
|
{
|
|
throw new Exception("第 " + index + " 行,料品: " + InvCode + " 已绑定相同不良信息!");
|
|
}
|
|
if (Enables=="是")
|
|
{
|
|
Enable = "1";
|
|
}
|
|
else
|
|
{
|
|
Enable = "0";
|
|
}
|
|
|
|
sql += @"INSERT INTO dbo.ICSInventoryBadGroup
|
|
( ID,InvCode,BCGroupID,BRGroupID,Enable,MUSER,MUSERName,MTIME,WorkPoint)
|
|
Values(NEWID(),'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')";
|
|
|
|
sql = string.Format(sql, InvCode, ds.Tables[1].Rows[0]["ID"].ToString(), ds.Tables[2].Rows[0]["ID"].ToString(), Enable, MUSER, MUSERNAME, MTIME, WorkPoint);
|
|
}
|
|
|
|
count = SqlHelper.CmdExecuteNonQueryLi(sql);
|
|
if (count > 0)
|
|
{
|
|
msg = "导入成功";
|
|
}
|
|
else
|
|
{
|
|
return "无有效的导入数据。";
|
|
|
|
}
|
|
return msg;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return ex.Message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 根据ID获取其他站点
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable GetWorkPointNotInID(string WorkPointCode)
|
|
{
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string sql = @"select '' as WorkPointCode,'' as WorkPointName union all
|
|
SELECT WorkPointCode,WorkPointName FROM dbo.Sys_WorkPoint WITH (NOLOCK) WHERE WorkPointCode <>'{0}'
|
|
";
|
|
sql = string.Format(sql, WorkPointCode.TrimEnd(','));
|
|
DataTable dt = SqlHelper.GetDataTableBySql(sql);
|
|
return dt;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string CloneWorkPointByCode(string WorkPoint, string WorkPointCode)
|
|
{
|
|
string msg = "";
|
|
//string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERName = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string sql = string.Empty;
|
|
var ID = Guid.NewGuid();
|
|
//克隆参数配置表
|
|
sql += @"INSERT INTO ICSConfiguration(ID, Code, Name, Enable, Figure, MTIME, MUSER, MUSERName, WorkPoint)
|
|
SELECT newid(),Code,Name,Enable,Figure,getdate(),'{0}','{1}','{2}'
|
|
FROM ICSConfiguration
|
|
where WorkPoint='{3}'
|
|
";
|
|
|
|
//克隆列类型
|
|
sql += @"INSERT INTO ICSType(ID, TableCode, ColumnCode, Code, Name, Enable, MTIME, MUSER, MUSERName, WorkPoint)
|
|
SELECT newid(),TableCode,ColumnCode,Code,Name,Enable,getdate(),'{0}','{1}','{2}'
|
|
FROM ICSType
|
|
where WorkPoint='{3}'
|
|
";
|
|
|
|
//克隆admin
|
|
sql += @"INSERT INTO Sys_SRM_User( F_Id, F_Account, F_RealName,F_NickName,F_HeadIcon,F_Gender,F_Birthday,F_MobilePhone,F_Email,F_WeChat,F_ManagerId,F_SecurityLevel,F_Signature,F_OrganizeId,F_DepartmentId,F_RoleId,F_DutyId,F_IsAdministrator,F_SortCode,F_DeleteMark,F_EnabledMark,F_Description,F_CreatorTime,F_CreatorUserId,F_LastModifyTime,F_LastModifyUserId,F_DeleteTime,F_DeleteUserId,F_Location,F_VenCode)
|
|
SELECT '{4}',F_Account,F_RealName,F_NickName,F_HeadIcon,F_Gender,F_Birthday,F_MobilePhone,F_Email,F_WeChat,F_ManagerId,F_SecurityLevel,F_Signature,F_OrganizeId,F_DepartmentId,F_RoleId,F_DutyId,F_IsAdministrator,F_SortCode,F_DeleteMark,F_EnabledMark,F_Description,getdate(),F_CreatorUserId,F_LastModifyTime,F_LastModifyUserId,F_DeleteTime,F_DeleteUserId,'{2}',F_VenCode
|
|
FROM Sys_SRM_User
|
|
where F_Location='{3}' and F_Account='admin'
|
|
";
|
|
|
|
//克隆admin登陆
|
|
sql += @"INSERT INTO Sys_SRM_UserLogOn( F_Id, F_UserId, F_UserPassword, F_UserSecretkey, F_AllowStartTime, F_AllowEndTime, F_LockStartDate, F_LockEndDate, F_FirstVisitTime, F_PreviousVisitTime, F_LastVisitTime, F_ChangePasswordDate, F_MultiUserLogin, F_LogOnCount, F_UserOnLine, F_Question, F_AnswerQuestion, F_CheckIPAddress, F_Language, F_Theme)
|
|
SELECT '{4}','{4}',F_UserPassword,F_UserSecretkey,F_AllowStartTime,F_AllowEndTime,F_LockStartDate,F_LockEndDate,F_FirstVisitTime,F_PreviousVisitTime,F_LastVisitTime,F_ChangePasswordDate,F_MultiUserLogin,F_LogOnCount,F_UserOnLine,F_Question,F_AnswerQuestion,F_CheckIPAddress,F_Language,F_Theme
|
|
from dbo.Sys_SRM_UserLogOn a
|
|
left join dbo.Sys_SRM_User b on a.F_UserId=b.F_Id
|
|
where b.F_Account='admin' and b.F_Location='{3}'
|
|
";
|
|
|
|
|
|
sql = string.Format(sql, MUSER, MUSERName, WorkPointCode, WorkPoint, ID);
|
|
try
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "克隆失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
|
|
|
|
public string DeleteTableByCode(string TableCode)
|
|
{
|
|
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
|
|
string MUSERNAME = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
string sql = string.Empty;
|
|
JArray res = (JArray)JsonConvert.DeserializeObject(TableCode);
|
|
foreach (var item in res)
|
|
{
|
|
JObject jo = (JObject)item;
|
|
sql += @" delete "+ jo["Code"].ToString() + " where WorkPoint='"+ WorkPoint + "' ";
|
|
|
|
}
|
|
try
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
msg = "清除失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//throw new Exception(ex.Message);
|
|
msg = ex.Message;
|
|
}
|
|
|
|
return msg;
|
|
}
|
|
}
|
|
}
|
|
|