简体   繁体   English

如何添加员工 ID 并为员工创建集合和列表?

[英]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 asCreateEmployee()方法中将您的代码更新为

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.

相关问题 如何使用.net Web API从员工列表中获取最新的员工ID(字符串) - How can I get latest employee ID (string) from the list of employees using .net web api Get call 如何根据员工收入中员工薪水排名第二的基于身份证的LINQ选择不同的员工? - How to select distinct employees with LINQ based on ID from an employee collection where employee 's salary is 2nd highest? 如何将角色列表的role_Id元素添加到员工列表中? - How to add role_Id element of role List to employee List? 如何通过员工 ID 将员工添加到项目中 - How to add employee to project by employee id 什么“ <employee> “在以下代码中表示:列表 <Employee><employee> 员工=新名单 <Employee><employee> (); - What does “<employee>” mean in the following code: List<Employee><employee> employees = new List<Employee><employee>(); 如何从json数组创建List集合? - How do i create a List collection from a json array? 我如何纠正&#39;qual.employee_id =人才招聘.employee_id中的错误“无法将类型&#39;int&#39;隐式转换为&#39;string&#39;”; &#39;? - How do I correct the error “cannot implicitly convert type 'int' to 'string'” in ' qual.employee_id = recruitment.employee_id; '? 创建班级Employee并使用SELECT将所有雇员带到GridView - Create class Employee and Get all employees to a GridView using SELECT 在反序列化 JSON 员工后,我的列表包含一个 null 员工 - My list contains a single null employee after deserializing a JSON of employees 如何为集合添加功能? - How do I add a function to a collection?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM