private static void AddNewEmployee(EmployeeRepo employeeRepo) { EmployeeModel employee = new EmployeeModel(); employee.EmployeeName = "Dibya"; employee.Department = "Tech"; employee.PhoneNumber = "6309807918"; employee.Address = "02-Khajauli"; employee.Gender = 'M'; employee.BasicPay = 110000.00M; employee.Deductions = (SqlMoney)1500.00; employee.StartDate = employee.StartDate = Convert.ToDateTime("2020-11-03"); if (employeeRepo.AddEmployee(employee)) { Console.WriteLine("Records added successfully"); } employeeRepo.RemoveEmployee("Satyam", 6); }
static void Main(string[] args) { Console.WriteLine("Welcome to Employee Payroll Service!"); EmployeeRepo employeeRepo = new EmployeeRepo(); EmployeeModel employeeModel = new EmployeeModel(); SalaryUpdateModel updateModel = new SalaryUpdateModel(); ///Get All Employee present in Employee_Payroll table employeeRepo.GetAllEmployee(); ///Update Employee Salary employeeModel.SalaryId = 1; employeeModel.SalaryMonth = "Jan"; employeeModel.Salary = 500000.00; employeeModel.EmpId = 2; employeeRepo.UpdateEmployeeSalary(updateModel); ///Get All Employee in a particular data range employeeRepo.GetAllEmployeeInADataRange(); ///Get data by Gender employeeRepo.GetDataByGroupByGender(); ///Add Employee Details employeeModel.EmpName = "Appu"; employeeModel.Salary = 500000.00; employeeModel.Start_Date = Convert.ToDateTime("12/05/2020"); employeeModel.Gender = 'F'; employeeModel.Phone_Number = "9877553212"; employeeModel.Employee_Address = "Kharadi"; employeeModel.Department = "Tetsing"; employeeModel.Basic_Pay = 8765.00; employeeModel.Deductions = 9876.00; employeeModel.Taxable_Pay = 97765.00; employeeModel.Income_Tax = 7654.00; employeeModel.Net_Pay = 6543.00; employeeModel.EmpId = 6; employeeModel.DeptId = 7; employeeModel.DeptName = "Development"; employeeModel.DeptLocation = "Pune"; employeeModel.SalaryMonth = "Jan"; ///Add Employee in Employee_Payroll table employeeRepo.AddEmployee(employeeModel); ///Remove particular employee entry using EmpId employeeRepo.RemoveEmployee(); ///Get Employee Details present in Employee table employeeRepo.GetAllEmployeeDetails(); ///Get Department details from Department table employeeRepo.GetAllDepartment(); ///Get Salary of Employee from Salary table employeeRepo.GetEmployeeSalary(); ///Get Data by Gender using joins employeeRepo.GetDataByGroupByGenderER(); Console.WriteLine("Employee Payroll using Threads"); ///retrieve url string[] words = CreateWordArray(@"http://www.gutenberg.org/files/54700/54700-0.txt"); #region ParallelTasks Parallel.Invoke (() => { Console.WriteLine("Begin First Task..."); GetLongestWord(words); }, () => { Console.WriteLine("Begin Second Task..."); GetMostCommonWords(words); }, //close second action () => { Console.WriteLine("Begin Third Task..."); GetCountForWord(words, "Sleep"); } //close third action ); //close parallel.invoke #endregion }
static void Main(string[] args) { Console.WriteLine("Welcome To Employee Payroll Service System"); EmployeeRepo repo = new EmployeeRepo(); int loop = 1; while (loop == 1) { Console.WriteLine("Choose \n1. View all records \n2. Add record \n3. Update salary \n4. Retrieve information from name \n5. Retrieve Employees with joining date in a range \n6. Sum of basic pay gender wise \n7. Average of basic pay gender wise \n8. Minimum basic pay gender wise \n9. Maximum basic pay gender wise \n10. Count of employees gender wise \n11. Remove emloyee from active employees \n12. Exit"); int choice = Convert.ToInt32(Console.ReadLine()); switch (choice) { case 1: List <EmployeeModel> employeeList = repo.GetAllEmployee(); foreach (EmployeeModel employeeModel in employeeList) { System.Console.WriteLine(employeeModel.EmployeeName + " " + employeeModel.BasicPay + " " + employeeModel.StartDate + " " + employeeModel.Gender + " " + employeeModel.PhoneNumber + " " + employeeModel.Address + " " + employeeModel.Department + " " + employeeModel.Deductions + " " + employeeModel.TaxablePay + " " + employeeModel.Tax + " " + employeeModel.NetPay); System.Console.WriteLine("\n"); } break; case 2: Console.WriteLine("Enter number of employees to be added"); int noOfEmployeesAdded = Convert.ToInt32(Console.ReadLine()); List <EmployeeModel> list = new List <EmployeeModel>(); while (noOfEmployeesAdded >= 1) { EmployeeModel employee = new EmployeeModel(); Console.WriteLine("Enter Name"); employee.EmployeeName = Console.ReadLine(); Console.WriteLine("Enter Phone Number"); employee.PhoneNumber = Console.ReadLine(); Console.WriteLine("Enter Address"); employee.Address = Console.ReadLine(); Console.WriteLine("Enter Gender"); employee.Gender = Convert.ToChar(Console.ReadLine()); Console.WriteLine("Enter Basic Pay"); employee.BasicPay = Convert.ToDecimal(Console.ReadLine()); Console.WriteLine("Enter Start date"); employee.StartDate = Convert.ToDateTime(Console.ReadLine()); Console.WriteLine("Enter Department"); employee.Department = Console.ReadLine(); Console.WriteLine("Enter department id"); employee.DepartmentId = Convert.ToInt32(Console.ReadLine()); noOfEmployeesAdded--; list.Add(employee); } noOfEmployeesAdded = repo.AddMultipleEmployeesUsingThread(list); break; case 3: Console.WriteLine("Enter Name"); string name = Console.ReadLine(); Console.WriteLine("Enter Basic Pay"); double salary = Convert.ToDouble(Console.ReadLine()); bool result = repo.UpdateSalary(name, salary); Console.WriteLine(result == true ? "Salary Updated" : "Salary cannot be updated"); break; case 4: Console.WriteLine("Enter Name"); string employeeName = Console.ReadLine(); List <EmployeeModel> employeeNameList = repo.RetrieveDataByName(employeeName); foreach (EmployeeModel employeeInfo in employeeNameList) { System.Console.WriteLine(employeeInfo.EmployeeName + " " + employeeInfo.BasicPay + " " + employeeInfo.StartDate + " " + employeeInfo.Gender + " " + employeeInfo.PhoneNumber + " " + employeeInfo.Address + " " + employeeInfo.Department + " " + employeeInfo.Deductions + " " + employeeInfo.TaxablePay + " " + employeeInfo.Tax + " " + employeeInfo.NetPay); System.Console.WriteLine("\n"); } break; case 5: Console.WriteLine("Enter Start date"); DateTime startDate = Convert.ToDateTime(Console.ReadLine()); Console.WriteLine("Enter End date"); DateTime endDate = Convert.ToDateTime(Console.ReadLine()); List <EmployeeModel> employeeWithStartDateList = repo.RetrieveEmployeesWithParticularDateRange(startDate.ToString("yyyy-MM-dd"), endDate.ToString("yyyy-MM-dd")); foreach (EmployeeModel employeeModel in employeeWithStartDateList) { System.Console.WriteLine(employeeModel.EmployeeName + " " + employeeModel.BasicPay + " " + employeeModel.StartDate + " " + employeeModel.Gender + " " + employeeModel.PhoneNumber + " " + employeeModel.Address + " " + employeeModel.Department + " " + employeeModel.Deductions + " " + employeeModel.TaxablePay + " " + employeeModel.Tax + " " + employeeModel.NetPay); System.Console.WriteLine("\n"); } break; case 6: repo.SumOfSalaryGenderWise(); break; case 7: repo.AverageOfSalaryGenderWise(); break; case 8: repo.MinimumSalaryGenderWise(); break; case 9: repo.MaximumSalaryGenderWise(); break; case 10: repo.CountOfEmployeesGenderWise(); break; case 11: Console.WriteLine("Enter employee Id of employee to be removed"); int empId = Convert.ToInt32(Console.ReadLine()); bool employeeRemoved = repo.RemoveEmployee(empId); if (employeeRemoved) { Console.WriteLine("Employee Removed successfully"); } break; case 12: loop = 0; break; } } }