|
I am studying software engineering but am new to c# and asp.net
I would really like to include this gantt style event calendar in my project. http://www.codeproject.com/aspnet/EventCalendarControl.asp[^]
Problem is, I havn't got a clue how to go about it!
If somebody could please explain it to me as simply as possible, i would really appreciate it!
Many thanks,
Jay
|
|
|
|
|
|
I am using the control in my Asp.net C# project.the control doesnt shows any output. i Think my pageload event code has some problem. the code is
SqlConnection con=new SqlConnection("Data Source=SAAD-03DC58C8B2;initial catalog=practice;uid=sa;pwd=sa");
SqlDataAdapter adp=new SqlDataAdapter("select * from [group]",con);
DataSet ds=new DataSet();
adp.Fill(ds,"[group]");
adp=new SqlDataAdapter("select * from block",con);
adp.Fill(ds,"block");
DataRelation dr=new DataRelation("rel",ds.Tables["[group]"].Columns["name"],ds.Tables["block"].Columns["name"]);
ds.Relations.Add(dr);
ds.Relations["rel"].Nested=true;
ec.XMLData=ds.GetXml();;
ec.Year=2006;
ec.Quarter=4;
ec.BlankGifPath = "trans.gif";
ec.BlockColor = "blue";
ec.ToggleColor = "green";
ec.CellHeight = 15;
ec.CellWidth = 15;
i have someone will be able to identify my problem
|
|
|
|
|
Hello, did you solve this problem?
|
|
|
|
|
Yes I have solved the Problem.
|
|
|
|
|
hi there
i am just wondering, instead of having the xml data display in the onload event of the page, is it possible to have to xml file in a directory of the project and give reference to that xml file?
thanks
|
|
|
|
|
Hi, Great control.
I seem to have spotted a bug in the control whereby it groups all of the tasks for a given quarter regardless of what year is selected. In otherwords if we have two tasks as follows:
task 1 in quarter 1 year 2005 and
task 2 in quarter 1 year 2006
both tasks get displayed at the same time in the gantt.
Has anybody else noticed this behavour?
Regards
Brendy
|
|
|
|
|
hi,
i guess when i wrote this i didnt intend the gantt chart to span over a period of a year. i think its ok to cross over years e.g crossing over 2005 to 2006 but not overlap quarters.
just needs some tweeking to expand on this, ive just been a bit busy.
|
|
|
|
|
I found another issue. A task start and end in 1st quarter will show a tail at Apr 1st even it's ended within 1st Qt.
Ben
|
|
|
|
|
i did some treaking and fixed this issue. let me know if u want the code for this fix
|
|
|
|
|
Can I have a copy of this fix? nicolechung9@gmail.com THanks!
|
|
|
|
|
Any chance to be able to use this control in Visual Basic? Possibly generating a web page including the control, and then showing it on a VB form with a browser control?
Thanks!
|
|
|
|
|
I converted this to VB and also can use the original control in a vb project.
Zath
VB Code Below:
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.ComponentModel
Imports System.Xml
< DefaultProperty("XMLData"), ToolboxData("<{0}:EventCalendarControl runat=server>")> _
Public Class EventCalendar
Inherits System.Web.UI.WebControls.WebControl
Private m_xmlData As String, m_blockColor As String, m_toggleColor As String, m_cellWidth As String, m_cellHeight As String, m_blankGifPath As String
Private m_year As Integer, m_quarter As Integer
Dim m_names() As String
Public Sub EventCalendarControl()
m_names = New String(3) {}
End Sub
#Region "Public Properties"
'/
'/ Gets or sets a value that contains XML data containing the events.
'/
< Bindable(True), Category("Appearance"), DefaultValue("")> _
Public Property XMLData() As String
Get
Return m_xmlData
End Get
Set(ByVal Value As String)
m_xmlData = Value
End Set
End Property
'/
'/ Gets or sets a value that indicates the quarter (1,2,3,4)
'/
< Bindable(True), Category("Appearance"), DefaultValue(1)> _
Public Property Quarter() As Integer
Get
Return m_quarter
End Get
Set(ByVal Value As Integer)
m_quarter = Value
End Set
End Property
'/
'/ Gets or sets a value that indicates the Year e.g. 2005
'/
< Bindable(True), Category("Appearance"), DefaultValue("")> _
Public Property Year() As Integer
Get
Return m_year
End Get
Set(ByVal Value As Integer)
m_year = Value
End Set
End Property
'/
'/ Gets or sets a value that indicates the default BlockColor
'/
< Bindable(True), Category("Appearance"), DefaultValue("red")> _
Public Property BlockColor() As String
Get
Return m_blockColor
End Get
Set(ByVal Value As String)
m_blockColor = Value
End Set
End Property
'/
'/ Gets or sets a value that indicates the cell width of the event calendar 'grid'
'/
< Bindable(True), Category("Appearance"), DefaultValue("15")> _
Public Property CellWidth() As Integer
Get
Return Integer.Parse(m_cellWidth)
End Get
Set(ByVal Value As Integer)
m_cellWidth = Value.ToString()
End Set
End Property
'/
'/ Gets or sets a value that indicates the cell height of the event calendar 'grid'
'/
< Bindable(True), Category("Appearance"), DefaultValue("15")> _
Public Property CellHeight() As Integer
Get
Return Integer.Parse(m_cellHeight)
End Get
Set(ByVal Value As Integer)
m_cellHeight = Value.ToString()
End Set
End Property
'/
'/ Gets or sets a value that indicates a color the event calendar will use to delimit the day names and event names.
'/
< Bindable(True), Category("Appearance"), DefaultValue("#dcdcdc")> _
Public Property ToggleColor() As String
Get
Return m_toggleColor
End Get
Set(ByVal Value As String)
m_toggleColor = Value
End Set
End Property
'/
'/ Gets or sets a value that indicates a color the event calendar will use to delimit the day names and event names.
'/
< Bindable(True), Category("Appearance"), DefaultValue("#dcdcdc")> _
Public Property BlankGifPath() As String
Get
Return m_blankGifPath
End Get
Set(ByVal Value As String)
m_blankGifPath = Value
End Set
End Property
#End Region
#Region "Event Handling"
'/
'/ writes out some javascript so the calendar grid can resize itself
'/
'/ <param name="e" />
Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
MyBase.OnPreRender(e)
If Not MyBase.Page.ClientScript.IsStartupScriptRegistered("EventCalendar") Then
MyBase.Page.ClientScript.RegisterStartupScript(Me.GetType, "EventCalendar", "function ResizeTables(){document.getElementById('divcal').style.width = '1px';document.getElementById('divcal').style.width = document.getElementById('tblcal').clientWidth + 'px';};")
MyBase.Page.ClientScript.RegisterStartupScript(Me.GetType, "EventCalendarOnLoad", "ResizeTables();")
MyBase.Page.ClientScript.RegisterStartupScript(Me.GetType, "EventCalendarOnResize", "ResizeTables();")
End If
End Sub
Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
' create a 2 column, 1 row table, the first column will contain the text for the tasks that
' is non scrollable.
writer.AddAttribute("border", "0")
writer.AddAttribute("cellSpacing", "0")
writer.AddAttribute("cellPadding", "0")
writer.AddAttribute("width", "100%")
writer.RenderBeginTag("table")
writer.RenderBeginTag("tr")
writer.AddAttribute("valign", "top")
writer.AddAttribute("align", "right")
writer.RenderBeginTag("td nowrap")
RenderLeftHandPane(writer)
writer.RenderEndTag()
writer.AddAttribute("id", "tblcal")
writer.AddAttribute("valign", "top")
writer.AddAttribute("align", "left")
writer.AddAttribute("width", "100%")
writer.RenderBeginTag("td nowrap")
RenderRightHandPane(writer)
writer.RenderEndTag()
writer.RenderEndTag()
writer.RenderEndTag()
End Sub
#End Region
#Region "Helper Functions"
Private Sub RenderLeftHandPane(ByVal writer As HtmlTextWriter)
Dim blocktext As String, grouptext As String
writer.AddAttribute("border", "1")
writer.AddAttribute("style", "FONT-SIZE: " & Font.Size.ToString() & ";FONT-FAMILY: " + Font.Name + ";BORDER-COLLAPSE: collapse")
writer.AddAttribute("borderColor", "#000000")
writer.AddAttribute("cellSpacing", "0")
writer.AddAttribute("cellPadding", "0")
writer.RenderBeginTag("table")
'empty row to match month headers on right hand pane
writer.RenderBeginTag("tr")
writer.RenderBeginTag("td")
writer.Write(" ")
writer.RenderEndTag()
writer.RenderEndTag()
'empty row to match day headers on right hand pane
writer.RenderBeginTag("tr")
writer.RenderBeginTag("td")
writer.Write(" ")
writer.RenderEndTag()
writer.RenderEndTag()
' now need to write the rows
' Load the XML
Dim xmlDoc As XmlDocument = New XmlDocument()
xmlDoc.LoadXml(m_xmlData)
Dim xmlRows As XmlNodeList = xmlDoc.SelectNodes("//group")
Dim xmlRow As XmlNode
For Each xmlRow In xmlRows
grouptext = xmlRow.SelectSingleNode("name").InnerText
writer.RenderBeginTag("tr")
writer.AddAttribute("bgcolor", m_toggleColor)
writer.AddAttribute("height", m_cellHeight)
writer.RenderBeginTag("td nowrap")
writer.Write(" " + grouptext + " ")
writer.RenderEndTag()
writer.RenderEndTag()
Dim xmlBlocks As XmlNodeList = xmlRow.SelectNodes("block")
Dim xmlBlock As XmlNode
For Each xmlBlock In xmlBlocks
writer.RenderBeginTag("tr")
blocktext = xmlBlock.SelectSingleNode("name").InnerText
'write the activity
writer.AddAttribute("height", m_cellHeight)
writer.RenderBeginTag("td nowrap")
writer.Write(" " + blocktext + " ")
writer.RenderEndTag()
writer.RenderEndTag()
Next
Next
writer.RenderEndTag()
End Sub
Private Sub RenderRightHandPane(ByVal writer As HtmlTextWriter)
Dim startdate As String, enddate As String, dayname As String, href As String, blocktext As String, blockcolor As String
Dim startindex As Integer, endindex As Integer, imagewidth As Integer, month As Integer
Dim week As Boolean = False
'Dim quarter As QuarterHelper = New QuarterHelper(m_year, m_quarter)
Dim quarter As QuarterHelper = New QuarterHelper()
quarter.QuarterHelper(m_year, m_quarter)
writer.AddAttribute("style", "width:1px; overflow-x:scroll;")
writer.AddAttribute("id", "divcal")
writer.RenderBeginTag("div")
writer.AddAttribute("border", "1")
writer.AddAttribute("style", "FONT-SIZE: " & Font.Size.ToString() & ";FONT-FAMILY: " & Font.Name & ";BORDER-COLLAPSE: collapse")
writer.AddAttribute("borderColor", "#000000")
writer.AddAttribute("cellSpacing", "0")
writer.AddAttribute("cellPadding", "0")
writer.RenderBeginTag("table")
'write month headers
writer.RenderBeginTag("tr")
Dim i As Integer
For i = 1 To 3
month = i + (3 * (quarter.QuarterIndex - 1))
writer.AddAttribute("align", "center")
writer.AddAttribute("colspan", quarter.TotalDaysInMonth(month).ToString())
writer.RenderBeginTag("td")
writer.Write(quarter.GetMonthName(i))
writer.RenderEndTag()
Next
writer.RenderEndTag()
'write day headers
writer.RenderBeginTag("tr")
'Dim i As Integer
For i = (3 * quarter.QuarterIndex - 2) To (3 * quarter.QuarterIndex)
Dim j As Integer
For j = 1 To quarter.TotalDaysInMonth(i) Step j + 1
dayname = quarter.GetDayName(i, j)
If dayname = "M" Then
week = Not week
End If
writer.AddAttribute("align", "center")
writer.AddAttribute("width", m_cellWidth)
writer.AddAttribute("height", m_cellHeight)
If week Then
writer.AddAttribute("bgcolor", m_toggleColor)
End If
writer.RenderBeginTag("td")
writer.Write(dayname)
writer.RenderEndTag()
Next
Next
writer.RenderEndTag()
' now need to write the rows
' Load the XML
Dim xmlDoc As XmlDocument = New XmlDocument()
xmlDoc.LoadXml(m_xmlData)
Dim xmlRows As XmlNodeList = xmlDoc.SelectNodes("//group")
Dim xmlRow As XmlNode
For Each xmlRow In xmlRows
' empty row to match group name
writer.RenderBeginTag("tr")
writer.AddAttribute("colspan", (quarter.Days).ToString())
writer.AddAttribute("width", ((quarter.Days) * Integer.Parse(m_cellWidth)).ToString())
writer.RenderBeginTag("td")
writer.Write(" ")
writer.RenderEndTag()
writer.RenderEndTag()
Dim node As XmlNode = xmlRow.SelectSingleNode("blockcolor")
If Not node Is Nothing Then
blockcolor = node.InnerText
Else
blockcolor = m_blockColor
End If
' write out the events
Dim strHTML As String
Dim xmlBlocks As XmlNodeList = xmlRow.SelectNodes("block")
Dim xmlBlock As XmlNode
For Each xmlBlock In xmlBlocks
writer.RenderBeginTag("tr")
startdate = xmlBlock.SelectSingleNode("StartDate").InnerText
enddate = xmlBlock.SelectSingleNode("EndDate").InnerText
href = xmlBlock.SelectSingleNode("href").InnerText
blocktext = xmlBlock.SelectSingleNode("name").InnerText
startindex = quarter.getColumnIndex(startdate)
endindex = quarter.getColumnIndex(enddate)
'write out the padding cells
'Dim i As Integer
For i = 0 To startindex - 1 Step i + 1
writer.AddAttribute("width", m_cellWidth)
writer.AddAttribute("height", m_cellHeight)
writer.RenderBeginTag("td")
writer.Write(" ")
writer.RenderEndTag()
Next
'create the filled in block
writer.AddAttribute("colspan", (endindex - startindex + 1).ToString())
writer.AddAttribute("bgColor", blockcolor)
writer.AddAttribute("width", m_cellWidth)
writer.AddAttribute("height", m_cellHeight)
writer.RenderBeginTag("td nowrap")
If href <> String.Empty Then
imagewidth = (endindex - startindex + 1) * Integer.Parse(m_cellWidth)
strHTML = ""
writer.Write(strHTML)
Else
writer.Write(" ")
End If
writer.RenderEndTag()
'
'write out the padding cells
'Dim i As Integer
For i = endindex To quarter.Days - 1 - 1 Step i + 1
writer.AddAttribute("width", m_cellWidth)
writer.AddAttribute("height", m_cellHeight)
writer.RenderBeginTag("td")
writer.Write(" ")
writer.RenderEndTag()
Next
writer.RenderEndTag()
Next
Next
' close table tag As
writer.RenderEndTag()
' close div tag As
writer.RenderEndTag()
End Sub
#End Region
#Region "Helper Classes"
Private Class QuarterHelper
Private m_year As Integer
Private m_quarter As Integer
Private m_names() As String = New String(3) {}
Private m_NoOfDays As Integer
Public Sub QuarterHelper()
End Sub
Public Sub QuarterHelper(ByVal year As Integer, ByVal quarter As Integer)
m_quarter = quarter
m_year = year
m_names = getQuarterNames()
m_NoOfDays = getDaysInQuarter(m_year, m_quarter)
End Sub
Public ReadOnly Property Year() As Integer
Get
Return m_year
End Get
End Property
Public ReadOnly Property QuarterIndex() As Integer
Get
Return m_quarter
End Get
End Property
Public ReadOnly Property Names() As String()
Get
Return m_names
End Get
End Property
Public ReadOnly Property Days() As Integer
Get
Return m_NoOfDays
End Get
End Property
Public Function GetMonthName(ByVal i As Integer) As String
Return m_names(i - 1)
End Function
Public Function TotalDays() As Integer
Dim retval As Integer = 0
Select Case m_quarter
Case 1
retval = DateTime.DaysInMonth(m_year, 1)
retval += DateTime.DaysInMonth(m_year, 2)
retval += DateTime.DaysInMonth(m_year, 3)
Exit Function
Case 2
retval = DateTime.DaysInMonth(m_year, 4)
retval += DateTime.DaysInMonth(m_year, 5)
retval += DateTime.DaysInMonth(m_year, 6)
Exit Function
Case 3
retval = DateTime.DaysInMonth(m_year, 7)
retval += DateTime.DaysInMonth(m_year, 8)
retval += DateTime.DaysInMonth(m_year, 9)
Exit Function
Case 4
retval = DateTime.DaysInMonth(m_year, 10)
retval += DateTime.DaysInMonth(m_year, 11)
retval += DateTime.DaysInMonth(m_year, 12)
Exit Function
End Select
Return retval
End Function
Public Function TotalDaysInMonth(ByVal i As Integer) As Integer
Return DateTime.DaysInMonth(m_year, i)
End Function
Public Function GetDayName(ByVal month As Integer, ByVal day As Integer) As String
Dim retval As String = String.Empty
Dim d As DateTime = New DateTime(m_year, month, day)
Select Case d.DayOfWeek
Case DayOfWeek.Monday
retval = "M" 'break
Case DayOfWeek.Tuesday
retval = "T" 'break
Case DayOfWeek.Wednesday
retval = "W" 'break
Case DayOfWeek.Thursday
retval = "T" 'break
Case DayOfWeek.Friday
retval = "F" 'break
Case DayOfWeek.Saturday
retval = "S" 'break
Case DayOfWeek.Sunday
retval = "S" 'break
End Select
Return retval
End Function
Private Function getQuarterNames() As String()
Dim retval() As String = New String(3) {}
Select Case m_quarter
Case 1
retval(0) = "January"
retval(1) = "Febuary"
retval(2) = "March"
' break()
Case 2
retval(0) = "April"
retval(1) = "May"
retval(2) = "June"
'break()
Case 3
retval(0) = "July"
retval(1) = "August"
retval(2) = "September"
'break()
Case 4
retval(0) = "October"
retval(1) = "November"
retval(2) = "December"
'break()
End Select
Return retval
End Function
Private Function getDaysInQuarter(ByVal year As Integer, ByVal quarter As Integer) As Integer
Dim dtS As DateTime, dtE As DateTime
If quarter < 4 Then
'{"Year, Month, and Day parameters describe an un-representable DateTime."}
dtS = New DateTime(year, (3 * quarter - 2), 1)
dtE = New DateTime(year, (3 * quarter - 2) + 3, 1)
Else
dtS = New DateTime(year, (3 * quarter - 2), 1)
dtE = New DateTime(year + 1, 1, 1)
End If
Dim ts As TimeSpan = New TimeSpan(dtE.Subtract(dtS).Ticks)
Return ts.Days
End Function
Public Function getColumnIndex(ByVal day As String) As Integer
Dim dt As DateTime = DateTime.Parse(day)
Dim offset As Integer = 0
Dim retval As Integer = 0
Dim i As Integer
For i = 1 To m_quarter - 1 Step i + 1
offset += getDaysInQuarter(m_year, i)
Next
retval = (dt.DayOfYear - 1) - offset
If retval < 0 Then
retval = 0
End If
If retval > getDaysInQuarter(m_year, m_quarter) Then
retval = getDaysInQuarter(m_year, m_quarter)
End If
Return retval
End Function
End Class
#End Region
End Class
|
|
|
|
|
Hi,
Hope u r fine. I liked the concept of the event calendar control. I have few queries regarding the same.
1) The demo version doesnot have all the pages. The link redirects to activity.aspx which was unavailable coz of which i was unabel to understand the entire functionality.
2) I would like to know how do i include a chart or a graph with this event calendar control.
3) My reqirements are that on clicking the left pane the calendar sheet should change accordingly.For eg. On clicking on "Gather Business Requirements " the calendar graph should change.
Could you please reply asap.
Warm Regards,
Smita .
|
|
|
|
|
Hello
Based on the cool modifications done by Jorge Lopez (jdlr1976) , I've included the ability to add multiple events for the same row.
****** The code is too large to put it here, so if somebody wants it, just ask. *********
NOTES:
1. It works pretty fine if you use a cellwidth=23 (or high) and cellhigh=20 (or high) in the eventcontrol properties.
2. and finally you should put this code in the <head> section of your web page where you're using this control:
<STYLE type="text/css">
td a{width:100%;height:100%;display:block;text-decoration:none;}
td a:hover{width:100%;height:100%;display:block;text-decoration:none;}
</STYLE>
=)
"This is not here"
|
|
|
|
|
I tried to email you but the CP form appears to be broken at the moment. I would be interested in a copy of your code.
Thanks,
Jack
|
|
|
|
|
I'm sorry for the late replay, I was on vacations!!
post your email here and I will send you the code.
See ya!
"This is not here"
|
|
|
|
|
np, I could use a vacation myself.
my email is codeproject at jhecker dot net.
Thanks!
Jack
|
|
|
|
|
I would like to get the code. My E-mail is benjamin.h.hou@honeywell.com
THX
|
|
|
|
|
Hi could you send me a copy of your modification too?
marker at avian dot sg.
Thanks in advance
|
|
|
|
|
I would be definately be interested in your modification.
crbjr at charter dot net
Thanks
|
|
|
|
|
Hello everybody,
First of all, I'm sorry guys for the late replay.
Here is the source code for all you guys that asked for this.
http://www.cubewave.com/public/EventCalendarControl.zip
"This is not here"
|
|
|
|
|
Help! I can use the original control ok but when I try to use yours (ie the multiple events version) It bombs out with a "Object reference not set to an instance of an object" error.
Has anyone else had this problem?
I'm using .net 1.1- is this v2 only?
|
|
|
|
|
Never mind- found it.
If anyone else downloads that source code, the data xml's block element needs ID and name sub-elements or it won't work. The sample data.xml doesn't have them.
|
|
|
|
|
I recieved same error and it will be appreciated if you could provide me the updated xmldata.
Thanks for your help in advance.
|
|
|
|
|