Beispiel #1
0
    protected void remplirTableAide()
    {
        if (Session["drcAideDep"] != null || drcAideDep != null)
        {
            if (drcAideDep == null)
            {
                drcAideDep = (DataRowCollection)Session["drcAideDep"];
            }
            foreach (DataRow dr in drcAideDep)
            {
                ClickableTableCell cell = new ClickableTableCell();
                cell.CssClass = "ajouterAcquereur_ClickableCell";
                TableRow tr = new TableRow();
                tr.Cells.Add(cell);
                TableAideRecherche.Rows.Add(tr);

                UpdatePanelControlTrigger trigger = new AsyncPostBackTrigger();
                trigger.ControlID = cell.UniqueID;
                UpdatePanel1.Triggers.Add(trigger);
            }
        }
        if (Session["drcAideVilles"] != null || drcAideVilles != null)
        {
            if (drcAideVilles == null)
            {
                drcAideVilles = (DataRowCollection)Session["drcAideVilles"];
            }
            foreach (DataRow dr in drcAideVilles)
            {
                ClickableTableCell cell = new ClickableTableCell();
                cell.CssClass = "ajouterAcquereur_ClickableCell";
                TableRow tr = new TableRow();
                tr.Cells.Add(cell);
                TableAideRecherche.Rows.Add(tr);

                UpdatePanelControlTrigger trigger = new AsyncPostBackTrigger();
                trigger.ControlID = cell.UniqueID;
                UpdatePanel1.Triggers.Add(trigger);
            }
        }
        if (Session["drcArrondissements"] != null || drcArrondissements != null)
        {
            if (drcArrondissements == null)
            {
                drcArrondissements = (DataRowCollection)Session["drcArrondissements"];
            }
            foreach (DataRow dr in drcArrondissements)
            {
                ClickableTableCell cell = new ClickableTableCell();
                cell.CssClass = "ajouterAcquereur_ClickableCell";
                TableRow tr = new TableRow();
                tr.Cells.Add(cell);
                TableAideRecherche.Rows.Add(tr);

                UpdatePanelControlTrigger trigger = new AsyncPostBackTrigger();
                trigger.ControlID = cell.UniqueID;
                UpdatePanel1.Triggers.Add(trigger);
            }
        }
    }
    //fonction que la cellule execute lors d un clic
    protected void remplirListeEmplacement(object sender, EventArgs e)
    {
        ClickableTableCell cell = (ClickableTableCell)sender;

        if (cell.type == "ville")
        {
            bool hasdistance = false;
            if (Convert.ToInt32(HiddenField2.Text) != 0)
            {
                hasdistance = true;
            }
            string      codeINSEE = cell.codeVille;
            Emplacement ville;

            bool hasArrondissement            = false;
            List <Arrondissement> listeArrond = null;
            if (cell.CP.Length > 5)
            {
                hasArrondissement = true;
                listeArrond       = construireListeArrond(cell.codeVille);
            }

            List <Ville> listeINSEE           = PATRIMO.Outils.OutilsDistance.villeINSEEListeDistance(cell.codeVille, Convert.ToInt32(HiddenField2.Text));
            ListeEmplacementRecherche listeER = convertListeVilleToListeEmplacement(listeINSEE);
            ville = new Emplacement(false, cell.nom, hasdistance, hasArrondissement, cell.codeVille, listeER, cell.CP, Convert.ToInt32(HiddenField2.Text), listeArrond);


            emplacementAffiche.Add(ville);

            rechargerListeERDansEmplacement(ville.CodeINSEE);
        }
        else if (cell.type == "pays")
        {
            string      codePays = cell.codeVille;
            Emplacement pays     = new Emplacement(false, cell.nom, false, false, codePays, new ListeEmplacementRecherche());
            pays.IsPays = true;
            emplacementAffiche.Add(pays);
        }
        else if (cell.type == "dep")
        {
            string      codeDep = cell.codeVille;
            Emplacement dep     = new Emplacement(true, cell.nom, false, false, codeDep, new ListeEmplacementRecherche());
            emplacementAffiche.Add(dep);
        }
        else if (cell.type == "arrondissement")
        {
            //si ville pas deja recherché: ajouter ville et bannnir tout les arrondissement sauf celui la
            //si ville existe deja, retirer arrondissement de la liste noir et recharger
            bool villeExiste = false;
            foreach (Emplacement empl in emplacementAffiche)
            {
                if (empl.CodeINSEE == cell.codeVille)
                {
                    villeExiste = true;
                    break;
                }
            }
            if (villeExiste)
            {
                foreach (Arrondissement arr in listeArrondissementNoire)
                {
                    if (arr.CP == cell.CP)
                    {
                        listeArrondissementNoire.Remove(arr);
                        break;
                    }
                }
                rafraichirArrondissement();
            }
            else
            {
                // la ville n est pas deja enrengsitrée

                bool hasdistance = false;
                if (Convert.ToInt32(HiddenField2.Text) != 0)
                {
                    hasdistance = true;
                }
                string      codeINSEE = cell.codeVille;
                Emplacement ville;

                List <Arrondissement> listeArrond = null;

                bool hasArrondissement = true;
                listeArrond = construireListeArrond(cell.codeVille);

                foreach (Arrondissement arr in listeArrond)
                {
                    if (arr.CP == cell.CP)
                    {
                        listeArrond.Remove(arr);
                        break;
                    }
                }

                foreach (Arrondissement arr in listeArrond)
                {
                    listeArrondissementNoire.Add(arr);
                }
                listeArrond = construireListeArrond(cell.codeVille);

                string[] nomSplit = cell.nom.Split(' ');
                string   nom      = "";
                for (int i = 0; i < nomSplit.Length - 1; i++)
                {
                    nom += nomSplit[i];
                }

                List <Ville> listeINSEE           = PATRIMO.Outils.OutilsDistance.villeINSEEListeDistance(cell.codeVille, Convert.ToInt32(HiddenField2.Text));
                ListeEmplacementRecherche listeER = convertListeVilleToListeEmplacement(listeINSEE);
                ville = new Emplacement(false, nom, hasdistance, hasArrondissement, cell.codeVille, listeER, cell.CP, Convert.ToInt32(HiddenField2.Text), listeArrond);


                emplacementAffiche.Add(ville);
            }

            rechargerListeERDansEmplacement(cell.codeVille);
        }

        rafraichirEmplacementAffiche();
        toutVirer = true;
    }
    //liste deroulante
    protected void UpdatePanel1_Load(object sender, EventArgs e)
    {
        if (Session["TableAideRechercheVisible"] != null)
        {
            TableAideRecherche.Visible = (bool)Session["TableAideRechercheVisible"];
        }

        int numLigne = 0;

        if (Session["drcAideDep"] != null || drcAideDep != null)
        {
            if (drcAideDep == null)
            {
                drcAideDep = (DataRowCollection)Session["drcAideDep"];
            }
            foreach (DataRow dr in drcAideDep)
            {
                ClickableTableCell cell = (ClickableTableCell)TableAideRecherche.Rows[numLigne].Cells[0];


                cell.type      = "dep";
                cell.nom       = dr["departement_nom"].ToString();
                cell.codeVille = dr["departement_code"].ToString();
                cell.Text      = dr["departement_nom"] + " (" + dr["departement_code"] + ")";
                cell.Click    += new EventHandler(remplirListeEmplacement);
                cell.Attributes.Add("runat", "server");
                cell.CssClass = "cell_liste_lieu bold";
                numLigne++;
            }
        }
        if (Session["drcAidePays"] != null || drcAidePays != null)
        {
            if (drcAidePays == null)
            {
                drcAidePays = (DataRowCollection)Session["drcAidePays"];
            }
            foreach (DataRow dr in drcAidePays)
            {
                ClickableTableCell cell = (ClickableTableCell)TableAideRecherche.Rows[numLigne].Cells[0];

                cell.type      = "pays";
                cell.nom       = dr["Titre_Pays"].ToString().ToUpper();
                cell.codeVille = dr[0].ToString();
                cell.Text      = cell.nom.ToUpper();
                cell.Click    += new EventHandler(remplirListeEmplacement);
                cell.Attributes.Add("runat", "server");
                cell.CssClass = "cell_liste_lieu bold";
                numLigne++;
            }
        }
        if (Session["drcAideVilles"] != null || drcAideVilles != null)
        {
            if (drcAideVilles == null)
            {
                drcAideVilles = (DataRowCollection)Session["drcAideVilles"];
            }
            foreach (DataRow dr in drcAideVilles)
            {
                ClickableTableCell cell = (ClickableTableCell)TableAideRecherche.Rows[numLigne].Cells[0];
                cell.nom       = dr["Nom"].ToString();
                cell.CP        = dr["Code Postal"].ToString();
                cell.type      = "ville";
                cell.codeVille = dr["Code INSEE"].ToString();
                cell.Text      = (dr["Code Postal"].ToString().Length > 5)
                    ? (dr["Nom"] + " (Tous codes postaux)")
                    : (dr["Nom"] + " (" + dr["Code Postal"] + ")");
                cell.Click += new EventHandler(remplirListeEmplacement);
                cell.Attributes.Add("runat", "server");
                cell.CssClass = "cell_liste_lieu";
                numLigne++;
            }
        }
        if (Session["drcArrondissements"] != null || drcArrondissements != null)
        {
            if (drcArrondissements == null)
            {
                drcArrondissements = (DataRowCollection)Session["drcArrondissements"];
            }
            foreach (DataRow dr in drcArrondissements)
            {
                ClickableTableCell cell = (ClickableTableCell)TableAideRecherche.Rows[numLigne].Cells[0];

                cell.nom       = dr["Nom"].ToString();
                cell.CP        = dr["Code Postal"].ToString();
                cell.type      = "arrondissement";
                cell.codeVille = dr["VilleINSEE"].ToString();
                cell.Text      = dr["Nom"] + " (" + dr["Code Postal"] + ")";
                cell.Click    += new EventHandler(remplirListeEmplacement);
                cell.Attributes.Add("runat", "server");
                cell.CssClass = "cell_liste_lieu";
                numLigne++;
            }
        }
        if (numLigne < 5)
        {
            hauteur_liste = 22 + numLigne * 30;
        }
        rafraichirEmplacementAffiche();
    }
    protected void Update_modifierAcquereur(object sender, EventArgs e)
    {
        //id acquereur
        string idAcq   = (string)Session["ajout_acquereur_id"];
        string requete = "SELECT cible FROM Acquereurs WHERE `id_acq`=" + idAcq + "";

        System.Data.DataSet ds = null;
        Connexion           c  = null;

        c = new Connexion(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        c.Open();
        ds = c.exeRequette(requete);
        c.Close();
        c = null;
        System.Data.DataRowCollection dr = ds.Tables[0].Rows;

        Regex regexPays  = new Regex("%type:pays%");
        Regex regexVille = new Regex("%type:vil%");
        Regex regexDep   = new Regex("%type:dep%");
        Regex regexArr   = new Regex("%arr:");

        String cibles = "";

        foreach (System.Data.DataRow ligne in dr)
        {
            cibles = ligne["cible"].ToString();
        }
        string[]           cible = cibles.Split('|');
        int                k;
        ClickableTableCell cell = new ClickableTableCell();

        for (int i = 0; i < cible.Length - 1; i++)                          // i = boucle des villes ou département d'un acquereur
        {
            string currentCible = cible[i];
            cible[i].Trim();
            cible[i] = cible[i].Replace("type:pays", "");
            cible[i] = cible[i].Replace("type:dep", "");
            cible[i] = cible[i].Replace("type:vil", "");

            string[] temp      = cible[i].Split('%');
            string[] cibleInfo = new string[4];
            k = 0;
            for (int j = 0; j < temp.Length; j++)                          // j = boucle des données de la ville i de l'acquereur
            {
                if (temp[j] != "")
                {
                    cibleInfo[k] = temp[j];
                    k++;
                }
            }
            string cibleCode = cibleInfo[0].Split(':')[1];                         // code de la ville ou du département i de l'acquereur
            string cibleNom  = cibleInfo[1].Split(':')[1];                         // nom de la ville ou du département i de l'acquereur
            string cibleCP   = "";
            if (cibleInfo[2] != null)
            {
                cibleCP = cibleInfo[2].Split(':')[1];                                                             // CP de la ville ou du département i de l'acquereur
            }
            string cibleArr = "";
            if (cibleInfo[3] != null)
            {
                cibleArr = cibleInfo[3].Split(':')[1];                              // Arrondissement de la ville i de l'acquereur
            }
            if (regexPays.IsMatch(currentCible))
            {
                List <Arrondissement>     listeArrondissement = null;
                ListeEmplacementRecherche listeVille          = new ListeEmplacementRecherche();
                Emplacement toto = new Emplacement(false, cibleNom, false, false, cibleCode, listeVille, cibleCP, 0, listeArrondissement);
                toto.IsPays = true;
                emplacementAffiche.Add(toto);
            }
            if (regexVille.IsMatch(currentCible) && !regexArr.IsMatch(currentCible))
            {
                List <Arrondissement>     listeArrondissement = null;
                ListeEmplacementRecherche listeVille          = new ListeEmplacementRecherche();
                Emplacement toto = new Emplacement(false, cibleNom, false, false, cibleCode, listeVille, cibleCP, 0, listeArrondissement);
                emplacementAffiche.Add(toto);
            }
            else if (regexDep.IsMatch(currentCible))
            {
                List <Arrondissement>     listeArrondissement = null;
                ListeEmplacementRecherche listeVille          = new ListeEmplacementRecherche();
                Emplacement toto = new Emplacement(true, cibleNom, false, false, cibleCode, listeVille, cibleCP, 0, listeArrondissement);
                emplacementAffiche.Add(toto);
            }
            else if (regexArr.IsMatch(currentCible))
            {
                List <Arrondissement> listeArrondissement = new List <Arrondissement>();
                listeArrondissement = construireListeArrond(cibleCode);
                ListeEmplacementRecherche listeVille = new ListeEmplacementRecherche();
                Emplacement toto = new Emplacement(false, cibleNom, false, true, cibleCode, listeVille, cibleCP, 0, listeArrondissement);
                toto.HasArrondissement = true;
                emplacementAffiche.Add(toto);
            }
        }
        rafraichirEmplacementAffiche();
    }
Beispiel #5
0
    protected void UpdatePanel1_Load(object sender, EventArgs e)
    {
        if (Session["TableAideRechercheVisible"] != null)
        {
            TableAideRecherche.Visible = (bool)Session["TableAideRechercheVisible"];
        }
        int numLigne = 0;

        if (Session["drcAideDep"] != null || drcAideDep != null)
        {
            if (drcAideDep == null)
            {
                drcAideDep = (DataRowCollection)Session["drcAideDep"];
            }
            foreach (DataRow dr in drcAideDep)
            {
                ClickableTableCell cell = (ClickableTableCell)TableAideRecherche.Rows[numLigne].Cells[0];


                cell.type      = "dep";
                cell.nom       = dr["departement_nom"].ToString();
                cell.codeVille = dr["departement_code"].ToString();
                cell.Text      = "Département: " + dr["departement_nom"] + " (" + dr["departement_code"] + ")";
                cell.Click    += new EventHandler(remplirListeEmplacement);
                cell.Attributes.Add("runat", "server");
                numLigne++;
            }
        }
        if (Session["drcAideVilles"] != null || drcAideVilles != null)
        {
            if (drcAideVilles == null)
            {
                drcAideVilles = (DataRowCollection)Session["drcAideVilles"];
            }
            foreach (DataRow dr in drcAideVilles)
            {
                ClickableTableCell cell = (ClickableTableCell)TableAideRecherche.Rows[numLigne].Cells[0];

                //TODO : Charles

                /*cell.nom = dr["Titre_Pays"].ToString();
                 * cell.CP = "0";
                 * cell.type = "ville";
                 * cell.codeVille = dr[0].ToString();
                 * cell.Text = dr[1].ToString();*/

                cell.nom       = dr["Nom"].ToString();
                cell.CP        = dr["Code Postal"].ToString();
                cell.type      = "ville";
                cell.codeVille = dr["Code INSEE"].ToString();
                cell.Text      = dr["Nom"] + " (" + dr["Code Postal"] + ")";
                cell.Click    += new EventHandler(remplirListeEmplacement);
                cell.Attributes.Add("runat", "server");
                numLigne++;
            }
        }
        if (Session["drcArrondissements"] != null || drcArrondissements != null)
        {
            if (drcArrondissements == null)
            {
                drcArrondissements = (DataRowCollection)Session["drcArrondissements"];
            }
            foreach (DataRow dr in drcArrondissements)
            {
                ClickableTableCell cell = (ClickableTableCell)TableAideRecherche.Rows[numLigne].Cells[0];

                cell.nom       = dr["Nom"].ToString();
                cell.CP        = dr["Code Postal"].ToString();
                cell.type      = "arrondissement";
                cell.codeVille = dr["VilleINSEE"].ToString();
                cell.Text      = dr["Nom"] + " (" + dr["Code Postal"] + ")";
                cell.Click    += new EventHandler(remplirListeEmplacement);
                cell.Attributes.Add("runat", "server");
                numLigne++;
            }
        }
        rafraichirEmplacementAffiche();
    }