2011-10-07 52 views
0

在此處學習C#。我有一個月度處理表單,可以選擇爲所有員工處理薪水,或者選擇要使用單選按鈕處理的員工(使用screenpainter的SAP B1表單)。C#從列表中篩選員工ID以修改查詢

一個可以打開表單來選擇員工,並將員工ID發送到每月處理表單並存儲在一個列表中。

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

    employeeIDs = idValues; 
} 

我想是選擇ALL EMP標識

//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語句來檢查它是每月處理所有還是僅僅幾個選擇d

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

_selectedEmployees指private SAPbouiCOM.OptionBtn _selectedEmployees;

只是處理

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

我希望我的問題是不夠清楚之前

回答

0

不是100%肯定你以後,但這樣做幫助:

// Code to see if the 'all employees' radiobutton is selected. 

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

然後您不必重複您的查詢。