Solved

Display a color-coded project status

Posted on 2007-11-29
10
598 Views
Last Modified: 2008-02-01
Dear .net Gurus,

I need your urgent assistance.

I have been tasked with building a so-called "Simple" project tracker.

I would like Projects grouped like this:

Department HR     Status              Color
Project A         Unassiged         Gainsboro
Project B         Pending           Yellow
Project C         Completed         Green
Project D         Past Due          Red
Prject F             Closed            Purple

Department IT       Status           Color
Project A           Unassiged         Gainsboro
Project B             Pending           Yellow
Project C             Completed         Green
Project D             Past Due          Red
Prject F              Closed            Purple

This will list all departments with all of its projects and status and color-coded status.

To get the details, a user would click on the particular project view such details as startdate, completion date, requestedcompletion date, actual completition date, status, priority, etc.

Can I get some help with how to code this please?
0
Comment
Question by:nigerman
  • 6
  • 4
10 Comments
 
LVL 3

Expert Comment

by:PierreBeukes
ID: 20380008
Hi,

In the table you are going to store your projects - you will have a status field. this will be numeric..
0 = Unassiged
1 = Pending
2 = Completed
3 = Past Due
4 = Closed

You can also have a table called something like app_status..
Where you can store the numeric value and the text value ... like above .... - you can also put a column in there for colour...

So when you load your projects  - you will be able to pickup the text value of the status and assign the appropriate colour...
What is nice is that if you store the colour in the table like that - if you want to change it - you change it in the Database and it will show the new colour all over (You can build a settings page to select the colours per status).

Thanks,
P
0
 

Author Comment

by:nigerman
ID: 20382505
Thanks very much for your response.

What we don't want to do is have a user select colors by themselves.

I love your idea of having a fieldname called Color in status table but I needed, if possible, the syntax for displaying this info.

For instance:

Select projectName, Status, color from Project, Status where project.statusid = status.statusid

Can you please help me with the .net syntax? I use vb but c# is ok too.
0
 

Author Comment

by:nigerman
ID: 20383572
Here is an example of what I am talking about.

The following code works as fars retrieving info and displaying.

On the summary page, StatusColor is displaying as Red, or White, Blue, depending on the status.

What I am having problem accomplishing is changing the color from text to the background color.

In other words, instead of reading Red, I want to see background color of Red displayed.

Can you please assist?

here is what I have so far:

        Private Function GetTasks() As DataSet
            Dim SQLStatement As String = "SELECT Project_ID,projName, DepartmentName, StatusName, StatusColor FROM tblProjects, tblStatus, tblDepartments Where tblProjects.statusID = tblStatus.StatusID and tblProjects.DeptID = tblDepartments.DepartmentID GROUP BY DepartmentName,ProjName,StatusName,project_id,statusColor ORDER BY DepartmentName"

            'instantiate sql connection and command object
            Dim myConnection As New SqlConnection("data source = Localhost;initial catalog = TaskList;Integrated Security=SSPI;")
            Dim myCommand As SqlDataAdapter = New SqlDataAdapter(SQLStatement, myConnection)

            '/declare myDataSet as DataSet
            Dim myDataSet As DataSet
            Dim RcdCount As Integer

            ' mark the Command as s Text
            myCommand.SelectCommand.CommandType = CommandType.Text

            '/create an instance of dataset
            myDataSet = New DataSet

            '/fill the dataset with returned records
            myCommand.Fill(myDataSet, "Contact")
            RcdCount = myDataSet.Tables("Contact").Rows.Count.ToString()
            'MyDataGrid.PageSize = CInt(ps.SelectedItem.Value)
            ResultCount = RcdCount
            RecordCount.Text = "<b><font color=red>" & RcdCount & "</font> records found"

            '/finally return dataset
            Return myDataSet
        End Function
0
 

Author Comment

by:nigerman
ID: 20386035
Can anyone please jump in and help???
0
 
LVL 3

Expert Comment

by:PierreBeukes
ID: 20393751
Hi,

Sorry for replying so late.
Ok - I see you created a function GetTasks() to return a Dataset to you.
Do you want to show the details in a gridview (I will assume this for now)...
so after you get the dataset...
you will bind it to a gridview

        GridView1.DataSource = GridDs
        GridView1.DataBind()

Add the RowDataBound event to the gridview

This is how mine looks like

    Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound

        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim c As System.Drawing.Color
            c = System.Drawing.ColorTranslator.FromHtml(e.Row.DataItem("StatusColour"))
            e.Row.BackColor = c
        End If
    End Sub



I have a column called StatusColour in my table with the values in html format  -> #b3424a

This works as it colours the entire row the colour which is specified in the database ... you can apply it to a column only if you wish...

Let me know if this works for you :)

Ciao
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:nigerman
ID: 20441011
Thanks a lot and sorry for late response.

I wanted it for datagrid, Can it be changed for datagrid?
0
 
LVL 3

Expert Comment

by:PierreBeukes
ID: 20447718
Are you working with Vb.NET  or ASP.NET?????
0
 

Author Comment

by:nigerman
ID: 20449206
asp.net, vb flavor
0
 
LVL 3

Accepted Solution

by:
PierreBeukes earned 100 total points
ID: 20455480
Then my above solution should work for you -> Just drag on a gridview
0
 

Author Comment

by:nigerman
ID: 20486651
thanks
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now