[英]how do I add employee ID and create collection and list for employees?
public class Employee : IEmployee
{
public string FirstName { get; set; }
public string LastName { get; set; }
public DateTime StartDate { get; set; }
public PayFrequency PayFrequency { get; set; }
public decimal Salary { get; set; }
public SickPay SickPay { get; set; }
//create collection and list for employees
//create employee
//view employee
//update employee
//delete employee
//add employee ID
public static IEmployee CreateEmployee(string fName, string lName, DateTime startDate, PayFrequency payFrequency, decimal salary, SickPay sickPay)
{
Employee employee = new Employee();
employee.FirstName = fName;
employee.LastName = lName;
employee.StartDate = startDate;
employee.PayFrequency = payFrequency;
employee.Salary = salary;
employee.SickPay = sickPay;
return employee;
}
}
I have this code and I need to add an employee ID
and create a collection and list for employees to show on console, but I am not sure how to do it.我有这段代码,我需要添加一个员工ID
并为员工创建一个集合和列表以显示在控制台上,但我不确定该怎么做。
void IEmployee.AddDeduction(Deduction type)
{
//switch case or if else,
//based on the deduction type calculate the deduction
}
decimal IEmployee.CalculateLabourCost(DateTime weekStart, int hours, int minutes, decimal sickdays)
{
//Calculate salary logic
return 0;
}
This is also part of it.这也是其中的一部分。 I need to calculate their salary, but I am not sure how do I do it either.我需要计算他们的薪水,但我也不确定该怎么做。 I am not sure how to start the calculation.我不确定如何开始计算。 I want to calculate the employees salary according to their pay frequency and any deductions or any schemes.我想根据他们的支付频率和任何扣除或任何计划来计算员工的工资。
In your code, In properties add EmployeeId as string datatype like在您的代码中,在属性中将 EmployeeId 添加为字符串数据类型,例如
public string EmployeeId {get;set;}.
In CreateEmployee()
method update your code as在CreateEmployee()
方法中将您的代码更新为
Guid guid = Guid.NewGuid();
EmployeeId=guid.ToString();
here, everytime new employee is created guid generate a unique id and stores in EmployeeId Guid generates a unique id everytime is called.在这里,每次创建新员工时,guid 都会生成一个唯一的 id 并存储在 EmployeeId 中,每次调用 Guid 都会生成一个唯一的 id。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.