c#从列表中过滤员工id以修改查询

本文关键字:id 修改 查询 列表 过滤 | 更新日期: 2023-09-27 18:10:34

在这里学习c#。我有一个每月处理表单,其中可以选择处理所有员工的工资,也可以使用单选按钮选择要处理的员工(SAP B1表单使用screenpainter)。

可以打开一个表单来选择员工,员工ID被发送到这个月度流程表单并存储在一个列表中。

//Method to retrieve string values from child form
public void GetFilteredIds(List<string> idValues)
{
    List<string> employeeIDs = new List<string>();
    employeeIDs = idValues;
}

我想在选择所有 emp id

的每月流程表单上过滤此查询
//Query database
var salaryFitments = salaryFitmentService.GetAllSalaryFitments();
var employeeIdList = (from sf in salaryFitments select sf.U_Employee_ID).Distinct();

这样我就有了类似的东西:

var k = from id in employeeIdList
           where employeeIDs.Contains(id)
           select id;

我如何编写我的代码,以便在处理之前(点击进程按钮),我有一个if语句来检查它是否为所有或只是几个选定的每月进程

if (_selectedEmployees.Selected == true)
{
   ...code to write
}
else
{
   ...code to write
}

_selecteemployees指private SAPbouiCOM.OptionBtn _selectedEmployees;

处理前

if (employeeIdList.Any())
            {  ............

我希望我的问题足够清楚

c#从列表中过滤员工id以修改查询

不能100%确定你在找什么,但是这会有帮助吗:

// Code to see if the 'all employees' radiobutton is selected.
var k = from id in employeeIdList
        where AllSelected || employeeIDs.Contains(id)
        select id;