OOP C# and MA

Submitted by: 
Language: 
Visitors have accessed this post 4679 times.

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.  
  9. namespace employeesapp
  10. {
  11. class employee
  12. {
  13. public string EmpID;
  14. public string Name;
  15. public string Jobtitle;
  16. public string Company;
  17.  
  18. public DataSet get()
  19. {
  20. OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\Employees.mdb");
  21. conn.Open();
  22.  
  23. OleDbDataAdapter da = new OleDbDataAdapter("Select * From employee", conn);
  24.  
  25. DataSet ds = new DataSet();
  26.  
  27. da.Fill(ds);
  28. return ds;
  29. }
  30.  
  31. public void AddNew()
  32. {
  33. OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\Employees.mdb");
  34. conn.Open();
  35. OleDbCommand cmd = new OleDbCommand("Insert Into employee([Name],[Jobtitle],[Company])Values ('" + Name + "','" + Jobtitle + "','" + Company + "')", conn);
  36. cmd.ExecuteNonQuery();
  37.  
  38.  
  39. }
  40. public void Update()
  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("Update employee([Name],[Jobtitle],[Company])Values ('" + Name + "','" + Jobtitle + "','" + Company + "')",conn);
  45. OleDbCommand cmd = new OleDbCommand(" Update employee set ([Name],[Jobtitle],[Company])Values ('" + Name + "','" + Jobtitle + "','" + Company + "' where EmpID='" + EmpID + "')", conn);
  46. cmd.ExecuteNonQuery();
  47.  
  48.  
  49. }
  50.  
  51. public void Delete()
  52. {
  53. OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\Employees.mdb");
  54. conn.Open();
  55. OleDbCommand cmd = new OleDbCommand("DELETE *FROM employee Where Name = '" + Name + "'", conn);
  56. cmd.ExecuteNonQuery();
  57.  
  58. }
  59.  
  60.  
  61.  
  62.  
  63. }
  64. }

Hope you learn from this.


Tags: 

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.

Comments

select to print, began install help me

Dear meftah, its really a neat and trim explanation.

asp.net

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.