protected virtual void PMSubTask_Position_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e) { if (e.Row == null) { return; } PMSubTask pmSubTaskRow = (PMSubTask)e.Row; PMSubTask subTasksSet = PXSelect <PMSubTask, Where <PMSubTask.projectID, Equal <Required <PMSubTask.projectID> >, And <PMSubTask.taskID, Equal <Required <PMSubTask.taskID> > > >, OrderBy <Desc <PMSubTask.position> > > .SelectWindowed(this.Base, 0, 1, pmSubTaskRow.ProjectID, pmSubTaskRow.TaskID); if (subTasksSet != null && subTasksSet.Position > 0) { pmSubTaskRow.Position = subTasksSet.Position + 1; } else { pmSubTaskRow.Position = 1; } }
protected virtual void buttonUp() { PMSubTask currentSubTaskRow = SelectedSubTasks.Current; PMSubTask prevSubTask = PXSelect <PMSubTask, Where <PMSubTask.projectID, Equal <Required <PMSubTask.projectID> >, And <PMSubTask.taskID, Equal <Required <PMSubTask.taskID> >, And <PMSubTask.position, Less <Required <PMSubTask.position> > > > >, OrderBy <Desc <PMSubTask.position> > > .SelectWindowed(this.Base, 0, 1, currentSubTaskRow.ProjectID, currentSubTaskRow.TaskID, currentSubTaskRow.Position); if (prevSubTask != null) { int swapPosition = (int)prevSubTask.Position; prevSubTask.Position = currentSubTaskRow.Position; currentSubTaskRow.Position = swapPosition; this.SelectedSubTasks.Update(currentSubTaskRow); this.SelectedSubTasks.Update(prevSubTask); } this.Base.Actions.PressSave(); }
/// <summary> /// Adds subtasks to the Smartsheet project /// </summary> /// <param name="smartsheetClient"></param> /// <param name="columnMap"></param> /// <param name="sheet"></param> /// <param name="taskRow"></param> /// <param name="pmTemplateTaskSSExtRow"></param> /// <param name="subTaskRow"></param> /// <param name="columnID"></param> /// <param name="dependencyStartDateOffset"></param> /// <param name="dependencySibling"></param> /// <returns></returns> public long AddSubTasks(SmartsheetClient smartsheetClient, ProjectEntry projectEntryGraph, Dictionary <string, long> columnMap, Sheet sheet, PMTask taskRow, PMTaskSSExt pmTemplateTaskSSExtRow, PMSubTask subTaskRow, long?columnID, int dependencyStartDateOffset, long dependencySibling, PXResultset <PMSSMapping> templateMappingSSRow) { List <Cell> newCells = new List <Cell>(); Cell currentCell; ProjectEntry copyProjectEntryGraph = projectEntryGraph; ProjectEntryExt graphExtended = copyProjectEntryGraph.GetExtension <ProjectEntryExt>(); if (taskRow != null) { taskRow.TaskCD = subTaskRow.SubTaskCD; taskRow.Description = subTaskRow.Description; if (pmTemplateTaskSSExtRow != null) { if (pmTemplateTaskSSExtRow.UsrEnableSubtaskDependency == true) { taskRow.StartDate = taskRow.EndDate; } } foreach (PMSSMapping row in templateMappingSSRow) { if (!String.IsNullOrEmpty(row.NameAcu)) { if (copyProjectEntryGraph.GetValue(SmartsheetConstants.ViewName.TASK, taskRow, row.NameAcu) is DateTime) { currentCell = new Cell.AddCellBuilder(columnMap[row.NameSS], (DateTime)copyProjectEntryGraph.GetValue(SmartsheetConstants.ViewName.TASK, taskRow, row.NameAcu)).Build(); currentCell.Format = SmartsheetConstants.CellFormat.LARGE_GRAY_BACKGROUND; } else { if (row.NameAcu == SmartsheetConstants.ColumnMapping.PCT_COMPLETE) { decimal completePercent = Convert.ToDecimal(copyProjectEntryGraph.GetValue(SmartsheetConstants.ViewName.TASK, taskRow, row.NameAcu)) / 100; currentCell = new Cell.AddCellBuilder(columnMap[row.NameSS], completePercent).Build(); currentCell.Format = SmartsheetConstants.CellFormat.LARGER_GRAY_BACKGROUND_PERCENTAGE; } else { currentCell = new Cell.AddCellBuilder(columnMap[row.NameSS], copyProjectEntryGraph.GetValue(SmartsheetConstants.ViewName.TASK, taskRow, row.NameAcu).ToString()).Build(); currentCell.Format = SmartsheetConstants.CellFormat.LARGE_GRAY_BACKGROUND; } } newCells.Add(currentCell); } } } Row currentRow = new Row.AddRowBuilder(null, true, null, null, null).SetCells(newCells).Build(); currentRow.ParentId = (long)columnID; currentRow.Format = SmartsheetConstants.CellFormat.GRAY_BACKGROUND; List <Row> newSSRows = new List <Row>(); newSSRows.Add(currentRow); IList <Row> ssRows = smartsheetClient.SheetResources.RowResources.AddRows((long)sheet.Id, newSSRows); return((long)ssRows[0].Id); }