You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
3.0 KiB
C#

1 year ago
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.CylinderManage
{
public class CylinderHelper
{
internal static DataTable GetCylinderTable()
{
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_Cylinder";
DataTable dt = dbHelper.GetDataTableBySql(sqlstr);
return dt;
}
internal static List<Hw_Cylinder> GetCylinderTList()
{
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_Cylinder";
DataTable dt = dbHelper.GetDataTableBySql(sqlstr);
List<Hw_Cylinder> list = new List<Hw_Cylinder>();
foreach (DataRow row in dt.Rows)
{
Hw_Cylinder hw=new Hw_Cylinder();
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_Cylinder 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;
}
}
}