예제 #1
0
        public WindowAddTeamGroup(ObservableCollection <TeamContext> TeamContexts)
        {
            InitializeComponent();

            list             = new ObservableCollection <TeamContext>();
            data.ItemsSource = list;
            using (var db = new DbContexts.SmetaDbAppContext())
            {
                int i = 0;
                foreach (var item in db.Posts)
                {
                    if (TeamContexts.Where(x => x.Post.Id == item.Id).Any())
                    {
                        list.Add(TeamContexts[i]);
                        i++;
                    }
                    else
                    {
                        list.Add(new TeamContext()
                        {
                            Post     = item,
                            WorkTeam = new Models.Team.WorkTeam()
                            {
                                PostId = item.Id
                            }
                        });
                    }
                }
            }
        }
 public WorkSectionView(WorkSection workSection)
 {
     this.WorkSection = workSection;
     using (var db = new DbContexts.SmetaDbAppContext())
     {
         book = db.WorkTypes.Where(x => x.Id == WorkSection.WorkTypeId).Single().Name;
     }
     place = Helper.getName(WorkSection.Place);
 }
예제 #3
0
        public WorkContext(Work Work)
        {
            this.Work        = Work;
            TeamContexts     = new ObservableCollection <TeamContext>();
            MaterailContexts = new ObservableCollection <MaterialContext>();
            PriborContexts   = new ObservableCollection <PriborContext>();

            WorkSections = new ObservableCollection <WorkSection>();

            using (var db = new DbContexts.SmetaDbAppContext())
            {
                db.WorkTeams.Where(x => x.WorkDemId == Work.Id).ToList().ForEach(x =>
                {
                    TeamContexts.Add(new TeamContext(x));
                });

                List <Material> materials = db.Materials;

                // WOrk types
                WorkTypes        = db.WorkTypes;
                selectedWorkType = WorkTypes.Where(x => x.Id ==
                                                   (db.WorkSections.Where(y => y.Id == Work.WorkSectionId)).FirstOrDefault().WorkTypeId).FirstOrDefault();

                //Work sections
                db.WorkSections.Where(x => x.WorkTypeId == selectedWorkType.Id).ToList().ForEach(x =>
                {
                    WorkSections.Add(x);
                });
                selectedSection = WorkSections.Where(x => x.Id == Work.WorkSectionId).FirstOrDefault();

                // Fill Materials
                db.MaterialGroups.Where(x => x.WorkId == Work.Id).ToList().ForEach(x =>
                {
                    var item      = new MaterialContext(x);
                    item.Material = materials.Where(y => y.Id == x.MaterialId).FirstOrDefault();

                    MaterailContexts.Add(item);
                });
                List <Pribor> pribors = db.Pribors;
                //Fill Pribors
                db.PriborGroups.Where(x => x.WorkId == Work.Id).ToList().ForEach(x =>
                {
                    var item    = new PriborContext(x);
                    item.Pribor = pribors.Where(y => y.Id == x.PriborId).FirstOrDefault();

                    PriborContexts.Add(item);
                });
            }
        }
        public WindowContractList()
        {
            InitializeComponent();

            list = new ObservableCollection <Contract>();

            using (var db = new DbContexts.SmetaDbAppContext())
            {
                foreach (var item in db.Contracts.OrderByDescending(x => x.Id))
                {
                    list.Add(item);
                }
            }
            data.ItemsSource = list;
        }
예제 #5
0
 public ContextWorkSection()
 {
     pol = false;
     kam = false;
     lab = false;
     using (var db = new DbContexts.SmetaDbAppContext())
     {
         WorkTypes = db.WorkTypes;
         if (WorkTypes.Count > 0)
         {
             selectedWorkType = WorkTypes[0];
         }
     }
     WorkSection = new WorkSection();
     Comentaries = new ObservableCollection <Commentary>();
 }
 public void FillOrClearTeamWorkers(bool v)
 {
     if (v)
     {
         using (var db = new DbContexts.SmetaDbAppContext())
         {
             db.WorkTeams.Where(x => x.WorkDemId == Id).ToList().ForEach(x =>
             {
                 TeamContexts.Add(new TeamContext(x));
             });
         }
     }
     else
     {
         TeamContexts.Clear();
     }
 }