This small app is a demo of N-Tier using C#. I haven't got a chance yet to do a full-pledge app in C# hence I played with this as a preparation for any impending projects I would tackle using C#.
The base class in DAL uses Factory Class to create a connection object base on the type of derived class, whether it is MS Access or SQL Server; reusabilty is what I have in mind when I decided to go on this design. The DAL also have support for transaction which can be triggered by method SetTransaction, CommitTransaction and RollbackTransaction. I have added in DAL the most common functions I use when dealing with database.
The BLL contains the Entity representation of an Employee and the CRUD operations. It also got an AuditLog where all CRUD operations will be logged in another database; when updating records all changed columns will also be logged. In BLL there is also stuff for Compacting, Repairing and backing-up Access database. Concurrency checking is also supported using the RowVersion method.
There are little thing that I did in the UI that may serve useful to 'newbies' out there like changing the color of the textbox in focus, moving to the next control when hitting the Enter key and moving to the previous control when hitting the Up key, etc...
This also have an Exception Logger where any exceptions can be logged in the Event Log and in a text file.
So check this out! Any comments/criticisms/feedbacks will be highly appreciated. :-)
BTW, just place the two MS Access database in your C:\Drive...
Last edited by dee-u; Feb 20th, 2006 at 07:32 PM.
Regards,
™
As a gesture of gratitude please consider rating helpful posts. c",)
This small app is a demo of N-Tier using C#. I haven't got a chance yet to do a full-pledge app in C# hence I played with this as a preparation for any impending projects I would tackle using C#.
The base class in DAL uses Factory Class to create a connection object base on the type of derived class, whether it is MS Access or SQL Server; reusabilty is what I have in mind when I decided to go on this design. The DAL also have support for transaction which can be triggered by method SetTransaction, CommitTransaction and RollbackTransaction. I have added in DAL the most common functions ..........................
I made the ff. utility to create .cs files out of your Access database just how I did it in the program I cited above... I hope one way or another this my serve useful...
Regards,
™
As a gesture of gratitude please consider rating helpful posts. c",)
Newer version with improved architecture though it's not yet complete as I am still refining my pattern based on some feedbacks from friends out there... Kamusta mga kabayan!
Regards,
™
As a gesture of gratitude please consider rating helpful posts. c",)
Hi
Nice to know about your work. I need some connection help from you regarding your code. You have used MS Access. I would like to connect Oracle DataBase. In DataAccessType Class i can see SQL and MS Access. I would like to add Oracle here. I tried following Code
VB Code:
public class OracleServerDatabase : DataAccess.Methods
{
public OracleServerDatabase(string connectionString)
: base("Oracle Server", connectionString)
}
But i really do not know where i can set it ...
Please tell me how can i connect..
Originally Posted by dee-u
Newer version with improved architecture though it's not yet complete as I am still refining my pattern based on some feedbacks from friends out there... Kamusta mga kabayan!
this above code..in your dataaccess.methods class.which creates a method whatever the databaseype which is specified when instantion of the object..
but sorry if im asking a crap..but why do you use that base(databaseType) part in the inhretince part..is that something like a generic type..just asking for clearifications..
is the above code and below are the same or is there anything special happening with the base(databaseTYpe)
Code:
protected Methods(string databaseType) : base
{}
thanx in advance..sorry if im asking a bad question as im a begginer..to c#..im just analaysing your code..
im getting the following error when i try to update a record
Code:
System.InvalidCastException was unhandled
Message="Specified cast is not valid."
Source="BusinessLogic"
StackTrace:
at BusinessLogic.AuditLog.WriteAudit(String affectedTable, String moduleName, String action, String reason, String code, Int32 rowVersion, Employee newEmp, Employee oldEmp) in C:\Users\Aneef\Desktop\stuff\EmployeeRecordsearlyedition\EmployeeRecords\BusinessLogic\BusinessLogic\AuditLog.cs:line 37
at BusinessLogic.EmployeeCRUD.UpdateRecord(Employee newEmp, Employee oldEmp) in C:\Users\Aneef\Desktop\stuff\EmployeeRecordsearlyedition\EmployeeRecords\BusinessLogic\BusinessLogic\EmployeeCRUD.cs:line 179
at ApplicationLayer.frmEmployee.toolStripSave_Click(Object sender, EventArgs e) in C:\Users\Aneef\Desktop\stuff\EmployeeRecordsearlyedition\EmployeeRecords\ApplicationLayer\ApplicationLayer\frmEmployee.cs:line 480
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at ApplicationLayer.Program.Main() in C:\Users\Aneef\Desktop\stuff\EmployeeRecordsearlyedition\EmployeeRecords\ApplicationLayer\ApplicationLayer\Program.cs:line 39
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()