Hello
Kindly provide me a sample code to populate the tasks grid in the ultraganttview from the database. This has to work on selecting a project from a dropdownlist.
Also need to add and modify the tasks and then save back to the table in the database.
Regards
jeni
Hello Jeni,
There are different approaches to solve this task. I`m not sure what is your scenario (Are you using TableAdapters, or EntityDataModel, or SQLCommands and so on...) I made small sample for you where I`m using TableAdapters and local database. Please take a look at the attached sample and video file for more details and let me know if you have any questions. Also you could find additional information in our online documentation: http://help.infragistics.com/Help/NetAdvantage/WinForms/2012.1/CLR2.0/html/WinGanttView.html
Here is the sample
This sample is not working for my version. Please give me the schema of the database. So I can try in my version and see whether this works.
Thanks in advance
jeni said:This sample is not working for my version
I`m not sure for which version are you talking, but this sample is independant of Infragistics controls version and can be used everywhere.
Please take a look at the SQL script. There are both tables that I`m using in my database
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
CREATE TABLE [dbo].[dbProjects](
[ProjectID] [uniqueidentifier] NOT NULL,
[ProjectKey] [nvarchar](50) NOT NULL,
[ProjectName] [nvarchar](50) NULL,
[ProjectStartTime] [datetime] NULL,
CONSTRAINT [PK_dbProjects] PRIMARY KEY CLUSTERED
(
[ProjectKey] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
SET ANSI_PADDING ON
CREATE TABLE [dbo].[dbTasks](
[TaskID] [uniqueidentifier] NOT NULL,
[ProjectKey] [nvarchar](50) NULL,
[TaskName] [nvarchar](50) NULL,
[TaskStartTime] [datetime] NULL,
[TaskDuration] [time](7) NOT NULL,
[ParentTaskID] [uniqueidentifier] NULL,
[TaskPercentComplete] [int] NULL,
[AllProperties] [varbinary](max) NULL,
CONSTRAINT [PK_dbTasks] PRIMARY KEY CLUSTERED
[TaskID] ASC,
[TaskDuration] ASC
SET ANSI_PADDING OFF
ALTER TABLE [dbo].[dbTasks] WITH NOCHECK ADD CONSTRAINT [FK_dbTasks_dbProjects] FOREIGN KEY([ProjectKey])
REFERENCES [dbo].[dbProjects] ([ProjectKey])
ALTER TABLE [dbo].[dbTasks] CHECK CONSTRAINT [FK_dbTasks_dbProjects]
Let me know if you have any further questions.
Thanks for your post.
In Ultraganttview samples, both in tableadapter and sqlcommand I encounter an error `Overflow exception was unhandled`
SqlDbType.Time overflow. Value '4.00:00:00' is out of range. Must be between 00:00:00.0000000 and 23:59:59.9999999.
In the database TaskDuration is of type time(7)
This occurs on editing the Taskduration and also on inserting new task and subtasks.
Also
In the sample with sqlcommand
I encounter an error Failed to convert parameter value from a TimeSpan to a DateTimeOffset.
sqlConnection.Open(); SqlCommand cmd = sqlConnection.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "sp_GanttTasks_InsertTask"; cmd.Parameters.Add("@TaskID", SqlDbType.UniqueIdentifier).Value = e.Task.Id; cmd.Parameters.Add("@ProjectKey", SqlDbType.VarChar, 50).Value = "p1"; cmd.Parameters.Add("@TaskName", SqlDbType.VarChar, 50).Value = e.Task.Name; cmd.Parameters.Add("@TaskStartTime", SqlDbType.DateTime).Value = e.Task.StartDateTime; cmd.Parameters.Add("@TaskDuration", SqlDbType.DateTimeOffset).Value = e.Task.Duration; cmd.Parameters.Add("@ParentTaskID", SqlDbType.UniqueIdentifier).Value = e.Task.Parent; cmd.Parameters.Add("@TaskPercentComplete", SqlDbType.Int).Value = e.Task.PercentComplete; cmd.Parameters.Add("@AllProperties", SqlDbType.Binary).Value = null;
cmd.ExecuteNonQuery();
Kindly provide a solution for this.
Jeni
The mentioned issue is expected and it is an error message from your database. Please note that you have TimeSpan dataType in your Duration column, meanwhile your database has Time(7) dataType, so it is not possible direct cast between these two data Types.
You could try:
- if you are using Duration bigger than 24 hours, you could use additional column into your database
- You could use Nvarchar(50) datatype instead of Time(7) in you database
Please let me know if you have any questions.
The sample of the script is attached here.
Hello Georgi
Thanks for your reply with video samples.
A sample for the issue is attached here along with the db script. Kindly have a look on to it.
I find issues in populating the ganttview on selecting the project from ultracomboeditor. I have a comboeditor on selecting a particular startdate and enddate combo is populated on the valuechanged of the combo I need to populate the tasks of that particular project. insert new task, subtask, delete and update functionality. I tried with paraamterised fill method of table adapter, I works perfect for update, delete, select but insert new task and subtask is not working for the selected project. Please suggest a way to work out this. Is there any way to insert the task by passing the projectid as the parameter on update?
Looking forward for your feedback.
I`m glad to see that you are using my sample and my suggestion with TableAdapters. I research your sample and you should make few changes to be able to Insert, Delete, Update your Tasks. I made a video file for you with the changes that I made into your sample. The video file is huge and I`m not able to upload it in this forum thread, that`s why I create a private case for you with Ref. Number CAS-101542-H7H8Q1. You could find your case at: https://ko.infragistics.com/my-account/support-activity/ with attached video file
Please take a look at the video file and let me know if you have any questions.
Please note that I made changes in:
1. Update Command
2. Delete Command
3. TaskDuration column in the database
4. About Resource Name, please note that you should have Owners in your UltraCalendarInfo. You could load this Owner from DataBase or direct in the UltraCalendarInfo
Please find the sample here.
I have included a small sample and the script.
My issues are described below.
Insert task, Update task etc with a duration more than 24 hours is not workingNot able to save resource namesOn click of Add Notes button I want the task information of the selected task to be opened, with the Notes tab as the selected tab.