using ICSSoft.Common; using ICSSoft.Entity; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ICSSoft.DataProject { /// /// pda版本 /// public class ICSWMSVersions { private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static string connString = System.Configuration.ConfigurationManager.AppSettings["ConnStr"]; private static string ERPDB = System.Configuration.ConfigurationManager.AppSettings["ERPDB"]; DataTable table = null; SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString); string sql = string.Empty; string sqlInfo = string.Empty; VerificationMethod verification = new VerificationMethod(); public List Get(ICSVersions JsonData) { conn.Open(); SqlTransaction sqlTran = conn.BeginTransaction(); SqlCommand cmd = new SqlCommand(); cmd.Transaction = sqlTran; cmd.Connection = conn; try { sql = @"select top(1)* from ICSVersions where 1=1"; if (!string.IsNullOrWhiteSpace(JsonData.ProjectName)) { sql += " and ProjectName='{0}'"; } sql = string.Format(sql, JsonData.ProjectName); table = DBHelper.SQlReturnData(sql, cmd); string json = JsonConvert.SerializeObject(table); List model = JsonConvert.DeserializeObject>(json); cmd.Transaction.Commit(); return model; } catch (Exception ex) { if (cmd.Transaction != null) cmd.Transaction.Rollback(); log.Error(ex.Message); throw new Exception(ex.Message); } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } conn.Dispose(); } } public List GetWorkPoint(ICSWorkPoint JsonData) { conn.Open(); SqlTransaction sqlTran = conn.BeginTransaction(); SqlCommand cmd = new SqlCommand(); cmd.Transaction = sqlTran; cmd.Connection = conn; try { sql = @"select * from Sys_WorkPoint where 1=1"; if (!string.IsNullOrWhiteSpace(JsonData.WorkPointCode)) { sql += " and WorkPointCode='{0}'"; } sql = string.Format(sql, JsonData.WorkPointCode); table = DBHelper.SQlReturnData(sql, cmd); string json = JsonConvert.SerializeObject(table); List model = JsonConvert.DeserializeObject>(json); cmd.Transaction.Commit(); return model; } catch (Exception ex) { if (cmd.Transaction != null) cmd.Transaction.Rollback(); log.Error(ex.Message); throw new Exception(ex.Message); } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } conn.Dispose(); } } } }