N-Tier in C# (2.0)-VBForums
Results 1 to 18 of 18

Thread: N-Tier in C# (2.0)

  1. #1

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Candon City, Ilocos Sur, Phils.
    Posts
    10,810

    Arrow N-Tier in C# (2.0)

    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...
    Attached Files Attached Files
    Last edited by dee-u; Feb 20th, 2006 at 06:32 PM.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  2. #2
    Addicted Member
    Join Date
    Feb 2006
    Posts
    182

    Re: N-Tier in C# (2.0)

    Quote Originally Posted by dee-u
    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 ..........................

    Is it C Programming? I need Visual Basic.

  3. #3
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,983

    Re: N-Tier in C# (2.0)

    Quote Originally Posted by r_amin
    Is it C Programming? I need Visual Basic.
    Since it's in the C# Codebank, the code would be in C# (it's also in his title).

    You could always make a DLL with the C# code, compile it and then reference that in your VB application
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  4. #4

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Candon City, Ilocos Sur, Phils.
    Posts
    10,810

    Re: N-Tier in C# (2.0)

    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...
    Attached Files Attached Files
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Candon City, Ilocos Sur, Phils.
    Posts
    10,810

    Re: N-Tier in C# (2.0)

    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!
    Attached Files Attached Files
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  6. #6
    New Member
    Join Date
    May 2006
    Posts
    6

    Re: N-Tier in C# (2.0)

    Hi there,

    Are you progressing on the N-tier thingy ? I'm curious about that.

    Greets

  7. #7
    Addicted Member
    Join Date
    Jan 2006
    Location
    Bangalore
    Posts
    172

    Re: N-Tier in C# (2.0)

    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:
    1. public class OracleServerDatabase : DataAccess.Methods
    2.                     {
    3.                      public OracleServerDatabase(string connectionString)
    4.                           : base("Oracle Server", connectionString)
    5.                      }

    But i really do not know where i can set it ...

    Please tell me how can i connect..



    Quote 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!

  8. #8
    New Member
    Join Date
    Apr 2007
    Posts
    2

    Re: N-Tier in C# (2.0)

    Dear Mr,

    how if i want to select a list that contain a where clause (for ex: select * from employee where LastName like 'ABC'), i have tried, but still have an error (on parameter that given)..

    thanks

    regards

    Andy

  9. #9
    New Member
    Join Date
    May 2006
    Posts
    6

    Re: N-Tier in C# (2.0)

    Hi there,

    What exactly is the problem then ?

    Greets MM

  10. #10
    New Member
    Join Date
    Apr 2007
    Posts
    2

    Re: N-Tier in C# (2.0)

    here is my some problems:
    public static List<Entities.GUI.MenusProgram> LoadTab (Entities.QueryGenerator query)
    query.SetTableName = "MenusProgram";
    query.AddWhereField(Entities.GUI.MenusProgram.MenusProgramField.MnuTab.ToString(), "H R D", Entities.QueryGenerator.Operand.Like);
    List<Entities.GUI.MenusProgram> MenusProgramCollection = _dataPortal.FetchMany(query.GetSelectSql(), query.WhereFields);
    return MenusProgramCollection;
    }

    and caled by this code

    Entities.QueryGenerator query = new Entities.QueryGenerator();
    query.IncludeField(Entities.GUI.MenusProgram.MenusProgramField.MnuTab.ToString());
    query.AddOrderBy(Entities.GUI.MenusProgram.MenusProgramField.MnuTab.ToString(), "ASC");

    List<Entities.GUI.MenusProgram> MenusPrograms = BusinessLogic.GUI.MenusProgramManager.LoadTab(query);

    i get a problem, when adding ...query.AddWhereField(Entities.GUI.MenusProgram.MenusProgramField.MnuTab.ToString(), "H R D", Entities.QueryGenerator.Operand.Like);

    i just want to retrieve some records, but with some criteria, with Like, =, etc..

    thanks,
    regards


    andy

  11. #11

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Candon City, Ilocos Sur, Phils.
    Posts
    10,810

    Re: N-Tier in C# (2.0)

    What sort of problem are you encountering?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  12. #12
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: N-Tier in C# (2.0)

    There is so much zip file Can I know What is the final ZIp File??

  13. #13
    Member
    Join Date
    May 2007
    Posts
    32

    Re: N-Tier in C# (2.0)

    hi dee u

    thank you for the awsum sample..it was alot of help to me..

    but i have a little question

    Code:
    protected Methods(string databaseType) : base(databaseType)
            {}
    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..

  14. #14
    New Member
    Join Date
    May 2007
    Posts
    1

    Re: N-Tier in C# (2.0)

    where is the C:\dee_u.mdb access file for this sample

    thanks

  15. #15
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,727

    Re: N-Tier in C# (2.0)

    Quote Originally Posted by smhaig
    where is the C:\dee_u.mdb access file for this sample

    thanks
    Read the very last sentence of the first post and get the first attatchment.

    BTW, welcome to VBForums !
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  16. #16
    Member
    Join Date
    May 2007
    Posts
    32

    Re: N-Tier in C# (2.0)

    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()
    what is the resolution for this helpppp

  17. #17

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Candon City, Ilocos Sur, Phils.
    Posts
    10,810

    Thumbs up Re: N-Tier in C# (2.0)

    This past days I have got time to tinker with the code and here it is...

    New Features:
    -added inserting images, both from using camera and loading selected picture
    -can now connect both to MS Access and SQL Server 2000
    -can now utilize queries/stored procedures to add/edit/delete records
    -integrated with a simple login menu and splash screen
    -improved architecture
    -bug fixes
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  18. #18
    New Member
    Join Date
    Feb 2008
    Posts
    1

    Re: N-Tier in C# (2.0)

    Is there any chance to post here a zip with the last source code?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.