imanager.cs

来自「一个通用的数据库访问层」· CS 代码 · 共 104 行

CS
104
字号
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 + =
减小字号Ctrl + -
显示快捷键?