コード例 #1
0
        public void ChargerGrille()
        {
            if (!this.IsPostBack)
            {
                if (ListeProprietes2.Length > 0)
                {
                    for (int k = 1; k < ListeProprietes2.Length; k++)
                    {
                        Proprietes p = LireDansFichier(ListeProprietes2[k]);
                        dt.Rows.Add(CreerLignePrDataRow(p));
                    }
                }
            }
            else
            {
                if (dt.Rows.Count == 0)
                {
                    if (ListeProprietes2.Length > 0)
                    {
                        for (int k = 1; k < ListeProprietes2.Length; k++)
                        {
                            Proprietes p = LireDansFichier(ListeProprietes2[k]);
                            dt.Rows.Add(CreerLignePrDataRow(p));
                        }
                    }
                }
            }

            int i = dt.Rows.Count;

            Session["mydata"] = dt;
            Session1();
        }
コード例 #2
0
ファイル: Default.aspx.cs プロジェクト: NathDems/Essai2
        public void AjouterDansFichier(Proprietes p)
        {
            string ligne = p.ProprID.ToString() + Separateur + p.ProprURL + Separateur + p.Adresse + Separateur +
                           p.PrixVente.ToString() + Separateur + p.PrixMunicipal + Separateur + p.AnneeConstr.ToString() +
                           Separateur + p.DateVisite.ToString() + Separateur + p.AgentImmob + Separateur + p.SiteVente +
                           Separateur + p.Garage + Separateur + p.EstAVisiter.ToString() + Separateur +
                           p.Cotation.ToString() + Separateur + p.Photo + Separateur + p.Commentaire;

            EcrireTexteFinFichier(ligne);
        }
コード例 #3
0
        public DataRow CreerLignePrDataRow(Proprietes prop)
        {
            DataRow ligne = dt.NewRow();

            //int NbChamp = 7;
            // string ligne[] = new string[NbChamp];
            ligne["id"]         = prop.ProprID;
            ligne["image"]      = "/img/" + prop.Photo;
            ligne["prix"]       = prop.PrixVente;
            ligne["evaluation"] = prop.PrixMunicipal;
            ligne["annee"]      = prop.AnneeConstr;
            ligne["adresse"]    = prop.Adresse;
            ligne["agence"]     = prop.SiteVente;
            ligne["agent"]      = prop.AgentImmob;
            return(ligne);
        }
コード例 #4
0
ファイル: Default.aspx.cs プロジェクト: NathDems/Essai2
        public Proprietes CreerNewPropr(int rangDeLaProprieteDansFichier,
                                        string _ProprURL, string _Adresse, double _PrixVente, double _PrixMunicipal,
                                        int _AnneeConstr, DateTime _DateVisite, string _AgentImmob, string _SiteVente,
                                        bool _Garage, bool _EstAVisiter, int _Cotation, string _Photo, string _Commentaire
                                        )
        {
            // si rangDeLaProprieteDansFichier est zero, on en ajoutera pas dans le fichier
            // si rangDeLaProprieteDansFichier est non nul, la valeur entree est celle du nombre de proprietes
            Proprietes propr = new Proprietes(
                _ProprURL, _Adresse, _PrixVente, _PrixMunicipal,
                _AnneeConstr, _DateVisite, _AgentImmob, _SiteVente,
                _Garage, _EstAVisiter, _Cotation, _Photo, _Commentaire
                );

            if (rangDeLaProprieteDansFichier != 0)            // nouvelle propriete
            {
                propr.ProprID = rangDeLaProprieteDansFichier; // AugmenterNombreProprDsFichier();
                AjouterDansFichier(propr);
            }
            return(propr);
        }
コード例 #5
0
ファイル: Default.aspx.cs プロジェクト: NathDems/Essai2
        public Proprietes LireDansFichier(int rang)
        {
            // Retourne la propriete telel que son ID = rang - Null par defaut
            string ligne = string.Empty;

            try
            {
                StreamReader sr     = new StreamReader(NomFichier);
                string[]     lignes = System.IO.File.ReadAllLines(NomFichier);
                sr.Close();
                // chercher la bonne ligne à partir du ID de la propriété
                if (lignes.Length > 0)      // s<assurer qu<il y a au moins une propriete
                {
                    // parcourir les lignes et chercher le ID = rang
                    int  i      = 0;
                    bool sortir = false;
                    do
                    {
                        i += 1;
                        // extraire le ID de la ligne
                        int j = ObtientIDDepuisLeFormatTexte(lignes[i]);    // obtenir le ID contenu dans la ligne
                        if (j > 0)
                        //if (result == true)
                        {
                            if (rang == j)
                            {      // la premiere propriete est dans la ligne 1
                                ligne  = lignes[rang];
                                sortir = true;
                            }
                        }
                    } while ((i < lignes.Length - 1) && (sortir == false));
                }
            }
            catch (Exception e)
            {
                Message = "Erreur : " + e.Message;
            }
            // creer la proprirte qui sera retrournee
            Proprietes prop = new Proprietes();

            // pour charger propr, convertir la ligne en champs
            if (ligne != string.Empty)
            {
                int      nbChamp = 14;
                string[] champs = new string[nbChamp];
                string   mot = string.Empty;
                int      rangMot = 0; int i = 0;
                do
                {
                    if ((i == ligne.Length) || (ligne.ElementAt(i) == Separateur.ElementAt(0)))
                    {
                        champs[rangMot] = mot;
                        if (i < ligne.Length)
                        {
                            rangMot += 1;
                        }
                        mot = string.Empty;
                    }
                    else
                    {
                        mot += ligne.ElementAt(i);
                    }
                    i += 1;
                } while (i <= ligne.Length);

                // attribuer les champs aux valeurs de propr
                prop.ProprID       = int.Parse(champs[0]);
                prop.ProprURL      = champs[1];                 // _ProprURL;
                prop.Adresse       = champs[2];                 //_Adresse;
                prop.PrixVente     = double.Parse(champs[3]);   //_PrixVente;
                prop.PrixMunicipal = double.Parse(champs[4]);   //_PrixMunicipal;
                prop.AnneeConstr   = int.Parse(champs[5]);      //AnneeConstr;
                prop.DateVisite    = DateTime.Parse(champs[6]); //_DateVisite; // DateTime.Today;
                prop.AgentImmob    = champs[7];                 //_AgentImmob;
                prop.SiteVente     = champs[8];                 //_SiteVente;
                string s = champs[9];
                if ((champs[9].ToUpper() == "FALSE") || (champs[9] == "0"))
                {
                    prop.Garage = false;
                }
                else
                {
                    prop.Garage = true;
                }
                s = champs[10];
                if ((champs[10].ToUpper() == "FALSE") || (champs[10] == "0"))
                {
                    prop.EstAVisiter = false;
                }
                else
                {
                    prop.EstAVisiter = true;
                }
                s                = champs[11];
                prop.Cotation    = int.Parse(champs[11]); //_Cotation;
                s                = champs[12];
                prop.Photo       = champs[12];            //_Photo;
                prop.Commentaire = champs[13];            // _Commentaire;
            }
            return(prop);
        }