2017-02-01 54 views
-3

您好我有一個服務檯應用的最高和最低數目,我有填充拿起它自動綁定表示分配給每個的這些管理代理列表中的另一個下拉的值的類別和用戶列表下拉類別。得到在陣列

現在的問題是,如果超過1個管理代理被分配到一個分類類別,我希望能夠計算每個代理之前打開的票的總數,並獲得最低的所有和綁定最低的下拉文本的票數。所以不需要用戶選擇管理代理來分配工作。 繼承人我的code.pls幫助。

------------------category dropdown that binds assigness dropdown----------- 
    Protected Sub ddlcategory_SelectedIndexChanged(sender As Object, e As EventArgs) 
     Dim TK As GHD5.TicketCategory = (New cls_ticketcategories).SelectThisID(ddlcategory.SelectedValue) 
     mod_filldropdowns.FillAssignees(ddlassignee, TK.CategoryID) 
     If ddlassignee.Items.Count = 0 Then 
      Msgbox1.ShowHelp("No Agent for " & ddlcategory.SelectedValue & "") 
      'ElseIf ddlassignee.Items.Count > 1 Then 
      ' For Each rec As GHD5.User In ddlassignee.Items 
      '  select * from tickets where status is 'open' and assigne = list of assigness 
        count() 
        get lowest number in each record retun 
bind dropdown with assignee username 

      ' Next 
      Exit Sub 

     End If 
    End Sub 


-------code to fill assigness dropdown based on category ID selected----------------- 

    Public Sub FillAssignees(ByVal cb As ASPxComboBox, ByVal categoryid As Integer) 
     Dim obj As List(Of GHD5.User) = (New cls_users).SelectuserbycategoryID(categoryid) 

     cb.DataSource = obj 
     cb.Columns.Clear() 
     cb.Columns.Add("UserID").Width = 50 
     cb.Columns.Add("Username").Width = 100 
     cb.Columns.Add("firstname").Width = 100 
     cb.Columns.Add("Lastname").Width = 150 
     cb.ValueField = "Username" 
     cb.TextField = "UserID" 
     cb.TextFormatString = "{0},{1}" 
     cb.DataBind() 

    End Sub 

回答

0

您可以使用數組和列表Min()Max()

int[] array = new int[] { 1, 3, 15, 7, 9 }; 

int min = array.Min(); 
int max = array.Max(); 


List<int> list = new List<int>() { 1, 3, 15, 7, 9 }; 

int min = list.Max(); 
int max = list.Max(); 
+0

那麼請如何在這些代碼塊之間使用它來解決這個問題。 – Martin