⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 imanager.cs

📁 一个通用的数据库访问层
💻 CS
字号:
using System;
using System.Data;
using System.Data.OleDb;
using System.Windows.Forms;
using YariSoft.DBUtil;

namespace YariSoft.DBCommander
{
	public class IManager
	{
		#region Loacal variables
		protected OleDbConnection connecton = null;
		protected SchemaGenerator schema	= null;
		protected bool _initialized			= false;
		protected bool needRefresh			= false;
		private ConnectionState previousConnectionState;
		#endregion

		#region Properties
		public bool Initialized
		{
			get{ return this._initialized; }
		}
		public bool NeedRefresh
		{
			get { return this.needRefresh; }
		}
		#endregion

		#region Constructor/Destructor
		public IManager( OleDbConnection Connecton, SchemaGenerator SchemaGenerator )
		{
			this.connecton = Connecton;
			this.schema = SchemaGenerator;
		}

		public virtual void Dispose(){

		}
		#endregion

		#region Protected functions
		protected bool OpenConnection()
		{
			this.previousConnectionState = this.connecton.State;

			bool result = true;
			try {
				if( previousConnectionState == ConnectionState.Closed ){
					this.connecton.Open();
				}
			} catch(Exception Exp ) {
				YariSoft.Utils.YMessages.Show( Exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error );
				result = false;
			}
			return result;
		}

		protected bool CloseConnection()
		{
			bool result = true;
			try {
				if( previousConnectionState == ConnectionState.Closed ){
					this.connecton.Close();
				}
			} catch(Exception Exp ) {
				YariSoft.Utils.YMessages.Show( Exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error );
				result = false;
			}
			return result;
		}
		#endregion

		#region Public functions
		public virtual DataView FillData( object SelectValue )
		{
			this._initialized = true;
			return null;
		}

		public virtual DataView GetData( object SelectValue )
		{
			return null;
		}

		public virtual DataView RefreshData( object SelectValue )
		{
			return null;
		}

		public virtual bool FillTableDataByFK ( string FKName )
		{
			return true;
		}

		public virtual bool UpdateData( object UpdateObject )
		{
			return true;
		}

		#endregion
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -