Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have 3 columns, the first is for the seller, the second is for completing the deal, and the third is for not completing it. I want to know how many deals were made or were not done for each employee through the coordination shown in the picture. This code give me the totale only Capture — imgbb.com[^]

What I have tried:

C#
DataTable numOfCalls2Table = new DataTable();
numOfCalls2Table.Columns.Add("SalesPerson", typeof(string));
numOfCalls2Table.Columns.Add("Scour", typeof(int));
numOfCalls2Table.Columns.Add("Dealclosed", typeof(int));
numOfCalls2Table.Columns.Add("Dealnotclosed", typeof(int));
DataView view = new DataView(table);
DataTable distinctValues = view.ToTable(true, "SalesPerson", "Dealclosed", "Dealnotclosed");           
if (distinctValues.Rows.Count > 0)
{

    for (int i = 0; i < distinctValues.Rows.Count; i++)
    {
        string agentName = distinctValues.Rows[i]["SalesPerson"].ToString();
        string dealclosed = distinctValues.Rows[i]["Dealclosed"].ToString();
        string dealnotclosed = distinctValues.Rows[i]["Dealnotclosed"].ToString();                   
        DataRow[] agentRows = table.Select($"SalesPerson='{ agentName}'");
        DataRow[] dealtyperow = table.Select($"Dealclosed='{ dealclosed}'");
        DataRow[] dealtyperow2 = table.Select($"Dealnotclosed='{ dealnotclosed}'");
        DataRow newRow = numOfCalls2Table.NewRow();
        newRow["SalesPerson"] = agentName;
        newRow["Scour"] = agentRows.Length;
        newRow["Dealclosed"] = dealtyperow.Length;
        newRow["Dealnotclosed"] = dealtyperow2.Length;
        numOfCalls2Table.Rows.Add(newRow);
    }
}

return numOfCalls2Table;

This code give me total data done and not done in ahmed and mark i want to know about ahmed and Mark only how many row done in dealclosed and how many not done in dealnotclosed.
Posted
Updated 24-Jan-20 2:28am
v2
Comments
OriginalGriff 24-Jan-20 8:22am    
And?
What have you tried?
Where are you stuck?
What help do you need?
Member 14634823 24-Jan-20 8:29am    
This code give me total data done and not done in ahmed and mark i want to know about Ahmed and Mark only how many row done in dealclosed and how many not done in dealnotclosed check this link https://ibb.co/njTk5nH
OriginalGriff 24-Jan-20 8:44am    
And?
What have you tried?
Where are you stuck?
What help do you need?
Member 14634823 24-Jan-20 8:54am    
the code is work .no problem but i want to update it to how meny emp make deal or not in dgv2 my code give me ahmed have 4 action ,Mark 4 action but in deal closed its give me all emp action done and not done to ahmed only
Richard MacCutchan 24-Jan-20 10:34am    
The column headings on the right hand view are not correct. The numbers in the left hand view look as if they are correct.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900