Merge branch 'master' of http://36.153.118.214:10080/nx.wms/u8-import
This commit is contained in:
@@ -9,7 +9,7 @@ using UFIDA.U8.U8MOMAPIFramework;
|
||||
|
||||
namespace NX.ERP.U8.AP
|
||||
{
|
||||
public class APVouch : VoucherBase
|
||||
public class APVouch : STVoucherBase
|
||||
{
|
||||
public APVouch() : base("应付单", "U8API/APVouch")
|
||||
{
|
||||
@@ -47,7 +47,7 @@ namespace NX.ERP.U8.AP
|
||||
}
|
||||
|
||||
|
||||
protected override void LoadRdVoucher(VoucherParameter para)
|
||||
protected override void LoadRdVoucher(STVoucherParameter para)
|
||||
{
|
||||
|
||||
try
|
||||
@@ -110,7 +110,7 @@ namespace NX.ERP.U8.AP
|
||||
}
|
||||
|
||||
|
||||
protected override string AddRdVoucher(VoucherParameter para)
|
||||
protected override string AddRdVoucher(STVoucherParameter para)
|
||||
{
|
||||
U8EnvContext u8EnvContext = new U8EnvContext
|
||||
{
|
||||
@@ -196,7 +196,7 @@ namespace NX.ERP.U8.AP
|
||||
public string AddVocher(NX.ERP.Model.Request.ApVouch ApVouch)
|
||||
{
|
||||
|
||||
VoucherParameter voucherParameter = new VoucherParameter
|
||||
STVoucherParameter voucherParameter = new STVoucherParameter
|
||||
{
|
||||
VoucherType = this.VoucherID,
|
||||
DomHead = new DOMDocumentClass(),
|
||||
|
||||
@@ -64,17 +64,18 @@
|
||||
<Compile Include="Store\PuStoreInDAL.cs" />
|
||||
<Compile Include="Store\SaleOutDAL.cs" />
|
||||
<Compile Include="Store\StockDAL.cs" />
|
||||
<Compile Include="Store\VoucherBase.cs" />
|
||||
<Compile Include="Store\STVoucherBase.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Base\SupplierDAL.cs" />
|
||||
<Compile Include="Account\Accinformation.cs" />
|
||||
<Compile Include="System\User.cs" />
|
||||
<Compile Include="U8DbHelper.cs" />
|
||||
<Compile Include="U8LoginContext.cs" />
|
||||
<Compile Include="Base\UnitDAL.cs" />
|
||||
<Compile Include="Base\WarehouseDAL.cs" />
|
||||
<Compile Include="ufsoft.cs" />
|
||||
<Compile Include="VoucherHistory.cs" />
|
||||
<Compile Include="VoucherParameter.cs" />
|
||||
<Compile Include="Store\STVoucherParameter.cs" />
|
||||
<Compile Include="VT.cs" />
|
||||
<Compile Include="XmlHelper.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Text;
|
||||
|
||||
namespace NX.ERP.U8.Store
|
||||
{
|
||||
public class BinChangeDAL : VoucherBase
|
||||
public class BinChangeDAL : STVoucherBase
|
||||
{
|
||||
public BinChangeDAL() : base("19", "U8API/BinChange")
|
||||
{
|
||||
@@ -15,7 +15,7 @@ namespace NX.ERP.U8.Store
|
||||
|
||||
public string AddVocher(Model.Request.BinChange binChange)
|
||||
{
|
||||
VoucherParameter voucherParameter = new VoucherParameter
|
||||
STVoucherParameter voucherParameter = new STVoucherParameter
|
||||
{
|
||||
VoucherType = this.VoucherID,
|
||||
DomHead = new DOMDocumentClass(),
|
||||
@@ -37,7 +37,6 @@ namespace NX.ERP.U8.Store
|
||||
var bodyXml = domBody.createElement("z:row");
|
||||
bodyXml.setAttribute("cinvcode", item.InvCode);
|
||||
bodyXml.setAttribute("cbposcode", item.SoucePositon);
|
||||
|
||||
bodyXml.setAttribute("caposcode", item.DestPostion);
|
||||
bodyXml.setAttribute("iquantity", item.Qty);
|
||||
domBody.selectSingleNode("//rs:data").appendChild(bodyXml);
|
||||
|
||||
@@ -9,26 +9,94 @@ namespace NX.ERP.U8.Store
|
||||
/// <summary>
|
||||
/// 领料申请
|
||||
/// </summary>
|
||||
public class MaterialAppDAL : VoucherBase
|
||||
public class MaterialAppDAL : STVoucherBase
|
||||
{
|
||||
public MaterialAppDAL() : base("64", "U8API/MaterialApp")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string AddVoucher(object param)
|
||||
public string AddVoucher(NX.ERP.Model.Request.MaterialApp param)
|
||||
{
|
||||
VoucherParameter voucherParameter = new VoucherParameter
|
||||
//conn=new AccessViolationException
|
||||
|
||||
//U8DbHelper u8DbHelper = new U8DbHelper(NX.ERP.U8.U8LoginContext.Instance.Constr);
|
||||
//u8DbHelper.BeginTrans();
|
||||
try
|
||||
{
|
||||
VoucherType = this.VoucherID,
|
||||
DomHead = new DOMDocumentClass(),
|
||||
DomBody = new DOMDocumentClass()
|
||||
};
|
||||
DOMDocument domHead = voucherParameter.DomHead;
|
||||
DOMDocument domBody = voucherParameter.DomBody;
|
||||
voucherParameter.DomHead.loadXML(HeadTemplate);
|
||||
voucherParameter.DomBody.loadXML(BodyTemplate);
|
||||
return "";
|
||||
STVoucherParameter voucherParameter = new STVoucherParameter
|
||||
{
|
||||
VoucherType = this.VoucherID,
|
||||
DomHead = new DOMDocumentClass(),
|
||||
DomBody = new DOMDocumentClass(),
|
||||
//cnnFrom = u8DbHelper.Conn
|
||||
};
|
||||
DOMDocument domHead = voucherParameter.DomHead;
|
||||
DOMDocument domBody = voucherParameter.DomBody;
|
||||
voucherParameter.DomHead.loadXML(HeadTemplate);
|
||||
voucherParameter.DomBody.loadXML(BodyTemplate);
|
||||
IXMLDOMElement headXml = domHead.createElement("z:row");
|
||||
headXml.setAttribute("id", "0");
|
||||
headXml.setAttribute("ccode", "AAAAA");
|
||||
headXml.setAttribute("ddate", param.Date);
|
||||
headXml.setAttribute("vt_id", "30718");
|
||||
headXml.setAttribute("csource", param.source);
|
||||
headXml.setAttribute("cRdCode", "206");
|
||||
headXml.setAttribute("cDepCode", "5401");
|
||||
Model.MOM.MomOrder Order = null;
|
||||
if (param.source == "生产订单")
|
||||
{
|
||||
Order = new Mom.MomOrderDAL().GetModel(param.SourceCode);
|
||||
}
|
||||
foreach (var item in param.MaterialAppDetails)
|
||||
{
|
||||
var bodyXml = domBody.createElement("z:row");
|
||||
bodyXml.setAttribute("autoid", 0);
|
||||
bodyXml.setAttribute("cinvcode", item.MaterialCode);
|
||||
bodyXml.setAttribute("iquantity", item.Qty);
|
||||
bodyXml.setAttribute("dduedate", item.Duedate);
|
||||
bodyXml.setAttribute("ipesotype", 0);
|
||||
if (param.source == "生产订单")
|
||||
{
|
||||
var detail = Order.Allocates.FirstOrDefault(m => m.AllocateId == item.SourceDetailId);
|
||||
if (detail == null)
|
||||
{
|
||||
throw new Exception("未知的明细项");
|
||||
}
|
||||
bodyXml.setAttribute("invcode", detail.momDetail.ProductCode);
|
||||
bodyXml.setAttribute("cmocode", param.SourceCode);
|
||||
bodyXml.setAttribute("imoseq", detail.momDetail.SortSeq);
|
||||
bodyXml.setAttribute("iposeq", "000");
|
||||
bodyXml.setAttribute("iorderdid", 0);
|
||||
bodyXml.setAttribute("iMPoIds", item.SourceDetailId);
|
||||
bodyXml.setAttribute("ipesodid", item.SourceDetailId);
|
||||
bodyXml.setAttribute("ipesotype", 7);
|
||||
bodyXml.setAttribute("cpesocode", param.SourceCode);
|
||||
bodyXml.setAttribute("ipesoseq", detail.momDetail.SortSeq);
|
||||
|
||||
|
||||
}
|
||||
domBody.selectSingleNode("//rs:data").appendChild(bodyXml);
|
||||
}
|
||||
domHead.selectSingleNode("//rs:data").appendChild(headXml);
|
||||
var code = this.AddRdVoucher(voucherParameter);
|
||||
//u8DbHelper.CommitTrans();
|
||||
return code;
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
//u8DbHelper.RollbackTrans();
|
||||
throw err;
|
||||
}
|
||||
finally
|
||||
{
|
||||
//u8DbHelper.Dispose();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace NX.ERP.U8.Store
|
||||
/// <summary>
|
||||
/// 材料出库单
|
||||
/// </summary>
|
||||
public class MaterialStoreOutDAL : VoucherBase
|
||||
public class MaterialStoreOutDAL : STVoucherBase
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
@@ -211,7 +211,7 @@ namespace NX.ERP.U8.Store
|
||||
/// <returns></returns>
|
||||
public string AddVocher(Model.Request.MaterialStoreOut storeOut)
|
||||
{
|
||||
VoucherParameter voucherParameter = new VoucherParameter
|
||||
STVoucherParameter voucherParameter = new STVoucherParameter
|
||||
{
|
||||
VoucherType = this.VoucherID,
|
||||
DomHead = new DOMDocumentClass(),
|
||||
@@ -296,7 +296,7 @@ namespace NX.ERP.U8.Store
|
||||
/// <param name="storeOut"></param>
|
||||
/// <param name="voucherParameter"></param>
|
||||
/// <returns></returns>
|
||||
public bool UpdateVocher(Model.Request.MaterialStoreOut storeOut, VoucherParameter voucherParameter = null)
|
||||
public bool UpdateVocher(Model.Request.MaterialStoreOut storeOut, STVoucherParameter voucherParameter = null)
|
||||
{
|
||||
if (voucherParameter == null)
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Text;
|
||||
|
||||
namespace NX.ERP.U8.Store
|
||||
{
|
||||
public class OtherStoreInDAL : VoucherBase
|
||||
public class OtherStoreInDAL : STVoucherBase
|
||||
{
|
||||
public OtherStoreInDAL() : base("08", "U8API/otherin")
|
||||
{
|
||||
@@ -16,7 +16,7 @@ namespace NX.ERP.U8.Store
|
||||
public string AddVocher(Model.Request.OtherStoreInOut storeIn)
|
||||
{
|
||||
|
||||
VoucherParameter voucherParameter = new VoucherParameter
|
||||
STVoucherParameter voucherParameter = new STVoucherParameter
|
||||
{
|
||||
VoucherType = this.VoucherID,
|
||||
DomHead = new DOMDocumentClass(),
|
||||
@@ -117,7 +117,7 @@ namespace NX.ERP.U8.Store
|
||||
|
||||
|
||||
|
||||
public bool UpdateVocher(Model.Request.OtherStoreInOut storeIn, VoucherParameter voucherParameter = null)
|
||||
public bool UpdateVocher(Model.Request.OtherStoreInOut storeIn, STVoucherParameter voucherParameter = null)
|
||||
{
|
||||
|
||||
if (voucherParameter == null)
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Text;
|
||||
|
||||
namespace NX.ERP.U8.Store
|
||||
{
|
||||
public class OtherStoreOutDAL : VoucherBase
|
||||
public class OtherStoreOutDAL : STVoucherBase
|
||||
{
|
||||
public OtherStoreOutDAL() : base("09", "U8API/otherout")
|
||||
{
|
||||
@@ -16,7 +16,7 @@ namespace NX.ERP.U8.Store
|
||||
public string AddVocher(Model.Request.OtherStoreInOut storeIn)
|
||||
{
|
||||
|
||||
VoucherParameter voucherParameter = new VoucherParameter
|
||||
STVoucherParameter voucherParameter = new STVoucherParameter
|
||||
{
|
||||
VoucherType = this.VoucherID,
|
||||
DomHead = new DOMDocumentClass(),
|
||||
@@ -119,7 +119,7 @@ namespace NX.ERP.U8.Store
|
||||
|
||||
|
||||
|
||||
public bool UpdateVocher(Model.Request.OtherStoreInOut storeIn, VoucherParameter voucherParameter = null)
|
||||
public bool UpdateVocher(Model.Request.OtherStoreInOut storeIn, STVoucherParameter voucherParameter = null)
|
||||
{
|
||||
|
||||
if (voucherParameter == null)
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Text;
|
||||
|
||||
namespace NX.ERP.U8.Store
|
||||
{
|
||||
public class ProductInDAL : VoucherBase
|
||||
public class ProductInDAL : STVoucherBase
|
||||
{
|
||||
public ProductInDAL() : base("10", "U8API/ProductIn")
|
||||
{
|
||||
@@ -16,7 +16,7 @@ namespace NX.ERP.U8.Store
|
||||
|
||||
public string AddVoucher(ProductStoreIn storeIn)
|
||||
{
|
||||
VoucherParameter voucherParameter = new VoucherParameter
|
||||
STVoucherParameter voucherParameter = new STVoucherParameter
|
||||
{
|
||||
VoucherType = this.VoucherID,
|
||||
DomHead = new DOMDocumentClass(),
|
||||
@@ -108,7 +108,7 @@ namespace NX.ERP.U8.Store
|
||||
}
|
||||
|
||||
|
||||
public bool UpdateVoucher(ProductStoreIn storeIn, VoucherParameter voucherParameter=null)
|
||||
public bool UpdateVoucher(ProductStoreIn storeIn, STVoucherParameter voucherParameter=null)
|
||||
{
|
||||
if (voucherParameter == null)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using UFIDA.U8.U8MOMAPIFramework;
|
||||
|
||||
namespace NX.ERP.U8.Store
|
||||
{
|
||||
public class PuStoreInDAL : VoucherBase
|
||||
public class PuStoreInDAL : STVoucherBase
|
||||
{
|
||||
public PuStoreInDAL() : base("01", "U8API/PuStoreIn")
|
||||
{
|
||||
@@ -25,7 +25,7 @@ namespace NX.ERP.U8.Store
|
||||
{
|
||||
try
|
||||
{
|
||||
VoucherParameter voucherParameter = new VoucherParameter
|
||||
STVoucherParameter voucherParameter = new STVoucherParameter
|
||||
{
|
||||
VoucherType = this.VoucherID,
|
||||
DomHead = new DOMDocumentClass(),
|
||||
@@ -162,7 +162,7 @@ namespace NX.ERP.U8.Store
|
||||
|
||||
|
||||
|
||||
public bool UpdateVocher(Model.Request.PuStoreIn puStoreIn, VoucherParameter voucherParameter = null)
|
||||
public bool UpdateVocher(Model.Request.PuStoreIn puStoreIn, STVoucherParameter voucherParameter = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -9,7 +9,10 @@ using UFIDA.U8.U8MOMAPIFramework;
|
||||
|
||||
namespace NX.ERP.U8.Store
|
||||
{
|
||||
public abstract class VoucherBase
|
||||
/// <summary>
|
||||
/// 库存模板基础类
|
||||
/// </summary>
|
||||
public abstract class STVoucherBase
|
||||
{
|
||||
private string voucherID;
|
||||
|
||||
@@ -19,7 +22,7 @@ namespace NX.ERP.U8.Store
|
||||
|
||||
private const string FLODER_NAME = "xml";
|
||||
|
||||
static VoucherBase()
|
||||
static STVoucherBase()
|
||||
{
|
||||
BasePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, FLODER_NAME);
|
||||
|
||||
@@ -84,7 +87,7 @@ namespace NX.ERP.U8.Store
|
||||
return this.voucherID;
|
||||
}
|
||||
}
|
||||
public VoucherBase(string voucherID, string Url)
|
||||
public STVoucherBase(string voucherID, string Url)
|
||||
{
|
||||
this.voucherID = voucherID;
|
||||
this.BaseUrl = Url;
|
||||
@@ -107,31 +110,71 @@ namespace NX.ERP.U8.Store
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static object lockHeadobj = new object();
|
||||
private static string strTemlateHead = "";
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private string GetHeadTemplate()
|
||||
{
|
||||
var strTemlate = FileHelp.ReadFile(HeadFile);
|
||||
if (strTemlate == string.Empty)
|
||||
if (string.IsNullOrEmpty(strTemlateHead))
|
||||
{
|
||||
this.LoadTemplate();
|
||||
strTemlate = GetHeadTemplate();
|
||||
lock (lockHeadobj)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(strTemlateHead))
|
||||
|
||||
{
|
||||
strTemlateHead = FileHelp.ReadFile(HeadFile);
|
||||
if (string.IsNullOrEmpty(strTemlateHead))
|
||||
{
|
||||
this.LoadTemplate();
|
||||
strTemlateHead = FileHelp.ReadFile(HeadFile);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return strTemlate;
|
||||
return strTemlateHead;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static object lockBodyobj = new object();
|
||||
private static string strTemlateBody = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private string GetBodyTemplate()
|
||||
{
|
||||
var strTemlate = FileHelp.ReadFile(BodyFile);
|
||||
if (strTemlate == string.Empty)
|
||||
if (string.IsNullOrEmpty(strTemlateBody))
|
||||
{
|
||||
this.LoadTemplate();
|
||||
strTemlate = GetBodyTemplate();
|
||||
lock (lockBodyobj)
|
||||
{
|
||||
if (string.IsNullOrEmpty(strTemlateBody))
|
||||
|
||||
{
|
||||
strTemlateBody = FileHelp.ReadFile(BodyFile);
|
||||
if (string.IsNullOrEmpty(strTemlateBody))
|
||||
{
|
||||
this.LoadTemplate();
|
||||
strTemlateBody = FileHelp.ReadFile(BodyFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return strTemlate;
|
||||
return strTemlateBody;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected virtual void LoadRdVoucher(VoucherParameter para)
|
||||
protected virtual void LoadRdVoucher(STVoucherParameter para)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -204,7 +247,7 @@ namespace NX.ERP.U8.Store
|
||||
|
||||
|
||||
|
||||
protected bool UpdateRdVoucher(VoucherParameter para)
|
||||
protected bool UpdateRdVoucher(STVoucherParameter para)
|
||||
{
|
||||
|
||||
|
||||
@@ -286,7 +329,7 @@ namespace NX.ERP.U8.Store
|
||||
}
|
||||
|
||||
|
||||
protected virtual string AddRdVoucher(VoucherParameter para)
|
||||
protected virtual string AddRdVoucher(STVoucherParameter para)
|
||||
{
|
||||
string VoucherId;
|
||||
|
||||
@@ -303,8 +346,15 @@ namespace NX.ERP.U8.Store
|
||||
{
|
||||
u8ApiBroker.AssignNormalValue("domPosition", para.DomPosition);
|
||||
}
|
||||
if (para.cnnFrom != null)
|
||||
{
|
||||
u8ApiBroker.AssignNormalValue("cnnFrom", para.cnnFrom);
|
||||
}
|
||||
else
|
||||
{
|
||||
u8ApiBroker.AssignNormalValue("cnnFrom", null);
|
||||
}
|
||||
|
||||
u8ApiBroker.AssignNormalValue("cnnFrom", null);
|
||||
if (para.DOMMsg != null)
|
||||
{
|
||||
u8ApiBroker.AssignNormalValue("domMsg", para.DOMMsg);
|
||||
@@ -375,9 +425,9 @@ namespace NX.ERP.U8.Store
|
||||
|
||||
|
||||
|
||||
protected VoucherParameter LoadVoucher(string where)
|
||||
protected STVoucherParameter LoadVoucher(string where)
|
||||
{
|
||||
var rdVoucherParameter = new VoucherParameter
|
||||
var rdVoucherParameter = new STVoucherParameter
|
||||
{
|
||||
VoucherType = this.VoucherID,
|
||||
IsGetBlank = false,
|
||||
@@ -396,11 +446,10 @@ namespace NX.ERP.U8.Store
|
||||
|
||||
private void LoadTemplate()
|
||||
{
|
||||
VoucherParameter rdVoucherParameter = null;
|
||||
try
|
||||
{
|
||||
|
||||
rdVoucherParameter = new VoucherParameter
|
||||
STVoucherParameter rdVoucherParameter = new STVoucherParameter
|
||||
{
|
||||
VoucherType = this.VoucherID,
|
||||
IsGetBlank = true
|
||||
@@ -6,7 +6,10 @@ using System.Text;
|
||||
|
||||
namespace NX.ERP.U8
|
||||
{
|
||||
public class VoucherParameter
|
||||
/// <summary>
|
||||
/// 库存模块
|
||||
/// </summary>
|
||||
public class STVoucherParameter
|
||||
{
|
||||
private string string_0;
|
||||
|
||||
@@ -46,6 +49,10 @@ namespace NX.ERP.U8
|
||||
|
||||
private string sBodyWhere_Order;
|
||||
|
||||
|
||||
public ADODB.Connection cnnFrom { get; set; } = null;
|
||||
|
||||
|
||||
public string SBodyWhere_Order
|
||||
{
|
||||
get
|
||||
@@ -264,7 +271,7 @@ namespace NX.ERP.U8
|
||||
}
|
||||
}
|
||||
|
||||
public VoucherParameter()
|
||||
public STVoucherParameter()
|
||||
{
|
||||
|
||||
isCheck = false;
|
||||
@@ -7,7 +7,7 @@ using System.Text;
|
||||
|
||||
namespace NX.ERP.U8.Store
|
||||
{
|
||||
public class SaleOutDAL : VoucherBase
|
||||
public class SaleOutDAL : STVoucherBase
|
||||
{
|
||||
public SaleOutDAL() : base("32", "U8API/saleout")
|
||||
{
|
||||
@@ -18,7 +18,7 @@ namespace NX.ERP.U8.Store
|
||||
public string AddVoucher(SaleStoreOut storeOut)
|
||||
{
|
||||
|
||||
VoucherParameter voucherParameter = new VoucherParameter
|
||||
STVoucherParameter voucherParameter = new STVoucherParameter
|
||||
{
|
||||
VoucherType = this.VoucherID,
|
||||
DomHead = new DOMDocumentClass(),
|
||||
@@ -125,7 +125,7 @@ namespace NX.ERP.U8.Store
|
||||
|
||||
|
||||
|
||||
public bool UpdateVoucher(SaleStoreOut storeOut, VoucherParameter voucherParameter = null)
|
||||
public bool UpdateVoucher(SaleStoreOut storeOut, STVoucherParameter voucherParameter = null)
|
||||
{
|
||||
if (voucherParameter == null)
|
||||
{
|
||||
|
||||
201
NX.ERP.U8/U8DbHelper.cs
Normal file
201
NX.ERP.U8/U8DbHelper.cs
Normal file
@@ -0,0 +1,201 @@
|
||||
using ADODB;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NX.ERP.U8
|
||||
{
|
||||
public class U8DbHelper:IDisposable
|
||||
{
|
||||
public string _connstring;
|
||||
|
||||
private string string_0;
|
||||
|
||||
public bool _DbErr;
|
||||
|
||||
public Connection Conn;
|
||||
|
||||
public string ConnectionString
|
||||
{
|
||||
get
|
||||
{
|
||||
return _connstring;
|
||||
}
|
||||
set
|
||||
{
|
||||
_connstring = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string ErrMsg
|
||||
{
|
||||
get
|
||||
{
|
||||
return string_0;
|
||||
}
|
||||
}
|
||||
|
||||
public U8DbHelper(string connstr)
|
||||
{
|
||||
|
||||
_connstring = connstr;
|
||||
if (_connstring != null && !(_connstring == string.Empty))
|
||||
{
|
||||
Conn = new ConnectionClass();
|
||||
Conn.ConnectionString = _connstring;
|
||||
try
|
||||
{
|
||||
Conn.Open();
|
||||
_DbErr = false;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_DbErr = true;
|
||||
string_0 = "数据连接配置错误,无法从指定的数据连接字符串打开数据库,请检查WEB.CONFIG文件";
|
||||
throw new Exception(ErrMsg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_DbErr = true;
|
||||
string_0 = "数据连接配置错误,没有配置数据连接";
|
||||
}
|
||||
}
|
||||
|
||||
public U8DbHelper(Connection cnt)
|
||||
{
|
||||
|
||||
_connstring = cnt.ConnectionString;
|
||||
Conn = cnt;
|
||||
try
|
||||
{
|
||||
if (Conn.State != 1)
|
||||
{
|
||||
Conn.Open();
|
||||
_DbErr = false;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_DbErr = true;
|
||||
string_0 = "数据连接配置错误,无法从指定的数据连接字符串打开数据库,请检查WEB.CONFIG文件";
|
||||
throw new Exception(ErrMsg);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsConn(string connectionString)
|
||||
{
|
||||
Connection connection = new ConnectionClass();
|
||||
try
|
||||
{
|
||||
connection.ConnectionString = connectionString;
|
||||
connection.Open();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (connection.State == 1)
|
||||
{
|
||||
connection.Close();
|
||||
}
|
||||
connection = null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Recordset U8ExcuteRecord(string strSQL)
|
||||
{
|
||||
try
|
||||
{
|
||||
object RecordsAffected;
|
||||
return Conn.Execute(strSQL, out RecordsAffected);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public int U8ExcuteNoneQuery(string strSQL)
|
||||
{
|
||||
try
|
||||
{
|
||||
object RecordsAffected;
|
||||
Conn.Execute(strSQL, out RecordsAffected);
|
||||
return (int)RecordsAffected;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void BeginTrans()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Conn != null)
|
||||
{
|
||||
Conn.BeginTrans();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void RollbackTrans()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Conn != null)
|
||||
{
|
||||
Conn.RollbackTrans();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void CommitTrans()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Conn != null)
|
||||
{
|
||||
Conn.CommitTrans();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Conn != null)
|
||||
{
|
||||
if (Conn.State == 1)
|
||||
{
|
||||
Conn.Close();
|
||||
}
|
||||
Conn = null;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user