using Mesnac.Action.ChemicalWeighing.Entity; using Mesnac.Codd.Session; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Mesnac.Action.ChemicalWeighing.PumpManage { public class PumpHelper { internal static DataTable GetPumpTable() { DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local); if (dbHelper == null) { throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError); } string sqlstr = "select * from Hw_Pump"; DataTable dt = dbHelper.GetDataTableBySql(sqlstr); return dt; } internal static List GetHwPumpTList() { DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local); if (dbHelper == null) { throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError); } string sqlstr = "select * from Hw_Pump"; DataTable dt = dbHelper.GetDataTableBySql(sqlstr); List list = new List(); foreach (DataRow row in dt.Rows) { Hw_Pump hw = new Hw_Pump(); hw.ID = Mesnac.Basic.DataProcessor.RowValue(row, "ID", 0); hw.Name = Mesnac.Basic.DataProcessor.RowValue(row, "Name", String.Empty); hw.BarCode = Mesnac.Basic.DataProcessor.RowValue(row, "BarCode", String.Empty); hw.CreateTime = Mesnac.Basic.DataProcessor.RowValue(row, "CreateTime", String.Empty); list.Add(hw); } return list; } internal static bool QueryIsExe(string name, string barCode) { DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local); if (dbHelper == null) { throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError); } string sqlstr = "select count(ID) from Hw_Pump where Name=@Name or BarCode=@BarCode"; dbHelper.CommandType = CommandType.Text; dbHelper.CommandText = sqlstr; dbHelper.ClearParameter(); dbHelper.AddParameter("@Name", name); dbHelper.AddParameter("@BarCode", barCode); object result = dbHelper.ToScalar(); if (result != null && result != System.DBNull.Value) { int intResult = 0; if (int.TryParse(result.ToString(), out intResult)) { if (intResult > 0) { return true; } } } return false; } } }