コード例 #1
0
        private void ButtonUpdateOffer_Click(object sender, RoutedEventArgs e)
        {
            Offer offer = (Offer)ListOffer.SelectedItem;

            if (offer != null)
            {
                OfferWindow offerWindow = new OfferWindow(db);
                OfferDataContext offerDataContext = new OfferDataContext();
                offerDataContext.Offer = offer;
                offerDataContext.JobDomains = new ObservableCollection<JobDomain>(db.JobDomain.ToList());
                offerDataContext.Jobs = new ObservableCollection<Job>(db.Job.ToList());
                offerDataContext.TypeOfContracts = new ObservableCollection<TypeOfContract>(db.TypeOfContract.ToList());
                offerDataContext.Clients = new ObservableCollection<Client>(db.Client.ToList());

                offerWindow.DataContext = offerDataContext;
                offerWindow.ShowDialog();

                if (offerWindow.DialogResult == true)
                {
                    db.SaveChanges();
                }
            }
            else
            {
                MessageBox.Show("Veuillez sélectionner une offre.");
            }
        }
コード例 #2
0
        private void ButtonAddOffer_Click(object sender, RoutedEventArgs e)
        {
            Offer offer = new Offer();
            OfferWindow offerWindow = new OfferWindow(db);
            offer.DateStartContract = DateTime.Today;
            offer.DateStartPublication = DateTime.Today;
            OfferDataContext offerDataContext = new OfferDataContext();
            offerDataContext.Offer = offer;
            offerDataContext.Clients = new ObservableCollection<Client>(db.Client.ToList());
            offerDataContext.JobDomains = new ObservableCollection<JobDomain>(db.JobDomain.ToList());
            offerDataContext.Jobs = new ObservableCollection<Job>(db.Job.ToList());
            offerDataContext.TypeOfContracts = new ObservableCollection<TypeOfContract>(db.TypeOfContract.ToList());

            offerWindow.DataContext = offerDataContext;
            offerWindow.ShowDialog();

            if (offerWindow.DialogResult == true)
            {
                Offers.Add(offer);
                db.Offer.Add(offer);

                db.SaveChanges();
            }
        }