AbstractDataManager.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:2k
- using System;
- using System.Data;
- using System.Data.SqlClient;
- using System.Web;
- using System.Web.UI;
- using com.etong.SqlDataConnect;
- namespace com.etong.BusinessRule.Zwf
- {
- /// <summary>
- /// AbstractDataManager 的摘要说明。
- /// </summary>
- public abstract class AbstractDataManager
- {
- public AbstractDataManager()
- {
- //
- // TODO: 在此处添加构造函数逻辑
- //
- }
- MSSqlDataAccess MSDA = new MSSqlDataAccess(0);
- public virtual bool insert(string InsSQL,QueryParameterCollection insParams,CommandType commandtype)
- {
- MSDA.Open();
- SqlTransaction tran = MSDA.BeginTransaction();
- try
- {
- MSDA.ExecuteNonQuery(commandtype,InsSQL,insParams);
- tran.Commit();
- return true;
- }
- catch
- {
- tran.Rollback();
- throw;
- // return false;
- }
- finally
- {
- MSDA.Close();
- }
- }
- public virtual DataSet Search(string searchSQL,QueryParameterCollection searchParams ,CommandType commandtype)
- {
- DataSet ds = new DataSet();
- MSDA.Open();
- SqlTransaction tran = MSDA.BeginTransaction();
- try
- {
- MSDA.ExecuteDataset(commandtype,searchSQL,searchParams,ds,"");
- tran.Commit();
- return ds;
- }
- catch
- {
- tran.Rollback();
- return null;
- }
- finally
- {
- MSDA.Close();
- }
-
- }
- public virtual bool Update(string updSQL,QueryParameterCollection updParams,CommandType commandtype)
- {
- MSDA.Open();
- // MSDA.ExecuteNonQuery(commandtype,updSQL,updParams);
- // MSDA.Close();
- // return true;
- SqlTransaction tran = MSDA.BeginTransaction();
- try
- {
- MSDA.ExecuteNonQuery(commandtype,updSQL,updParams);
- tran.Commit();
- return true;
- }
- catch
- {
- tran.Rollback();
- throw;
- // return false;
- }
- finally
- {
- MSDA.Close();
- }
- }
- public virtual bool Delete(string delSQL ,QueryParameterCollection delParams,CommandType commandtype)
- {
- MSDA.Open();
- SqlTransaction tran = MSDA.BeginTransaction();
- try
- {
- MSDA.ExecuteNonQuery(commandtype,delSQL,delParams);
- tran.Commit();
- return true;
- }
- catch
- {
- tran.Rollback();
- return false;
- }
- finally
- {
- MSDA.Close();
- }
- }
- }
- }