• We just launched and are currently in beta. Join us as we build and grow the community.

OOP C# and MA

Mae

Pipeline Automation Expert
M Rep
0
0
0
Rep
0
M Vouches
0
0
0
Vouches
0
Posts
118
Likes
153
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
This is an example project using OOP C#. Hope this system can help you in your future project. Below are codes used in this system.

  1. using

    System

    ;
  2. using

    System.Collections.Generic

    ;
  3. using

    System.Linq

    ;
  4. using

    System.Text

    ;
  5. using

    System.Data

    ;
  6. using

    System.Data.OleDb

    ;
  7. using

    System.Collections

    ;

  8. namespace

    employeesapp
  9. {
  10. class

    employee
  11. {
  12. public

    string

    EmpID;
  13. public

    string

    Name;
  14. public

    string

    Jobtitle;
  15. public

    string

    Company;

  16. public

    DataSet get

    (

    )
  17. {
  18. OleDbConnection conn =

    new

    OleDbConnection(

    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\

    Employees.mdb"

    )

    ;
  19. conn.

    Open

    (

    )

    ;

  20. OleDbDataAdapter da =

    new

    OleDbDataAdapter(

    "Select * From employee"

    , conn)

    ;

  21. DataSet ds =

    new

    DataSet(

    )

    ;

  22. da.

    Fill

    (

    ds)

    ;
  23. return

    ds;
  24. }

  25. public

    void

    AddNew(

    )
  26. {
  27. OleDbConnection conn =

    new

    OleDbConnection(

    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\

    Employees.mdb"

    )

    ;
  28. conn.

    Open

    (

    )

    ;
  29. OleDbCommand cmd =

    new

    OleDbCommand(

    "Insert Into employee([Name],[Jobtitle],[Company])Values ('"

    +

    Name +

    "','"

    +

    Jobtitle +

    "','"

    +

    Company +

    "')"

    , conn)

    ;
  30. cmd.

    ExecuteNonQuery

    (

    )

    ;


  31. }
  32. public

    void

    Update(

    )
  33. {
  34. OleDbConnection conn =

    new

    OleDbConnection(

    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\

    Employees.mdb"

    )

    ;
  35. conn.

    Open

    (

    )

    ;
  36. //OleDbCommand cmd = new OleDbCommand("Update employee([Name],[Jobtitle],[Company])Values ('" + Name + "','" + Jobtitle + "','" + Company + "')",conn);
  37. OleDbCommand cmd =

    new

    OleDbCommand(

    " Update employee set ([Name],[Jobtitle],[Company])Values ('"

    +

    Name +

    "','"

    +

    Jobtitle +

    "','"

    +

    Company +

    "' where EmpID='"

    +

    EmpID +

    "')"

    , conn)

    ;
  38. cmd.

    ExecuteNonQuery

    (

    )

    ;


  39. }

  40. public

    void

    Delete(

    )
  41. {
  42. OleDbConnection conn =

    new

    OleDbConnection(

    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\

    Employees.mdb"

    )

    ;
  43. conn.

    Open

    (

    )

    ;
  44. OleDbCommand cmd =

    new

    OleDbCommand(

    "DELETE *FROM employee Where Name = '"

    +

    Name +

    "'"

    , conn)

    ;
  45. cmd.

    ExecuteNonQuery

    (

    )

    ;

  46. }




  47. }
  48. }

Hope you learn from this.

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.

2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.


Download
You must upgrade your account or reply in the thread to view hidden text.
 

440,010

316,559

316,568

Top