添加导出到货单接口
This commit is contained in:
138
NX.ERP.U8/AdoHelper.cs
Normal file
138
NX.ERP.U8/AdoHelper.cs
Normal file
@@ -0,0 +1,138 @@
|
||||
using ADODB;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NX.ERP.U8
|
||||
{
|
||||
public class AdoHelper : IDisposable
|
||||
{
|
||||
private ADODB.Connection connection;
|
||||
|
||||
public Connection Connection { get => connection; set => connection = value; }
|
||||
|
||||
public void BeginTrans()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Connection != null)
|
||||
{
|
||||
Connection.BeginTrans();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public AdoHelper(string constr)
|
||||
{
|
||||
|
||||
if (!string.IsNullOrEmpty(constr))
|
||||
{
|
||||
connection = new ConnectionClass();
|
||||
connection.ConnectionString = constr;
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
throw new Exception(err.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("链接字符串为空");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Recordset U8ExcuteRecord(string strSQL)
|
||||
{
|
||||
try
|
||||
{
|
||||
return connection.Execute(strSQL, out object RecordsAffected);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int ExcuteNoneQuery(string strSQL)
|
||||
{
|
||||
try
|
||||
{
|
||||
Connection.Execute(strSQL, out var RecordsAffected);
|
||||
return (int)RecordsAffected;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void RollbackTrans()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Connection != null)
|
||||
{
|
||||
Connection.RollbackTrans();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void CommitTrans()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Connection != null)
|
||||
{
|
||||
Connection.CommitTrans();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Connection != null)
|
||||
{
|
||||
if (Connection.State == 1)
|
||||
{
|
||||
Connection.Close();
|
||||
}
|
||||
Connection = null;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user