OOP C# and MA

Language
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.

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.

Tags

Comments

select to print, began install help me

Add new comment