0% found this document useful (0 votes)
70 views4 pages

Programs - CS: Using Using Using Using Using Using Namespace Class New Public Static Void

The document contains code for an employee management system (EMS) that allows users to perform CRUD (create, read, update, delete) operations on employee records. It includes classes for the employee data model, exceptions, and data access layer. The main Program class contains a menu and switch statement to call the appropriate method for selected operations like adding, updating, deleting an employee.

Uploaded by

yeshwanth kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views4 pages

Programs - CS: Using Using Using Using Using Using Namespace Class New Public Static Void

The document contains code for an employee management system (EMS) that allows users to perform CRUD (create, read, update, delete) operations on employee records. It includes classes for the employee data model, exceptions, and data access layer. The main Program class contains a menu and switch statement to call the appropriate method for selected operations like adding, updating, deleting an employee.

Uploaded by

yeshwanth kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Programs.

cs

using EMP.DAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EMS
{
class Program
{
EMPDataAccess eMPDataAccess = new EMPDataAccess();
public static void GetMENU()
{
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine("welcome to EMS");
Console.WriteLine("Please select the below options");
Console.WriteLine("**********************************************");
Console.WriteLine("**********Menu List*********************");
Console.WriteLine("**********************************************");
Console.WriteLine("1.Add Employee");
Console.WriteLine("2.Update Employee");
Console.WriteLine("3.Delete Employee");
Console.WriteLine("4.Get List of Employee");
}
public static void Add()
{
Console.WriteLine("Id");
int id = int.Parse(Console.ReadLine());
Console.WriteLine("Name");
String Name = Console.ReadLine();
Console.WriteLine("Loc");
String Loc = Console.ReadLine();
Console.WriteLine("Sal");
int Sal = int.Parse(Console.ReadLine());
Console.WriteLine("DeptId");
int DeptId = int.Parse(Console.ReadLine());
EMPDataAccess.AddEmp(id, Name, Loc, Sal, DeptId);
}
private static void Update()
{

}
private static void Delete()
{

}
private static void GetAll()
{

}
static void Main(string[] args)
{
GetMENU();
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Please enter your option");
int option = int.Parse(Console.ReadLine());
switch (option)
{

case 1:
Add();
break;
case 2:
Update();
break;
case 3:
Delete();
break;
case 4:
GetAll();
break;
default:
Console.WriteLine("option is invalid");
break;
}
}

}
}

Employee.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

nnamespace EMP.Entities
{
public class Employee
{
public int ID { get; set; }
public int Name { get; set; }
public int Location { get; set; }
public int Salary { get; set; }
public int DeptID { get; set; }
}
}

Emp.Exceptions.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EMP.Exceptions
{
public class EMPExceptions : Exception
{
public EMPExceptions() : base()
{

}
public EMPExceptions(string msg) : base(msg)
{

}
}
}

EMPDAL.cs
using EMP.Entities;
using EMP.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EMP.DAL
{
public class EMPDataAccess
{
private List<Employee> employeeslist;

//public static List<Employee> employeeslist=new List<Employee>();


public List<Employee> GetAllEmployees()
{
return employeeslist;
}
public static bool AddEmp(int id, string name, string loc, int sal, int
deptid)
{
try
{
//employeeslisT.Add(new Employee()
{ID=id,Name=name,Location=loc,Salary=sal,DeptID=deptid});
return true;
}
catch (ApplicationException e)
{
throw new EMPExceptions();
}
}
public void UpdateEmp(int id, string name, string loc, int sal, int deptid)
{

}
public bool DeleteEmp(int id)
{
try
{

Employee deleteemployee = employeeslist.Find(x => x.ID == id);


employeeslist.Remove(deleteemployee);
return true;
}
catch
{
return false;
}
}
}
}

You might also like