In my application I have a number of projects listed in a ultracomboeditor. I am using the tableadapter method. The functionality to achieve is to bind the tasks in ultraganttview , accordingly in response to the value selected in the ultracomboeditor with projects.
The issue, is the tasks are not loading correctly in the ultraganttview, where as the tasks are bound in the tableadapter correctly. I have added the function which I call on ultracomboeditor Valuechanged event
public void LoadAllTasksByID(int Id) { try { if (Id < 0) return; ganttDataSet1.Clear(); //Fill DataSet projectsTableAdapter1.Fill(ganttDataSet1.Projects); dbTasksTableAdapter1.FillBy(ganttDataSet1.DbTasks,Id); ultraCalendarInfoProjects.DataBindingsForProjects.BindingContextControl = this; ultraCalendarInfoProjects.DataBindingsForTasks.BindingContextControl = this; //// Set the DataBinding members for Projects this.ultraCalendarInfoProjects.DataBindingsForProjects.DataSource = ganttDataSet1.Projects; this.ultraCalendarInfoProjects.DataBindingsForProjects.IdMember = "ProjectId"; this.ultraCalendarInfoProjects.DataBindingsForProjects.KeyMember = "Id"; this.ultraCalendarInfoProjects.DataBindingsForProjects.NameMember = "ProjectName"; // Set the DataBinding members for Tasks this.ultraCalendarInfoProjects.DataBindingsForTasks.DataSource = ganttDataSet1.DbTasks; // Basic Task properties this.ultraCalendarInfoProjects.DataBindingsForTasks.NameMember = "TaskName"; this.ultraCalendarInfoProjects.DataBindingsForTasks.DurationMember = "TaskDuration"; this.ultraCalendarInfoProjects.DataBindingsForTasks.StartDateTimeMember = "TaskStartTime"; this.ultraCalendarInfoProjects.DataBindingsForTasks.IdMember = "TaskID"; this.ultraCalendarInfoProjects.DataBindingsForTasks.ProjectKeyMember = "ProjectKey"; this.ultraCalendarInfoProjects.DataBindingsForTasks.ParentTaskIdMember = "ParentTaskID"; this.ultraCalendarInfoProjects.DataBindingsForTasks.PercentCompleteMember = "TaskPercentComplete"; this.ultraCalendarInfoProjects.DataBindingsForTasks.AllPropertiesMember = "AllProperties"; this.ultraGanttView1.CalendarInfo = this.ultraCalendarInfoProjects; //Choose which project to be show in the GanntView this.ultraGanttView1.Project = this.ultraGanttView1.CalendarInfo.Projects[0]; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
Please reply where I have gone wrong.
Thanks
Hello Jeni,
Thanks for attached code. I see, that you implemented one of my suggestion. I have few small remarks (maybe because you do not include it in the forum thread )
1. Please note that you should clear your DataSet and TableAdapters before to Fill it again
2. Please remove :
//Choose which project to be show in the GanntView
this.ultraGanttView1.Project = this.ultraGanttView1.CalendarInfo.Projects[0];
3. In my scenario I used UltraCombo control with RowSelected() event to choose different projects. The could be:
private void ucProjects_RowSelected(object sender, RowSelectedEventArgs e)
{
if (e.Row != null)
ultraGanttView1.Enabled = true;
ProjectKey = e.Row.Cells["ProjectKey"].Text;
dbTasksTableAdapter1.FillByProjectKey(dbDataSetTasks1.dbTasks, ProjectKey);
}
Please take a look on attached video file for more details. If you have any questions, please do not hesitate to write me
Hi Georgi
Your sample really helped me, Now the issue is on update.
I have written the following code on the events ultraGanttView1_CellDeactivating,ultraGanttView1_TaskAdded,ultraGanttView1_TaskDeleted public void UpdateChangesToDatabase() { try { dbTasksTableAdapter1.Update(DataSet1.DbTasks); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
I am getting an error. Please have a look on to the attached image.
Hello Georgi
Adding new tasks and subtasks are not working. The issue is Projectkey is not saving in the table on insert. Please advise to fix this.
Thanks in Advance
Jeni
This error message come from your TableAdapter. Usually it is happen when you try to update a record which already been updated by some other process (user). There are many articles in MSDN how to resolve this issue depending of your scenario and requirement, but if you want to keep the last change, then you could modify your Update command in TableAdapter. For example:
UPDATE dbTasks SET TaskID = @TaskID, ProjectKey = @ProjectKey, TaskName = @TaskName, TaskStartTime = @TaskStartTime, TaskDuration = @TaskDuration, ParentTaskID = @ParentTaskID, TaskPercentComplete = @TaskPercentComplete, AllProperties = @AllProperties, TaskDuration3 = @TaskDuration3, ID = @ID WHERE TaskID = @Original_TaskID
instead to use the full where:
UPDATE dbTasks SET TaskID = @TaskID, ProjectKey = @ProjectKey, TaskName = @TaskName, TaskStartTime = @TaskStartTime, TaskDuration = @TaskDuration, ParentTaskID = @ParentTaskID, TaskPercentComplete = @TaskPercentComplete, AllProperties = @AllProperties, TaskDuration3 = @TaskDuration3, ID = @ID WHERE (TaskID = @Original_TaskID) AND (@IsNull_ProjectKey = 1 AND ProjectKey IS NULL OR ProjectKey = @Original_ProjectKey) AND (@IsNull_TaskName = 1 AND TaskName IS NULL OR TaskName = @Original_TaskName) AND (@IsNull_TaskStartTime = 1 AND TaskStartTime IS NULL OR TaskStartTime = @Original_TaskStartTime) AND (@IsNull_TaskDuration = 1 AND TaskDuration IS NULL OR TaskDuration = @Original_TaskDuration) AND (@IsNull_ParentTaskID = 1 AND ParentTaskID IS NULL OR ParentTaskID = @Original_ParentTaskID) AND (@IsNull_TaskPercentComplete = 1 AND TaskPercentComplete IS NULL OR TaskPercentComplete = @Original_TaskPercentComplete) AND (@IsNull_TaskDuration3 = 1 AND TaskDuration3 IS NULL OR TaskDuration3 = @Original_TaskDuration3) AND (ID = @Original_ID)
Let me know if you have any questions.