Example #1
0
        public void Load(ORM.ProjectInfoView project)
        {
            if (_dc != null)
            {
                _dc.Dispose();
            }
            ;
            _dc = new FPMDataContext();
            Stages.Clear();
            var mainStage = new ProjectStageTile()
            {
                ID        = -1,
                Name      = "Основные данные",
                SortIndex = 0,
                IsPublic  = true,
                RowState  = 0,
            };

            Stages.Add(mainStage);
            FocusedStage = mainStage;

            _project         = project;
            _originalProject = project.ToProject();

            if (_project.ID > 0)
            {
                var stages = _dc.ProjectStage
                             .Where(x => x.RowState == Convert.ToInt16(ERowState.Active) &&
                                    x.ProjectID == _project.ID &&
                                    (x.IsPublic || (UserSettings.ProfileRole == ERole.Administrator) || x.ResponsibleRole == Convert.ToInt16(UserSettings.ProfileRole)))
                             .OrderBy(x => x.SortIndex);

                foreach (var stage in stages)
                {
                    Stages.Add(new ProjectStageTile(stage));
                }
                ;
            }
            else
            {
                Stages.Add(new ProjectStageTile(EStageTemplate.Sketch, 1));
                Stages.Add(new ProjectStageTile(EStageTemplate.Contract, 2));
                Stages.Add(new ProjectStageTile(EStageTemplate.Payment, 3));
                Stages.Add(new ProjectStageTile(EStageTemplate.Shipment, 4));
            };

            Stages.Where(x => x.Project == null).ToList().ForEach(x => x.Project = _originalProject);

            OnStageChanged();
            isLoaded = true;
        }
Example #2
0
 public ProjectStageTile(ORM.Project project, int sortIndex)
     : this()
 {
     ID              = 0;
     CrtDate         = DateTime.Now;
     IsFocused       = true;
     IsPublic        = true;
     Name            = "Новая стадия";
     Note            = String.Empty;
     Project         = project;
     ProjectID       = project.ID;
     ResponsibleRole = Convert.ToInt16(ERole.Administrator);
     RowState        = Convert.ToInt16(ERowState.Active);
     SortIndex       = sortIndex;
     StageState      = (int)EStageState.Configurating;
 }