コード例 #1
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            ConcertEvent concert = new ConcertEvent();

            concert.BeginningDate      = this.BeginingDate.SelectedDate;
            concert.EndDate            = this.EndDate.SelectedDate;
            concert.Country            = this.CountryTextBox.Text;
            concert.City               = this.CitytextBox.Text;
            concert.Address            = this.AddresTextBox.Text;
            concert.ConcertTypeId      = concertTypeRepositoty.Get(p => p.Name == this.TypeComboBox.Text).First().ID;
            concert.ConcertPlaceTypeId = concertPlaceTypeRepository.Get(p => p.Name == this.TypePlaceComboBox.Text).First().ID;
            concert.Description        = this.DescriptionTextBox.Text;


            concertRepositoty.Insert(concert);

            if (workerListView.Items != null)
            {
                concert.ConcertMarks = null;
                //ICollection<ConcertMarks> concertMarks = new System.Collections.ObjectModel.Collection<ConcertMarks>();
                for (int i = 0; i < workerListView.Items.Count; i++)
                {
                    Items Value = (Items)workerListView.Items[i];

                    ConcertMarks concertMark = new ConcertMarks();
                    concertMark.NumOfMarks     = Value.mark;
                    concertMark.ConcertEventID = concert.ID;
                    concertMark.WorkerID       = Value.wrk.ID;


                    concertMarksRepositoty.Insert(concertMark);
                }
                concertRepositoty.Update(concert);
            }

            concertRepositoty.UpdateCache(concert, concert.ID);


            MessageBox.Show("добавлен");
            Close_Click(sender, e);
            //this.btnReload_Click(sender, e);
        }
コード例 #2
0
        private void AddWorkerButton_Click(object sender, RoutedEventArgs e)
        {
            List <Worker> wrList = new List <Worker>();

            if (workerListView.Items != null)
            {
                for (int i = 0; i < workerListView.Items.Count; i++)
                {
                    Items Value = (Items)workerListView.Items[i];
                    wrList.Add(Value.wrk);
                }
            }



            AddWorkersToConcertWindow addWorker = new AddWorkersToConcertWindow(wrList);

            this.Visibility = Visibility.Collapsed;
            addWorker.ShowDialog();
            if (addWorker.DialogResult.HasValue && addWorker.DialogResult.Value)
            {
                workerListView.Items.Add(new Items
                {
                    wrk  = addWorker.Worker,
                    mark = addWorker.Mark
                });

                ConcertEvent concert = concertRepositoty.GetByIdFromCahce(id);

                ConcertMarks concertMark = new ConcertMarks();
                concertMark.NumOfMarks     = addWorker.Mark;
                concertMark.ConcertEventID = concert.ID;
                concertMark.WorkerID       = addWorker.Worker.ID;

                concertMarksRepositoty.Insert(concertMark);
            }
            this.Visibility = Visibility.Visible;

            workerListView.Items.Refresh();
        }