纽威
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.
 
 
 
 
 

3745 lines
162 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 = "";
keyValue = keyValue.Substring(1, keyValue.Length - 2);
string sql = string.Empty;
//sql = string.Format(@"DELETE FROM dbo.ICSLocation WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
sql = string.Format(@"IF EXISTS(SELECT ID FROM dbo.ICSLocation WHERE ID IN ({0}) and WorkPoint ='{1}' AND EATTRIBUTE1 is not null AND EATTRIBUTE1!='')
BEGIN
DELETE FROM dbo.ICSLocationOverLoad WHERE OverLoadLocationCode IN (
SELECT EATTRIBUTE1 FROM dbo.ICSLocation WHERE ID IN ({0}) and WorkPoint ='{1}') and WorkPoint ='{1}'
END;
DELETE FROM dbo.ICSLocation WHERE ID IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
try
{
SqlHelper.CmdExecuteNonQueryLi(sql);
}
catch (Exception ex)
{
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 GetLocationCode()
{
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
string sql = @"select '' as LocationCode
union all
SELECT a.LocationCode from ICSLocation a
left join ICSLocationOverLoad b on b.WorkPoint=a.WorkPoint and a.LocationCode = b.LocationCode
WHERE (a.EATTRIBUTE1 is null or a.EATTRIBUTE1='')
AND b.ID is null ";
//string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode;
//if (role != "admin")
//{
// sql += " and b.WorkPoint='" + WorkPoint + "'";
//}
sql += " and a.WorkPoint='" + WorkPoint + "'";
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 = @"INSERT INTO dbo.ICSLocation
( ID ,LocationCode ,LocationName ,WHID ,MUSER ,
MUSERName ,MTIME ,WorkPoint ,Region,Row,GoodsShelf ,Tier,Grid,StockInArea) Values(NEWID(),'{0}','{1}','{2}','{3}','{4}',GETDATE(),'{5}','{6}','{7}','{8}','{9}','{10}','{11}')";
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(), queryParam["WarehouseArea"].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 InsertOverLoadStack(string keyValue)
{
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 msg = "";
//验证数据是否符合要求
string overLoadCode = queryParam["LocationCode1"].ToString() + "," + queryParam["LocationCode2"].ToString();
//if (overLoadCode!=null&&overLoadCode.Count!=2)
//{
// msg = "请输入两个符合要求的库位信息";
// return msg;
//}
string checkSql = $@"IF EXISTS (SELECT ID FROM ICSLocation WHERE LocationCode='{queryParam["StackCode"]}')
BEGIN
RAISERROR('',16,1);
RETURN
END;
IF EXISTS (SELECT ID FROM ICSLocationOverLoad WHERE LocationCode='{queryParam["LocationCode1"]}')
BEGIN
RAISERROR('1',16,1);
RETURN
END
IF EXISTS (SELECT ID FROM ICSLocationOverLoad WHERE LocationCode='{queryParam["LocationCode2"]}')
BEGIN
RAISERROR('2',16,1);
RETURN
END
SELECT * from ICSLocation WHERE LocationCode='{queryParam["LocationCode1"]}';SELECT * from ICSLocation WHERE LocationCode='{queryParam["LocationCode2"]}';";
var dataSet = SqlHelper.GetDataSetBySql(checkSql);
if (dataSet.Tables[0].Rows.Count == 0)
{
msg = "库位1编号不存在!";
return msg;
}
if (dataSet.Tables[1].Rows.Count == 0)
{
msg = "库位2编号不存在!";
return msg;
}
if (queryParam["LocationCode1"].ToString() == queryParam["LocationCode2"].ToString())
{
msg = "选择重复的库位!";
return 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 = $@"INSERT INTO dbo.ICSLocation
( ID ,LocationCode ,LocationName ,WHID ,MUSER ,MUSERName ,MTIME ,WorkPoint ,Region,Row,GoodsShelf ,Tier,Grid,EATTRIBUTE1,StockInArea)
Values(NEWID(),'{queryParam["StackCode"]}','{queryParam["StackName"]}','{dt.Rows[0]["ID"]}','{MUSER}','{MUSERNAME}',GETDATE(),'{WorkPoint}','{queryParam["Qu"]}','{queryParam["Pai"]}','{queryParam["Jia"]}','{queryParam["Ceng"]}','{queryParam["Ge"]}','{overLoadCode}','{queryParam["WarehouseArea"]}');
INSERT INTO [dbo].[ICSLocationOverLoad] ([ID], [LocationCode], [OverLoadLocationCode], [WorkPoint], [MTIME], [MUSER], [MUSERNAME])
VALUES (NEWID(), '{queryParam["LocationCode1"]}', '{overLoadCode}', '{WorkPoint}', GETDATE(), '{MUSER}', '{MUSERNAME}');
INSERT INTO [dbo].[ICSLocationOverLoad] ([ID], [LocationCode], [OverLoadLocationCode], [WorkPoint], [MTIME], [MUSER], [MUSERNAME])
VALUES (NEWID(), '{queryParam["LocationCode2"]}','{overLoadCode}', '{WorkPoint}',GETDATE(),'{MUSER}', '{MUSERNAME}');";
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
{
}
else
{
msg = "新增超托库位失败";
}
return msg;
}
catch (Exception ex)
{
//throw new Exception(ex.Message);
return ex.Message;
}
}
/// <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}' and WorkPoint='{1}'";
StackSql = string.Format(StackSql, queryParam["Warehouse"].ToString(), WorkPoint);
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}',StockInArea='{12}' 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(), queryParam["WarehouseArea"].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 UpdateOverLoadStack(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 overLoadCode = queryParam["LocationCode1"].ToString() + "," + queryParam["LocationCode2"].ToString();
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 = @"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}',EATTRIBUTE1='{12}',StockInArea='{13}' 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(), overLoadCode, queryParam["WarehouseArea"].ToString());
sql += $@"DELETE FROM ICSLocationOverLoad WHERE OverLoadLocationCode='{overLoadCode}' AND WorkPoint='{WorkPoint}';
INSERT INTO [dbo].[ICSLocationOverLoad] ([ID], [LocationCode], [OverLoadLocationCode], [WorkPoint], [MTIME], [MUSER], [MUSERNAME])
VALUES (NEWID(), '{queryParam["LocationCode1"]}', '{overLoadCode}', '{WorkPoint}', GETDATE(), '{MUSER}', '{MUSERNAME}');
INSERT INTO [dbo].[ICSLocationOverLoad] ([ID], [LocationCode], [OverLoadLocationCode], [WorkPoint], [MTIME], [MUSER], [MUSERNAME])
VALUES (NEWID(), '{queryParam["LocationCode2"]}','{overLoadCode}', '{WorkPoint}',GETDATE(),'{MUSER}', '{MUSERNAME}');";
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 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 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="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;
}
//不良代码
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 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 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 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 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>
/// 不良原因子表查询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 BRGCode)
{
string sql = string.Empty;
DataTable dt = null;
sql = string.Format(@"select * from ICSBadReason where BRGroupID='{0}'", BRGCode);
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();
}
}
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 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 )
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}')
";
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);
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}'
,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());
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
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="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>
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 )
Values(NEWID(),'{0}','{1}','{2}','{3}',GETDATE(),'{4}','{5}','{6}')
";
sql = string.Format(sql, queryParam["ContainerID"].ToString(), queryParam["ContainerCODE"].ToString(), queryParam["ContainerName"].ToString(), queryParam["Memo"].ToString(), MUSER, MUSERNAME, WorkPoint);
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 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}' 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());
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;
}
/// <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;
}
/// <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();
string WarehouseArea = dr["窄巷道待入库区域"].ToString().Trim().ToUpper();
string StackCode1 = dr["库位1"].ToString().Trim().ToUpper();
string StackCode2 = dr["库位2"].ToString().Trim().ToUpper();//CutStringToSecondOccurrence
if (StackCode1 == StackCode2 && StackCode1 != "" && StackCode1 != null && StackCode2 != "" && StackCode2 != null)
{
throw new Exception("第 " + index + " 行绑定的超托库位为相同库位!");
}
if (CutStringToSecondOccurrence(StackCode1, '-') != CutStringToSecondOccurrence(StackCode2, '-'))
{
throw new Exception("第 " + index + " 行绑定的超托库位仓库或区域不一致!");
}
if ((String.IsNullOrEmpty(StackCode1) && !String.IsNullOrEmpty(StackCode2)) || (String.IsNullOrEmpty(StackCode2) && !String.IsNullOrEmpty(StackCode1)))
{
throw new Exception("第 " + index + " 行必须导入两个库位进行超托库位绑定!");
}
//超托库位编码
string OverLoadStackCode = string.Empty;
if (StackCode1 != "" && StackCode1 != null && StackCode2 != "" && StackCode2 != null)
{
OverLoadStackCode = StackCode1 + "," + StackCode2;
}
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 + " 不存在!");
}
if (!String.IsNullOrEmpty(OverLoadStackCode))
{
string sqlLocationCode = $@"IF NOT EXISTS (SELECT ID FROM ICSLocation WHERE LocationCode='{StackCode1}')
BEGIN
RAISERROR('库位编码{StackCode1}不存在',16,1)
RETURN
END;
IF NOT EXISTS (SELECT ID FROM ICSLocation WHERE LocationCode='{StackCode2}')
BEGIN
RAISERROR('库位编码{StackCode2}不存在',16,1)
RETURN
END;
IF EXISTS (SELECT ID FROM ICSLocationOverLoad WHERE (LocationCode='{StackCode1}' OR LocationCode='{StackCode2}') and WorkPoint='{WorkPoint}')
BEGIN
RAISERROR('第{index}行库位已经绑定超托库位,操作失败!',16,1)
RETURN
END; ";
SqlHelper.ExecuteNonQuery(sqlLocationCode);
}
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 [dbo].[ICSLocation] ([ID], [LocationCode], [LocationName], [WHID], [MUSER], [MUSERName], [MTIME], [WorkPoint], [EATTRIBUTE1], [Region], [Row], [GoodsShelf ], [Tier], [Grid], [StockInArea], [Isoccupy])
VALUES (NEWID(), '{StackCode}', '{StackName}', '{WHID}', '{MUSER}', '{MUSERNAME}', getdate(), '{WorkPoint}', '{OverLoadStackCode}', '{Qu}', '{Pai}', '{Jia}', '{Ceng}', '{Ge}', '{WarehouseArea}', '');"
;
if (!String.IsNullOrEmpty(OverLoadStackCode))
{
sql += $@"INSERT INTO [dbo].[ICSLocationOverLoad] ([ID], [LocationCode], [OverLoadLocationCode], [WorkPoint], [MTIME], [MUSER], [MUSERNAME], [EATTRIBUTE1], [EATTRIBUTE2], [EATTRIBUTE3], [EATTRIBUTE4], [EATTRIBUTE5])
VALUES (NEWID(), '{StackCode1}', '{OverLoadStackCode}', '{WorkPoint}', getdate(), '{MUSER}', '{MUSERNAME}', NULL, NULL, NULL, NULL, NULL);
INSERT INTO [dbo].[ICSLocationOverLoad] ([ID], [LocationCode], [OverLoadLocationCode], [WorkPoint], [MTIME], [MUSER], [MUSERNAME], [EATTRIBUTE1], [EATTRIBUTE2], [EATTRIBUTE3], [EATTRIBUTE4], [EATTRIBUTE5])
VALUES (NEWID(), '{StackCode2}', '{OverLoadStackCode}', '{WorkPoint}', getdate(), '{MUSER}', '{MUSERNAME}', NULL, NULL, NULL, NULL, NULL);";
}
//sql += @"Insert INto ICSLocation Values (newid(),'{0}','{1}','{2}','{3}','{4}',getdate(),'{5}','{12}','{6}','{7}','{8}','{9}','{10}','{11}',NULL)";
}
//sql = string.Format(sql, StackCode, StackName, WHID, MUSER, MUSERNAME, WorkPoint,Qu,Pai,Jia,Ceng,Ge,WarehouseArea, OverLoadStackCode);
}
count = SqlHelper.CmdExecuteNonQueryLi(sql);
if (count > 0)
{
msg = "导入成功";
}
else
{
return "无有效的导入数据。";
}
return msg;
}
catch (Exception ex)
{
return ex.Message;
}
}
/// <summary>
/// 字符串截取方法,截取第二次特定字符之前的字符串
/// </summary>
/// <param name="str">截取字符串</param>
/// <param name="ch">字符</param>
/// <returns></returns>
public string CutStringToSecondOccurrence(string str, char ch)
{
int index1 = str.IndexOf(ch);
if (index1 == -1)
return str;
int index2 = str.IndexOf(ch, index1 + 1);
if (index2 == -1)
return str.Substring(0, index1); // 如果只找到一次指定字符
return str.Substring(0, index2);
}
/// <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);
}
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 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 ICSMTDOC, string SireID)
{
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;
}
//包装容器关联条码
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);
}
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 from ICSInventoryLot a
left join ICSInventory b on a.InvCode=b.InvCode and a.WorkPoint=b.WorkPoint where a.LotNo='{0}'";
sql = string.Format(sql, LotNo);
return Repository().FindTableBySql(sql.ToString());
}
public string BindingContainerLotID(string ICSMTDOC, string SireID, string SireCode)
{
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;
}
/// <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,
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(@ID,'{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 SyncDNDoc(string DocNO, string StartDate)
{
DataTable dt = new DataTable();
var queryParam = "";
List<DbParameter> parameter = new List<DbParameter>();
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 = "";
SAPGetChkDocInfoZS.ZWMS_SK_WS_CHECK client = new SAPGetChkDocInfoZS.ZWMS_SK_WS_CHECK();
SAPGetChkDocInfoZS.ZWMS_SK_WS_CHECK1 Info = new SAPGetChkDocInfoZS.ZWMS_SK_WS_CHECK1();
if (DocNO != "")
{
Info.PRUEFLOS = DocNO;
Info.CHG_DATE = "";
}
if (StartDate != "")
{
Info.PRUEFLOS = "";
Info.CHG_DATE = StartDate;
}
if (DocNO == "" && StartDate == "")
{
Info.PRUEFLOS = "";
Info.CHG_DATE = DateTime.Now.Year + "-" + DateTime.Now.Month.ToString().PadLeft(2, '0') + "-" + DateTime.Now.Day.ToString().PadLeft(2, '0');
}
Info.WERKS = WorkPoint;
Info.ZCHECK_HEAD = new SAPGetChkDocInfoZS.ZWMS_SK_CHECK_HEAD[1];
Info.ZCHECK_ITEM = new SAPGetChkDocInfoZS.ZWMS_SK_CHECK_ITEM[1];
SAPGetChkDocInfoZS.ZWMS_SK_WS_CHECKResponse result = new SAPGetChkDocInfoZS.ZWMS_SK_WS_CHECKResponse();
client.Timeout = 300000;
result = client.CallZWMS_SK_WS_CHECK(Info);
List<SAPGetChkDocInfoZS.ZWMS_SK_CHECK_ITEM> ItemInfoList = new List<SAPGetChkDocInfoZS.ZWMS_SK_CHECK_ITEM>();
ItemInfoList.AddRange(result.ZCHECK_ITEM);
foreach (SAPGetChkDocInfoZS.ZWMS_SK_CHECK_HEAD HeadInfo in result.ZCHECK_HEAD)
{
string LineNum = "10";
var ItemInfo = ItemInfoList.Where(a => a.PRUEFLOS == HeadInfo.PRUEFLOS);
foreach (SAPGetChkDocInfoZS.ZWMS_SK_CHECK_ITEM Item in ItemInfo)
{
string ExtensionID = "";
bool isNew = false;
string Colspan = "";
if (Item.SOBKZ == "E")
{
Colspan = Item.KDAUF + "~~~" + Item.KDPOS + "~~~~~~~~~~";
}
else
{
Colspan = "~~~~~~~~~~~~~";
}
string chksql = @"select ID from ICSExtension where Colspan='{0}' and WorkPoint='{1}'";
chksql = string.Format(chksql, Colspan, WorkPoint);
DataTable chkdt = SqlHelper.GetDataTableBySql(chksql);
if (chkdt.Rows.Count != 0)
{
ExtensionID = chkdt.Rows[0]["ID"].ToString();
}
else
{
ExtensionID = Common.GuId();
sql += @" insert into ICSExtension
(ID,BatchCode,Version,Brand,ProjectCode,Colspan,MTIME,MUSER,MUSERName,WorkPoint)
VALUES
('{6}','','','{0}','{1}','{2}',GETDATE(),'{3}','{4}','{5}') ";
if (Item.SOBKZ == "E")
{
sql = string.Format(sql, Item.KDPOS, Item.KDAUF, Colspan, MUSER, MUSERNAME, WorkPoint, ExtensionID);
}
else
{
sql = string.Format(sql, "", "", Colspan, MUSER, MUSERNAME, WorkPoint, ExtensionID);
}
}
chksql = @"select ID from ICSDeliveryNotice where DNCode='{0}' AND InvCode='{1}' AND WorkPoint='{2}'";
chksql = string.Format(chksql, Item.PRUEFLOS, Item.MATNR.TrimStart('0'), WorkPoint);
chkdt = SqlHelper.GetDataTableBySql(chksql);
if (chkdt.Rows.Count == 0)
{
sql += @" INSERT INTO [dbo].[ICSDeliveryNotice]
([ID],[DNCode],[Sequence],[SAPSequence],[VenCode],[DepCode],[DNType],[InvCode],[Quantity],[Amount],[RCVQuantity]
,[Status],[CreatePerson],[CreateDateTime],[POID],[DNID],[DNDetailID],[ExtensionID]
,[MUSER],[MUSERName],[MTIME],[WorkPoint],[EATTRIBUTE1],[WHCode],[InspectionType],[InvoDescribe]
,[StockIndicator],[DepositArea],[Unity],[ModificationDate],[TrackingNumber],[NonconformingForm]
,[EATTRIBUTE2])
VALUES
(NEWID(),'" + Item.PRUEFLOS + "','" + LineNum + "'," + Item.L_LME.ToString() + ",'" + HeadInfo.LIFNR + @"'
,'" + HeadInfo.NAME1 + "','1','" + Item.MATNR.TrimStart('0') + "'," + Item.HGMENGE + @",0
,0,2,'" + MUSER + "','" + Convert.ToDateTime(HeadInfo.VDATUM) + "','" + HeadInfo.AUFNR + @"'
,'" + HeadInfo.EBELN + "','" + HeadInfo.EBELP + "','" + ExtensionID + "','" + MUSER + @"'
,'" + MUSERNAME + "',GETDATE(),'" + WorkPoint + "','" + Item.MEMO + "','" + Item.LGORT.Trim() + @"'
,'" + HeadInfo.ART + "','" + Item.MAKTX + "','" + Item.SOBKZ + "','" + Item.LTKZA + @"'
,'" + Item.MEINS + "','" + HeadInfo.TEST1 + "','" + HeadInfo.TEST2 + "','" + HeadInfo.TEST3 + @"'
,'" + HeadInfo.TEST4 + "')";
}
else
{
sql += @" Update ICSDeliveryNotice set VenCode='" + HeadInfo.LIFNR + "',DepCode='" + HeadInfo.NAME1 + @"',DNType=1
,CreateDateTime='" + Convert.ToDateTime(HeadInfo.VDATUM) + "',POID='" + HeadInfo.AUFNR + @"'
,DNID='" + HeadInfo.EBELN + "',DNDetailID='" + HeadInfo.EBELP + "',Quantity=" + Item.HGMENGE + @"
,SAPSequence=" + Item.L_LME.ToString() + ",WHCode='" + Item.LGORT.Trim() + "',EATTRIBUTE1='" + Item.MEMO + @"'
,ExtensionID='" + ExtensionID + "',InspectionType='" + HeadInfo.ART + "',InvoDescribe='" + Item.MAKTX + @"'
,Unity='" + Item.MEINS + "',StockIndicator='" + Item.SOBKZ + "',DepositArea='" + Item.LTKZA + @"'
,ModificationDate='" + HeadInfo.TEST1 + "',TrackingNumber='" + HeadInfo.TEST2 + @"'
,NonconformingForm='" + HeadInfo.TEST3 + "',EATTRIBUTE2='" + HeadInfo.TEST4 + @"'
where DNCode='{0}' AND InvCode='{1}' AND WorkPoint='{2}' ";
sql = string.Format(sql, Item.PRUEFLOS, Item.MATNR.TrimStart('0'), WorkPoint);
}
}
}
try
{
if (sql != "")
{
SqlHelper.CmdExecuteNonQueryLi(sql);
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return "";
}
}
}