Ejemplo n.º 1
0
        private void Button_save_Click(object sender, RoutedEventArgs e)
        {
            //string saveFolderpath = @".\ContactImages\";

            string filepath = tbPathImage.Text;

            //FileInfo fi = new FileInfo(filepath);

            //string finename = Guid.NewGuid().ToString() + fi.Extension;

            //if (!Directory.Exists(saveFolderpath))
            //{
            //    Directory.CreateDirectory(saveFolderpath);
            //}

            //System.IO.File.Copy(filepath, saveFolderpath + finename, true);

            imgSrc.Source = null;

            using (var context = new AVosSouhaits.AVSouhaitsDBEntities())
            {
                Composant compo = new Composant();

                //if (idProjet.Text != string.Empty)
                //{
                //    long idProj = long.Parse(idProjet.Text);

                //    projet = (from b in context.Projets
                //              where b.IdProjet == idProj
                //              select b).FirstOrDefault();
                //}
                //else
                //{
                context.Composants.Add(compo);
                //}

                compo.Nom = tbName.Text;
                compo.Note = tbNote.Text;
                compo.UrlPhoto = "urlPicture";
                compo.Image = ConvertImage(filepath);
                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Projet projet = new Projet();

            using (var context = new AVosSouhaits.AVSouhaitsDBEntities())
            {
                if (idProjet.Text != string.Empty)
                {
                    long idProj = long.Parse(idProjet.Text);

                    projet = (from b in context.Projets
                              where b.IdProjet == idProj
                              select b).FirstOrDefault();
                }
                else
                {
                    context.Projets.Add(projet);
                }

                projet.Civilite1 = long.Parse(CbCivi1.SelectedValue.ToString());
                projet.Nom1 = nom1.Text;
                projet.Prenom1 = prenom1.Text;
                projet.Civilite2 = long.Parse(CbCivi2.SelectedValue.ToString());
                projet.Nom2 = nom2.Text;
                projet.Prenom2 = prenom2.Text;
                projet.Telephone = telephone.Text;
                projet.Ville = ville.Text;
                projet.Email = email.Text;
                projet.Adresse = adresse.Text;
                projet.CodePostal = codepostal.Text;
                projet.Budget = long.Parse(budget.Text);
                projet.DateDuMariage = DateTime.Parse(dateDuMarriage.Text);

                context.SaveChanges();
            }

            expand.IsExpanded = false;
        }