75 lines
1.8 KiB
C#
75 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace JJMediSys
|
|
{
|
|
class SqlHelper
|
|
{
|
|
private SQLiteDBHelper _mgr;
|
|
string file = "";
|
|
string CurDay = "";
|
|
string CreateSql = "";
|
|
public void initDB(string fileName,string mCreatSql)
|
|
{
|
|
string path = System.IO.Directory.GetCurrentDirectory();
|
|
file = string.Format($"{path}\\{fileName}", path);
|
|
bool exist = File.Exists(file);
|
|
CreateSql = mCreatSql;
|
|
if (exist != true)
|
|
{
|
|
System.IO.File.Create(file).Dispose();
|
|
OpenCon();
|
|
_mgr.CreateDB(file, CreateSql);
|
|
}
|
|
else
|
|
{
|
|
OpenCon();
|
|
}
|
|
// int Ret = OpenCon();
|
|
}
|
|
|
|
public int OpenCon()
|
|
{
|
|
this._mgr = new SQLiteDBHelper(file);
|
|
this._mgr.SetDataSource(file, null);
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string GetBLEAddr(string BarCode) //通过条码号 获取盒子蓝牙地址
|
|
{
|
|
string sql = "Select MacAddr from BOXLIST where Barcode='" + BarCode + "'";
|
|
|
|
DataTable dataTable = _mgr.ExecQuery(sql);
|
|
if (dataTable == null || dataTable.Rows.Count <= 0)
|
|
return "";
|
|
return dataTable.Rows[0]["MacAddr"].ToString();
|
|
|
|
}
|
|
|
|
public void ExcuteCmd(string sql)
|
|
{
|
|
|
|
_mgr.ExecuteCommand(sql);
|
|
}
|
|
|
|
public DataTable ExcQuery(string sql)
|
|
{
|
|
|
|
DataTable dataTable = _mgr.ExecQuery(sql);
|
|
return dataTable;
|
|
}
|
|
}
|
|
}
|