protected void Button1_Click(object sender, EventArgs e)
        {
            using (ServiceAgence.AgenceClient client = new ServiceAgence.AgenceClient())
            {
                ServiceAgence.BienImmobilier mBien = new ServiceAgence.BienImmobilier();
                //On crée un bien complet

                mBien.Titre = BoxTitre.Text;
                mBien.Prix = Double.Parse(BoxPrixDemande.Text);
                mBien.MontantCharges = Double.Parse(BoxMontantCharges.Text);
                mBien.Ville = BoxVille.Text;
                mBien.CodePostal = BoxCodePostal.Text;
                mBien.TransactionEffectuee = false;
                //On récupère la date du jour et l'heure            MARCHE!!!!!!!!!
                DateTime localDate = DateTime.Now;
                mBien.DateMiseEnTransaction = localDate;
                mBien.DateTransaction = null;

                /*
                Non affichés lors du mode admin
                */

                mBien.Description = BoxDescription.Text;
                mBien.Surface = Double.Parse(BoxSurface.Text);
                mBien.Adresse = BoxAdresse.Text;
                mBien.NbPieces = int.Parse(BoxNbPiece.Text);
                mBien.NbEtages = int.Parse(BoxNbPiece.Text);
                mBien.NumEtage = int.Parse(BoxNumEtage.Text);

                mBien.TypeBien = (ServiceAgence.BienImmobilierBase.eTypeBien)Enum.Parse(typeof(ServiceAgence.BienImmobilierBase.eTypeBien), type_bien.SelectedValue);
                mBien.TypeChauffage = (ServiceAgence.BienImmobilierBase.eTypeChauffage)Enum.Parse(typeof(ServiceAgence.BienImmobilierBase.eTypeChauffage), type_chauffage.SelectedValue);
                mBien.EnergieChauffage = (ServiceAgence.BienImmobilierBase.eEnergieChauffage)Enum.Parse(typeof(ServiceAgence.BienImmobilierBase.eEnergieChauffage), type_energie_chauffage.SelectedValue);
                mBien.TypeTransaction = (ServiceAgence.BienImmobilierBase.eTypeTransaction)Enum.Parse(typeof(ServiceAgence.BienImmobilierBase.eTypeTransaction), type_transaction.SelectedValue);

                /*
                Création de la galerie de photos
                */
                List<String> mListe = new List<string>();
                int iLen;
                byte[] btArr;
                IList<HttpPostedFile> listePhoto =  FileuploadGroup.PostedFiles;
                foreach (var item in listePhoto)
                {
                    iLen = item.ContentLength;
                    btArr = new byte[iLen];
                    item.InputStream.Read(btArr, 0, iLen);
                    mListe.Add((Convert.ToBase64String(btArr)));
                }
                mBien.PhotosBase64 = mListe;

                /*
                ajouter la gestion des erreurs
                */
                //On ajoute dans la BD
                client.AjouterBienImmobilier(mBien);
                //On modifie le label pour dire que l'action est faite
                mLabel.Text = "Insertion faite";
            }
        }
Beispiel #2
0
        private void save_Click(object sender, RoutedEventArgs e)
        {
            using (ServiceAgence.AgenceClient client = new ServiceAgence.AgenceClient())
            {
                client.Open();


                if (id_bien == -1)                 // Ajouter
                {
                    bien.DateMiseEnTransaction = DateTime.Now;
                    bien.DateTransaction       = null;
                    bien.TransactionEffectuee  = false;
                    if (u == null)
                    {
                        u = new Uri(@".\images\nothumbnail.png", UriKind.Relative);
                    }

                    BitmapImage bi = new BitmapImage(u);
                    bien.PhotoPrincipaleBase64 = BitmapImagetoBase64(bi);
                    bien.PhotosBase64          = new ObservableCollection <string>();
                    bien.PhotosBase64.Add(bien.PhotoPrincipaleBase64);


                    ServiceAgence.ResultatBool r = client.AjouterBienImmobilier(bien);
                }

                else                 // Modifier
                {
                    if (u != null)
                    {
                        BitmapImage bi = new BitmapImage(u);
                        bien.PhotoPrincipaleBase64 = BitmapImagetoBase64(bi);
                        bien.PhotosBase64          = new ObservableCollection <string>();
                        bien.PhotosBase64.Add(bien.PhotoPrincipaleBase64);
                    }
                    ServiceAgence.ResultatBool res = client.ModifierBienImmobilier(bien);
                }


                client.Close();
            }

            this.DialogResult = true;

            this.Close();
        }
Beispiel #3
0
        private void textBox_valider_Click(object sender, RoutedEventArgs e)
        {
            ServiceAgence.BienImmobilier bien = new ServiceAgence.BienImmobilier();

            bien.Adresse        = textBox_adresse.Text;
            bien.CodePostal     = textBox_codePostal.Text;
            bien.Description    = textBox_description.Text;
            bien.MontantCharges = int.Parse(textBox_charges.Text);
            bien.NbEtages       = int.Parse(textBox_nbEtages.Text);
            bien.NbPieces       = int.Parse(textBox_nbPieces.Text);
            bien.NumEtage       = int.Parse(textBox_numEtage.Text);
            bien.Prix           = int.Parse(textBox_prix.Text);
            bien.Surface        = int.Parse(textBox_surface.Text);
            bien.Titre          = textBox_titre.Text;
            bien.Ville          = textBox_ville.Text;

            using (ServiceAgence.AgenceClient client = new ServiceAgence.AgenceClient())
            {
                client.AjouterBienImmobilier(bien);
            }

            this.Close();
        }
        private void btnValider_Click(object sender, RoutedEventArgs e)
        {
            using (ServiceAgence.AgenceClient client = new ServiceAgence.AgenceClient())
            {
                try {
                    ServiceAgence.BienImmobilier mBien = new ServiceAgence.BienImmobilier();
                    //On crée un bien complet

                    mBien.Titre                = BoxTitre.Text;
                    mBien.Prix                 = Double.Parse(BoxPrix.Text);
                    mBien.MontantCharges       = Double.Parse(BoxMontantCharges.Text);
                    mBien.Ville                = BoxVille.Text;
                    mBien.CodePostal           = BoxCodePostal.Text;
                    mBien.TransactionEffectuee = false;
                    //On récupère la date du jour et l'heure
                    DateTime localDate = DateTime.Now;
                    mBien.DateMiseEnTransaction = localDate;
                    mBien.DateTransaction       = null;

                    mBien.Description = BoxDescription.Text;
                    mBien.Surface     = Double.Parse(BoxSurface.Text);
                    mBien.Adresse     = BoxAdresse.Text;
                    mBien.NbPieces    = int.Parse(BoxNbPiece.Text);
                    mBien.NbEtages    = int.Parse(BoxNbEtage.Text);
                    mBien.NumEtage    = int.Parse(BoxNumEtage.Text);

                    //////////////////////////////

                    mBien.TypeBien         = (ServiceAgence.BienImmobilierBase.eTypeBien)type_bien.SelectedValue;
                    mBien.TypeChauffage    = (ServiceAgence.BienImmobilierBase.eTypeChauffage)type_chauffages.SelectedValue;
                    mBien.EnergieChauffage = (ServiceAgence.BienImmobilierBase.eEnergieChauffage)type_energies_chauffage.SelectedValue;
                    mBien.TypeTransaction  = (ServiceAgence.BienImmobilierBase.eTypeTransaction)type_transaction.SelectedValue;


                    /*
                     * Création de la galerie de photos
                     */
                    ObservableCollection <String> mCollection = new ObservableCollection <string>();
                    foreach (String item in mesImages)
                    {
                        mCollection.Add(item);
                    }
                    mBien.PhotosBase64 = mCollection;

                    /*
                     * ajouter la gestion des erreurs
                     */
                    //On ajoute dans la BD
                    client.AjouterBienImmobilier(mBien);
                }
                catch (InvalidCastException inv)
                {
                    Console.WriteLine(inv.StackTrace);
                }
                catch (FormatException form)
                {
                    Console.WriteLine(form.StackTrace);
                }
                this.Close();
            }
        }
Beispiel #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Admin"] == null || Session["Admin"].ToString() == "false")
            {
                Response.Redirect("~/Connexion.aspx");
            }
            else
            {
                Catalogue obj = new Catalogue();

                string id = Request.QueryString["id"];

                if (!this.IsPostBack)
                {
                    obj.Load_DropDownListItem <ServiceAgence.BienImmobilierBase.eTypeBien>(DropDownListTypeBien, false);
                    obj.Load_DropDownListItem <ServiceAgence.BienImmobilierBase.eTypeChauffage>(DropDownListTypeChauffage, false);
                    obj.Load_DropDownListItem <ServiceAgence.BienImmobilierBase.eEnergieChauffage>(DropDownListEnergieChauffage, false);
                    obj.Load_DropDownListItem <ServiceAgence.BienImmobilierBase.eTypeTransaction>(DropDownListTypeTransaction, false);

                    DropDownListTypeBien.SelectedValue         = "0";
                    DropDownListEnergieChauffage.SelectedValue = "0";
                    DropDownListTypeChauffage.SelectedValue    = "0";
                    DropDownListTypeTransaction.SelectedValue  = "0";



                    if (id != null)
                    {
                        using (ServiceAgence.AgenceClient client = new ServiceAgence.AgenceClient())
                        {
                            client.Open();

                            ServiceAgence.BienImmobilier bien = client.LireDetailsBienImmobilier(id).Bien;
                            if (bien == null)
                            {
                                Response.Redirect("~/erreur.aspx");
                            }

                            Titre.Text          = bien.Titre;
                            Prix.Text           = bien.Prix.ToString();
                            MontantCharges.Text = bien.MontantCharges.ToString();
                            Adresse.Text        = bien.Adresse;
                            CP.Text             = bien.CodePostal;
                            Ville.Text          = bien.Ville;
                            Surface.Text        = bien.Surface.ToString();
                            NombreEtage.Text    = bien.NbEtages.ToString();
                            NumeroEtage.Text    = bien.NumEtage.ToString();
                            Description.Text    = bien.Description;
                            NombrePiece.Text    = bien.NbPieces.ToString();
                            Description.Text    = bien.Description;
                            DropDownListTypeBien.SelectedIndex         = (int)bien.TypeBien;
                            DropDownListTypeTransaction.SelectedIndex  = (int)bien.TypeTransaction;
                            DropDownListTypeChauffage.SelectedIndex    = (int)bien.TypeChauffage;
                            DropDownListEnergieChauffage.SelectedIndex = (int)bien.EnergieChauffage;
                        }
                    }
                }

                if (this.IsPostBack)
                {
                    using (ServiceAgence.AgenceClient client = new ServiceAgence.AgenceClient())
                    {
                        client.Open();

                        ServiceAgence.BienImmobilier bien;

                        if (id == null)
                        {
                            bien = new ServiceAgence.BienImmobilier();
                            Initbien(bien);
                        }
                        else
                        {
                            bien = client.LireDetailsBienImmobilier(id).Bien;
                        }



                        bien.Adresse               = Adresse.Text;
                        bien.CodePostal            = CP.Text;
                        bien.DateMiseEnTransaction = DateTime.Now;
                        bien.DateTransaction       = null; // ?? A completer ??
                        bien.Description           = Description.Text;
                        bien.EnergieChauffage      = (ServiceAgence.BienImmobilierBase.eEnergieChauffage)obj.AffectSelectedValue(DropDownListEnergieChauffage);
                        bien.MontantCharges        = ConvertStringToDouble(MontantCharges.Text, 0);
                        bien.NbEtages              = ConvertStringToInt(NombreEtage.Text, 0);
                        bien.NbPieces              = ConvertStringToInt(NombrePiece.Text, 0);
                        bien.NumEtage              = ConvertStringToInt(NumeroEtage.Text, 0);
                        bien.PhotoPrincipaleBase64 = "";
                        bien.PhotosBase64          = new List <string>();

                        PutImage(ImageP, bien);
                        PutImage(Image1, bien);
                        PutImage(Image2, bien);


                        bien.Prix    = ConvertStringToDouble(Prix.Text, 0);
                        bien.Surface = ConvertStringToDouble(Surface.Text, 0);

                        bien.Titre = Titre.Text;
                        bien.TransactionEffectuee = false;
                        bien.TypeBien             = (ServiceAgence.BienImmobilierBase.eTypeBien)obj.AffectSelectedValue(DropDownListTypeBien);
                        bien.TypeChauffage        = (ServiceAgence.BienImmobilierBase.eTypeChauffage)obj.AffectSelectedValue(DropDownListTypeChauffage);
                        bien.TypeTransaction      = (ServiceAgence.BienImmobilierBase.eTypeTransaction)obj.AffectSelectedValue(DropDownListTypeTransaction);
                        bien.Ville = Ville.Text;

                        if (id != null)
                        {
                            bien.Id = Convert.ToInt32(id);
                            client.ModifierBienImmobilier(bien);
                        }
                        else
                        {
                            client.AjouterBienImmobilier(bien);
                        }


                        client.Close();
                    }

                    Response.Redirect("~/Administration.aspx");
                }
            }
        }
Beispiel #6
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            using (ServiceAgence.AgenceClient client = new ServiceAgence.AgenceClient())
            {
                ServiceAgence.BienImmobilier mBien = new ServiceAgence.BienImmobilier();
                //On crée un bien complet

                mBien.Titre                = BoxTitre.Text;
                mBien.Prix                 = Double.Parse(BoxPrixDemande.Text);
                mBien.MontantCharges       = Double.Parse(BoxMontantCharges.Text);
                mBien.Ville                = BoxVille.Text;
                mBien.CodePostal           = BoxCodePostal.Text;
                mBien.TransactionEffectuee = false;
                //On récupère la date du jour et l'heure            MARCHE!!!!!!!!!
                DateTime localDate = DateTime.Now;
                mBien.DateMiseEnTransaction = localDate;
                mBien.DateTransaction       = null;


                /*
                 * Non affichés lors du mode admin
                 */

                mBien.Description = BoxDescription.Text;
                mBien.Surface     = Double.Parse(BoxSurface.Text);
                mBien.Adresse     = BoxAdresse.Text;
                mBien.NbPieces    = int.Parse(BoxNbPiece.Text);
                mBien.NbEtages    = int.Parse(BoxNbPiece.Text);
                mBien.NumEtage    = int.Parse(BoxNumEtage.Text);



                mBien.TypeBien         = (ServiceAgence.BienImmobilierBase.eTypeBien)Enum.Parse(typeof(ServiceAgence.BienImmobilierBase.eTypeBien), type_bien.SelectedValue);
                mBien.TypeChauffage    = (ServiceAgence.BienImmobilierBase.eTypeChauffage)Enum.Parse(typeof(ServiceAgence.BienImmobilierBase.eTypeChauffage), type_chauffage.SelectedValue);
                mBien.EnergieChauffage = (ServiceAgence.BienImmobilierBase.eEnergieChauffage)Enum.Parse(typeof(ServiceAgence.BienImmobilierBase.eEnergieChauffage), type_energie_chauffage.SelectedValue);
                mBien.TypeTransaction  = (ServiceAgence.BienImmobilierBase.eTypeTransaction)Enum.Parse(typeof(ServiceAgence.BienImmobilierBase.eTypeTransaction), type_transaction.SelectedValue);

                /*
                 * Création de la galerie de photos
                 */
                List <String>          mListe = new List <string>();
                int                    iLen;
                byte[]                 btArr;
                IList <HttpPostedFile> listePhoto = FileuploadGroup.PostedFiles;
                foreach (var item in listePhoto)
                {
                    iLen  = item.ContentLength;
                    btArr = new byte[iLen];
                    item.InputStream.Read(btArr, 0, iLen);
                    mListe.Add((Convert.ToBase64String(btArr)));
                }
                mBien.PhotosBase64 = mListe;

                /*
                 * ajouter la gestion des erreurs
                 */
                //On ajoute dans la BD
                client.AjouterBienImmobilier(mBien);
                //On modifie le label pour dire que l'action est faite
                mLabel.Text = "Insertion faite";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Admin"] == null || Session["Admin"].ToString() == "false")
            {
                Response.Redirect("~/Connexion.aspx");
            }
            else
            {
                Catalogue obj = new Catalogue();

                string id = Request.QueryString["id"];

                if (!this.IsPostBack)
                {

                    obj.Load_DropDownListItem<ServiceAgence.BienImmobilierBase.eTypeBien>(DropDownListTypeBien, false);
                    obj.Load_DropDownListItem<ServiceAgence.BienImmobilierBase.eTypeChauffage>(DropDownListTypeChauffage, false);
                    obj.Load_DropDownListItem<ServiceAgence.BienImmobilierBase.eEnergieChauffage>(DropDownListEnergieChauffage, false);
                    obj.Load_DropDownListItem<ServiceAgence.BienImmobilierBase.eTypeTransaction>(DropDownListTypeTransaction, false);

                    DropDownListTypeBien.SelectedValue = "0";
                    DropDownListEnergieChauffage.SelectedValue = "0";
                    DropDownListTypeChauffage.SelectedValue = "0";
                    DropDownListTypeTransaction.SelectedValue = "0";

                    if (id != null)
                    {

                        using (ServiceAgence.AgenceClient client = new ServiceAgence.AgenceClient())
                        {
                            client.Open();

                            ServiceAgence.BienImmobilier bien = client.LireDetailsBienImmobilier(id).Bien;
                            if(bien == null)
                            {
                                Response.Redirect("~/erreur.aspx");
                            }

                            Titre.Text = bien.Titre;
                            Prix.Text = bien.Prix.ToString();
                            MontantCharges.Text = bien.MontantCharges.ToString();
                            Adresse.Text = bien.Adresse;
                            CP.Text = bien.CodePostal;
                            Ville.Text = bien.Ville;
                            Surface.Text = bien.Surface.ToString();
                            NombreEtage.Text = bien.NbEtages.ToString();
                            NumeroEtage.Text = bien.NumEtage.ToString();
                            Description.Text = bien.Description;
                            NombrePiece.Text = bien.NbPieces.ToString();
                            Description.Text = bien.Description;
                            DropDownListTypeBien.SelectedIndex = (int)bien.TypeBien;
                            DropDownListTypeTransaction.SelectedIndex = (int)bien.TypeTransaction;
                            DropDownListTypeChauffage.SelectedIndex = (int)bien.TypeChauffage;
                            DropDownListEnergieChauffage.SelectedIndex = (int)bien.EnergieChauffage;

                        }

                    }

                }

                if (this.IsPostBack)
                {
                    using (ServiceAgence.AgenceClient client = new ServiceAgence.AgenceClient())
                    {
                        client.Open();

                        ServiceAgence.BienImmobilier bien;

                        if (id == null)
                        {
                            bien = new ServiceAgence.BienImmobilier();
                            Initbien(bien);
                        }
                        else
                        {
                            bien = client.LireDetailsBienImmobilier(id).Bien;

                        }

                        bien.Adresse = Adresse.Text;
                        bien.CodePostal = CP.Text;
                        bien.DateMiseEnTransaction = DateTime.Now;
                        bien.DateTransaction = null; // ?? A completer ??
                        bien.Description = Description.Text;
                        bien.EnergieChauffage = (ServiceAgence.BienImmobilierBase.eEnergieChauffage)obj.AffectSelectedValue(DropDownListEnergieChauffage);
                        bien.MontantCharges = ConvertStringToDouble(MontantCharges.Text, 0);
                        bien.NbEtages = ConvertStringToInt(NombreEtage.Text, 0);
                        bien.NbPieces = ConvertStringToInt(NombrePiece.Text, 0);
                        bien.NumEtage = ConvertStringToInt(NumeroEtage.Text, 0);
                        bien.PhotoPrincipaleBase64 = "";
                        bien.PhotosBase64 = new List<string>();

                        PutImage(ImageP, bien);
                        PutImage(Image1, bien);
                        PutImage(Image2, bien);

                        bien.Prix = ConvertStringToDouble(Prix.Text, 0);
                        bien.Surface = ConvertStringToDouble(Surface.Text, 0);

                        bien.Titre = Titre.Text;
                        bien.TransactionEffectuee = false;
                        bien.TypeBien = (ServiceAgence.BienImmobilierBase.eTypeBien)obj.AffectSelectedValue(DropDownListTypeBien);
                        bien.TypeChauffage = (ServiceAgence.BienImmobilierBase.eTypeChauffage)obj.AffectSelectedValue(DropDownListTypeChauffage);
                        bien.TypeTransaction = (ServiceAgence.BienImmobilierBase.eTypeTransaction)obj.AffectSelectedValue(DropDownListTypeTransaction);
                        bien.Ville = Ville.Text;

                        if (id != null)
                        {
                            bien.Id = Convert.ToInt32(id);
                            client.ModifierBienImmobilier(bien);
                        }
                        else
                        {
                            client.AjouterBienImmobilier(bien);
                        }

                        client.Close();
                    }

                    Response.Redirect("~/Administration.aspx");
                }
            }
        }
        private void btnValider_Click(object sender, RoutedEventArgs e)
        {
            using (ServiceAgence.AgenceClient client = new ServiceAgence.AgenceClient())
            {
                try {
                    ServiceAgence.BienImmobilier mBien = new ServiceAgence.BienImmobilier();
                    //On crée un bien complet

                    mBien.Titre = BoxTitre.Text;
                    mBien.Prix = Double.Parse(BoxPrix.Text);
                    mBien.MontantCharges = Double.Parse(BoxMontantCharges.Text);
                    mBien.Ville = BoxVille.Text;
                    mBien.CodePostal = BoxCodePostal.Text;
                    mBien.TransactionEffectuee = false;
                    //On récupère la date du jour et l'heure
                    DateTime localDate = DateTime.Now;
                    mBien.DateMiseEnTransaction = localDate;
                    mBien.DateTransaction = null;

                    mBien.Description = BoxDescription.Text;
                    mBien.Surface = Double.Parse(BoxSurface.Text);
                    mBien.Adresse = BoxAdresse.Text;
                    mBien.NbPieces = int.Parse(BoxNbPiece.Text);
                    mBien.NbEtages = int.Parse(BoxNbEtage.Text);
                    mBien.NumEtage = int.Parse(BoxNumEtage.Text);

                    //////////////////////////////

                    mBien.TypeBien = (ServiceAgence.BienImmobilierBase.eTypeBien)type_bien.SelectedValue;
                    mBien.TypeChauffage = (ServiceAgence.BienImmobilierBase.eTypeChauffage)type_chauffages.SelectedValue;
                    mBien.EnergieChauffage = (ServiceAgence.BienImmobilierBase.eEnergieChauffage)type_energies_chauffage.SelectedValue;
                    mBien.TypeTransaction = (ServiceAgence.BienImmobilierBase.eTypeTransaction)type_transaction.SelectedValue;

                    /*
                    Création de la galerie de photos
                    */
                    ObservableCollection<String> mCollection = new ObservableCollection<string>();
                    foreach (String item in mesImages)
                    {
                        mCollection.Add(item);
                    }
                    mBien.PhotosBase64 = mCollection;
                    /*
                    ajouter la gestion des erreurs
                    */
                    //On ajoute dans la BD
                    client.AjouterBienImmobilier(mBien);
                }
                catch (InvalidCastException inv)
                {
                    Console.WriteLine(inv.StackTrace);
                }
                catch (FormatException form)
                {
                    Console.WriteLine(form.StackTrace);
                }
                this.Close();
            }
        }