using System;
using System.Data;
using System.Data.OleDb;
using System.Text;
using Medivators.BusinessObjects;

namespace Medivators.Data
{

	public delegate void SelectCompleteEventHandler ( object sender, SelectCompleteEventArgs e);
	public delegate void DataExceptionEventHandler(object sender, DataExceptionEventArgs e);
	public delegate void InsertCompleteEventHandler(object sender, InsertCompleteEventArgs e);

	public class SelectCompleteEventArgs : EventArgs
	{
		private string _sql = string.Empty;		
		private IDataMapper _data = null;
		private long _operationID = 0;

		public SelectCompleteEventArgs(string SQL, IDataMapper Data, long DataOperationID)
		{
			_sql = SQL;
			_data = Data;
			_operationID = DataOperationID;
		}
		public long DataOperationID
		{
			get { return _operationID; }
			set { _operationID = value; }
		}
		public string SQL
		{
			get { return _sql; }
			set { _sql = value; }
		}
		public IDataMapper Data 
		{
			get { return _data; }
			set { _data = value; }
		}
		public override string ToString()
		{
			return string.Format("{0}: \r\nID={1}\r\nSQL={2}\r\nData={3}", 
							     this.GetType().Name, 
								 this._operationID, 
								 this._sql, 
								 this._data);
		}
	}
	public class DataExceptionEventArgs : EventArgs
	{
		private Exception _ex = null;
		private string _sql = string.Empty;
		private long _operationID = 0;

		public DataExceptionEventArgs(string SQL, Exception Ex, long DataOperationID)
		{
			_ex = Ex;
			_sql = SQL;
			_operationID = DataOperationID;
		}
		public long DataOperationID
		{
			get { return _operationID; }
			set { _operationID = value; }
		}
		public string SQL
		{
			get { return _sql; }
			set { _sql = value; }
		}
		public Exception Ex
		{
			get { return _ex; }
			set { _ex = value; }
		}
		public override string ToString()
		{
			return string.Format("{0}: \r\nID={1}\r\nSQL={2}\r\nException={3}",
								 this.GetType().Name,
								 this._operationID,
								 this._sql,
								 this._ex.ToString());
		}
	}
	public class InsertCompleteEventArgs : EventArgs
	{
		private string _sql = string.Empty;
		private int _count = 0;
		private long _operationID = 0;

		public InsertCompleteEventArgs(string SQL, int RecordsAffected, long DataOperationID)
		{
			_sql = SQL;
			_count = RecordsAffected;
			_operationID = DataOperationID;
		}
		public long DataOperationID
		{
			get { return _operationID; }
			set { _operationID = value; }
		}
		public string SQL
		{
			get { return _sql; }
			set { _sql = value; }
		}
		public int RowsAffected
		{
			get { return _count; }
			set { _count = value; }
		}
		public override string ToString()
		{
			return string.Format("{0}: \r\nID={1}\r\nSQL={2}\r\nRowsAffected={3}",
								 this.GetType().Name,
								 this._operationID,
								 this._sql,
								 this._count.ToString());
		}
	}
}
