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; namespace NFine.Application.WMS { public class PrintApp : RepositoryFactory { 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 GetLableSourceID() { string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); string sql = @" select '' as ID,'' as SourceName union all select distinct ID,SourceName from Sys_LableDataSource"; string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode; DataTable dt = SqlHelper.GetDataTableBySql(sql); return dt; } public DataTable GetSys_LablesID(string LableType) { 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 where LableType='{0}'"; sql = string.Format(sql, LableType); string role = NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode; DataTable dt = SqlHelper.GetDataTableBySql(sql); return dt; } public DataTable SelectColumnName(string BeginTime, string EndTime) { string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; string sql = @"select ColCode, ColName from ICSExtensionEnable where Enable=1 and workPoint='{0}' order by cast(EATTRIBUTE1 as int)"; sql = string.Format(sql, WorkPoint); DataTable dt = SqlHelper.GetDataTableBySql(sql); return dt; } public DataTable SelectTableColumnName(string BeginTime, string EndTime) { string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; string sql = @"select TableCode, ColumnCode AS Code,Name from ICSColumnEnable where Enable=1 and workPoint='{0}' order by MTIME"; sql = string.Format(sql, WorkPoint); DataTable dt = SqlHelper.GetDataTableBySql(sql); return dt; } public string GetCnValue(string Code) { try { object MultipleLanguageSetting = GetMultipleLanguageSetting(); string content = ""; string sql = string.Format(@"select {1} from Sys_Language where Code='{0}'", Code, MultipleLanguageSetting); DataTable dt = SqlHelper.GetDataTableBySql(sql); if (dt != null && dt.Rows.Count > 0) { content = dt.Rows[0]["" + MultipleLanguageSetting + ""].ToString().ToUpper(); } else { content = ""; } return content; } catch (Exception ex) { throw new Exception(ex.Message.ToString()); } } public object GetMultipleLanguageSetting() { try { string sql = string.Format(@"select top 1 b.F_Define1 from Sys_SRM_Items a left join Sys_SRM_ItemsDetail b on a.F_Id=b.F_ItemId where a.F_EnCode='LGG0001' and b.F_EnabledMark='1' order by b.F_ItemCode"); object MultipleLanguageSetting = SqlHelper.ExecuteScalar(sql); return MultipleLanguageSetting; } catch (Exception ex) { throw new Exception(ex.Message.ToString()); } } public string updatePrintStatus(string LotNo) { try { string User = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; string msg = ""; string sql = @"UPDATE ICSInventoryLot SET PrintTimes=( CASE WHEN PrintTimes IS NULL THEN 1 ELSE PrintTimes+1 END),LastPrintUser='{0}',LastPrintTime=GETDATE() WHERE LotNo='{1}' AND WorkPoint='{2}'"; sql = string.Format(sql, User, LotNo, WorkPoint); if (!(SqlHelper.ExecuteNonQuery(sql) > 0)) { msg = "条码 " + LotNo + " 更新打印人、打印时间与打印次数失败!"; } return msg; } catch (Exception ex) { return "更新打印人出错:" + ex.Message; } } } }