private void LoadDataGridViewMainTask(bool iShowFirstPage, long?iSelectedMainTaskId = null) { var firstDisplayIndex = dgvMain.FirstDisplayedScrollingRowIndex; using (var releaseService = new Service.Release.Front.ReleaseService(_Group.GetEnvironment().GetSQLExtendConnectionString())) { var skip = (iShowFirstPage) ? 0 : ucNavigator.Skip; if (iShowFirstPage) { ucNavigator.PageNumber = 1; } Tuple <List <MainTask>, int> maintaskTuple; if (_LoadingType == LoadingType.Criteria) { maintaskTuple = releaseService.GetMainTaskList(_MainTaskStatusSearchEnum, _MainTaskOrderBy, _ProjectId, _ProductLineId, _MainTaskType, _DevelopperId, _PackageId, skip, ucNavigator.Take, GranularityEnum.Full, _ExternalProjectId); } else if (_LoadingType == LoadingType.MainTaskId) { var mainTask = releaseService.GetMainTaskById(_MainTaskId, GranularityEnum.Full); if (mainTask != null) { maintaskTuple = new Tuple <List <MainTask>, int>(new List <MainTask>() { mainTask }, 1); } else { maintaskTuple = new Tuple <List <MainTask>, int>(null, 0); } } else { throw new NotSupportedException(_LoadingType.ToStringWithEnumName()); } ucNavigator.Count = (maintaskTuple != null) ? maintaskTuple.Item2 : 0; var mainTaskList = (maintaskTuple != null) ? maintaskTuple.Item1 : null; if (mainTaskList.IsNotNullAndNotEmpty()) { lblMessage.Text = "{0} tâche(s) sur {1}".FormatString(maintaskTuple.Item1.Count(), maintaskTuple.Item2); //commande var list = mainTaskList.Enum().Select(x => MainTaskView.ConvertTo(x)).ToList(); _MainTaskBindingSource.DataSource = list; dgvMain.Refresh(); } else { lblMessage.Text = "Aucune tâche."; _MainTaskBindingSource.Clear(); } } //dgvMain.SetFirstDisplayedScrollingRowIndex(firstDisplayIndex); if (dgvMain.RowCount != 0) { if (iSelectedMainTaskId != null) { dgvMain.Refresh(); if (!dgvMain.SelectRowByPropertyValue <MainTaskView>(x => x.Object.MainTaskId.ToString(), iSelectedMainTaskId.ToString())) { MessageBox.Show("La nouvelle tâche n'a pas pu être sélectionnée car absente. Veuillez changer de page ou modifier les filtres"); } } var selectedTransaction = GetSelectedMainTask(); if (selectedTransaction != null) { MainTaskSelectionChanged(selectedTransaction); } else { MainTaskSelectionChanged(null); } } else { NothingSelected(null, null); } CommandEnableManagement(); dgvMain.PerformLayout(); }
public bool RunCheckup() { DialogResult = OpenModeEnum.NotAllowed; using (var releaseService = new Service.Release.Front.ReleaseService(_Project.Group.GetEnvironment().GetSQLExtendConnectionString())) { var openedTask = releaseService.GetDevMainTasks(Library.Tools.Enums.GranularityEnum.Full); var concerneTaskList = openedTask.Enum().Where(x => x.SubTasks.Enum().Any(y => y.ProjectGUID == _Project.Id)).Enum().ToList(); if (concerneTaskList.Any()) { _MainBindingSource.DataSource = concerneTaskList.Enum().Select(x => MainTaskView.ConvertTo(x)).Enum().ToList(); return(true); } else { var answer = MessageBox.Show("Ce projet n'est dans aucune tâche. Une sous-tâche est nécessaire. L'ouverture en modification n'est pas possible. Voulez-vous ouvrir un lecture seule le projet ?", "Information", MessageBoxButtons.YesNo); if (answer == System.Windows.Forms.DialogResult.Yes) { DialogResult = OpenModeEnum.ReadOnly; return(false); } else { DialogResult = OpenModeEnum.NotAllowed; return(false); } } } }