I have been asked to create a system where that can rate colleagues with colours

the colours are as follows starting with the highest first

Gold
Silver
Bronze
Blue
Orange
Black

the colleagues all will start on Orange.

now the tricky part.

If the colleague sells a quantity of 4 a week and had 0 or 1 rejects then he goes up to Blue and so on

But if the colleague sells a quatity of 4 and had 2 rejects then he stays on that colour

if the colleague gets up to silver they need to sell 6 and have 0 rejects to get up to gold.

but if they get any rejects they go back to silver.

ANYONE WITH ANY IDEAS HOW TO DO THIS would be gratefully helpful.

Thanks.

Andy.

Dani AI

Generated

A practical, low-friction way to implement the colour-ranking idea from is:

  • Compute the weekly metrics on the server, persist them, and derive a single Rank value per colleague each week. That makes the UI simple (show a colour/class) and keeps business rules in one place. As suggested, a grid is a good display; as advised, model each person as a Colleague object; and thanks to for the binding hint — just be sure to use parameterized queries and proper disposal of DB resources.

Example VB.NET rank calculator (keeps rules deterministic and easy to test):

Enum Rank
  Black = 0
  Orange = 1
  Blue = 2
  Bronze = 3
  Silver = 4
  Gold = 5
End Enum

Function ComputeRank(current As Rank, sales As Integer, rejects As Integer) As Rank
  Select Case current
    Case Rank.Orange
      If sales >= 4 AndAlso rejects <= 1 Then Return Rank.Blue
      If rejects >= 3 Then Return Rank.Black
    Case Rank.Blue
      If sales >= 4 AndAlso rejects <= 1 Then Return Rank.Bronze
      If rejects >= 2 Then Return Rank.Orange
    Case Rank.Bronze
      If sales >= 4 AndAlso rejects <= 1 Then Return Rank.Silver
      If rejects >= 2 Then Return Rank.Blue
    Case Rank.Silver
      If sales >= 6 AndAlso rejects = 0 Then Return Rank.Gold
      If rejects >= 2 Then Return Rank.Bronze
    Case Rank.Gold
      If rejects > 0 Then Return Rank.Silver
  End Select
  Return current
End Function

Store weekly data (WeeklyMetrics: ColleagueId, WeekStartDate, SalesCount, RejectsCount) and compute aggregates with a simple GROUP BY, then run the rank calculation in a scheduled job or on-write handler. Use transactions to avoid race conditions and a clear week boundary (e.g., ISO week start).

For presentation, set a CSS class for the rank and apply it in the grid-row binding event rather than inlining colors. See the GridView row-binding pattern and always wrap connections in Using blocks for safety: GridView.RowDataBound Using statement (VB).

Recommended Answers

All 4 Replies

Hi

Probably the easiest is to use a datagrid; then you will have to compare the number of sales of the week and change the row accordingly.

Who is going to be inputting the data of the number of sales per peron? probably tat wil be the tricky part.

Hope it helps

Hi

Probably the easiest is to use a datagrid; then you will have to compare the number of sales of the week and change the row accordingly.

Who is going to be inputting the data of the number of sales per peron? probably tat wil be the tricky part.

Hope it helps

how would you code a datagrid to do that???

Have you not been given any training at all?

Do you know how to use Visual Studio to start a project?

Your first task before you code anything is to identify the objects. They become your classes the first obvious one is 'Colleague' do you know how to create a class in VB.NET?

to code in datagrid...
just drag& drop it from toolbox& to colour the datagrid based on the there sales(with orange,green,yellow...etc).use datagrid_itemdatabound function....
--------------------------write this code in pageload& just drop datagrid on form,,,
Private Sub LoadData()
Dim strSQL As String = "SELECT * FROM table1 order by ID "
Dim cnn As String = ConfigurationSettings.AppSettings("preeconn")
Dim cmd As New SqlCommand(strSQL, New SqlConnection(cnn))
cmd.Connection.Open()
Dim myCommand As New SqlDataAdapter(strSQL, cnn)
Dim ds As New DataSet
myCommand.Fill(ds, "table1")
datagrid1.DataSource = cmd.ExecuteReader
Dim sumTotal As Integer
sumTotal = ds.Tables(0).Compute("SUM(Age)", String.Empty).ToString
datagrid1.Columns(2).FooterText = "TOTAL: "
datagrid1.Columns(3).FooterText = sumTotal
datagrid1.DataBind()
cmd.Connection.Close()
cmd.Connection.Dispose()
End Sub

--------------And for datagrid_itemdatabound...then use this function..manipulate the functions based on ur requirements,,,

Protected Sub datagrid1_itemdatabound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles datagrid1.ItemDataBound
If (e.Item.ItemType = ListItemType.Item) Or (e.Item.ItemType = ListItemType.AlternatingItem) Then
Dim value As String = Trim(e.Item.DataItem("Sex"))
If Len(value) = 4 Then
e.Item.BackColor = System.Drawing.Color.Chocolate ' i is the index of the particular column
' 'e.Item.Cells(4).Text = "hai"
End If
End If
------------------if u have any prblm,just scrap it over here& w will solve it.....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.