Ejemplo n.º 1
0
        private void bt_valid_Click(object sender, EventArgs e)
        {
            string  mtt  = mttpaye.Text.Trim();
            decimal dmtt = 0;

            decimal.TryParse(mtt, out dmtt);
            string postbanq = "1";

            if (ck_banque.Checked)
            {
                postbanq = "2";
            }
            if (dmtt <= 0)
            {
                uf.message_info("Veuillez saisir le montant payé !");
                return;
            }
            int    numfolio      = int.Parse(Fmain.Maxsuivant(Fmain.nombasecompta + ".cpta_mouvement", "numfolio", "year(datemouvement) = " + DateTime.Now.Year.ToString()));
            string idcomptedebit = uf.ValeurParCond(comrech, Fmain.nombasecompta + ".cpta_compte", "idcompte, codecompte", "idcompte", "codecompte = " + Fmain.comptedebit);
            string idcompteb     = uf.ValeurParCond(comrech, Fmain.nombasecompta + ".cpta_compte", "idcompte, codecompte", "idcompte", "codecompte = " + Fmain.compteb);

            string typetrans = "0";     //tft banque

            if (typetransfert.SelectedIndex == 1)
            {
                typetrans = "1";
            }
            string textedeb = coordpayeur.Text.Trim();
            string datyp    = uf.getDateSQL(datepaiement.Value);
            //Comptabilisation
            string newid = uf.executeSQL(comrealvistamod, Fmain.nombasecompta + ".cpta_mouvement", "numfolio,datesaisie,datemouvement,typeecriture,idcompte,codecompte,idcomptec,codecomptec,libelledetail,entree,sortie",
                                         numfolio.ToString() + "$" + string.Format("{0:yyyy-MM-dd}", DateTime.Now) + "$" + string.Format("{0:yyyy-MM-dd}", DateTime.Now) + "$" + "1" + "$" + idcompteb + "$" + Fmain.compteb + "$" + idcomptedebit + "$" + Fmain.comptedebit + "$" + "Paiement " + numfact + "-" + textedeb + "-" + comptepayeur.Text.Trim() + "$" + dmtt.ToString() + "$" + "0", 2, "");

            string champ  = "typepaiement, postebanque, datesaisie, datepaiement, identreprise, idclient, numfacture, montant, refpaiement, coordpayeur, comptepaiement, typetransfert, idmouvementpaye";
            string valeur = typepaiement.SelectedIndex.ToString() + "$" + postbanq + "$" + uf.getDateSQL(datesaisie.Value) + "$" + uf.getDateSQL(datepaiement.Value) + "$" +
                            Fmain.identreprisesel + "$" + int.Parse(numfact.Substring(4, 2)).ToString() + "$" + numfact + "$" + dmtt.ToString() + "$" + refpaiement.Text.Trim() + "$" + textedeb + "$" + comptepayeur.Text.Trim() + "$" + typetrans + "$" + newid;

            if (typemod == 2) //modif
            {
                uf.executeSQL(comrealvistamod, "fact_paiement", champ, valeur, 1, "idpaiement = " + gv_listepaiement.CurrentRow.Cells["g_idpaiement"].FormattedValue.ToString());
                chargerpaiement();
            }
            else
            {
                uf.executeSQL(comrealvistamod, "fact_paiement", champ, valeur, 2, "");
                //Si solde = 0
                uf.executeSQL(comrealvistamod, "fact_facturation", "rappel", "0", 2, "reffacturedeltareal='" + numfact + "'");

                DialogResult = DialogResult.OK;
            }
        }
Ejemplo n.º 2
0
        private void f_marchandises_Load(object sender, EventArgs e)
        {
            uf.initialisation(p_affiche);
            //remplir les combos
            //uf.RemplirCombo(client, "SELECT if (entreprise.iddeltareal > 0, concat(clidelta.socligne1, ' ', clidelta.socligne2), concat(entreprise.socligne1, ' ', entreprise.socligne2)) as entreprise, entreprise.identreprise FROM fact_entreprise entreprise left join " + Fmain.baseInit + ".client clidelta ON clidelta.idclient = entreprise.iddeltareal ORDER BY entreprise.identreprise ", comrealvista, mySqlDataAdapter1);
            lb_entreprise.Text = uf.ValeurParCond(comrealvista, "fact_entreprise entreprise left join " + Fmain.baseInit + ".client clidelta ON clidelta.idclient = entreprise.iddeltareal", "if (entreprise.iddeltareal > 0, concat(clidelta.socligne1, ' ', clidelta.socligne2), concat(entreprise.socligne1, ' ', entreprise.socligne2)) as entreprise", "entreprise", "identreprise = " + Fmain.identreprisesel);
            uf.RemplirCombo(unite, "SELECT unitecode, unitelibelle, idunite FROM fact_unite ORDER BY unitecode", comrealvista, mySqlDataAdapter1);
            reqdon = "select idarticle, codearticle, descriptif_ligne1, descriptif_ligne2, descriptif_ligne3, descriptif_ligne4, descriptif_ligne5, " +
                     "remarque, concat(unitecode, ' ', unitelibelle) as unite, fact_unite.idunite as idunite FROM fact_articles " +
                     //"LEFT JOIN fact_entreprise entreprise ON entreprise.identreprise = fact_articles.identreprise AND entreprise.identreprise =" + Fmain.identreprisesel + " " +
                     //"left join " + Fmain.baseInit + ".client clidelta ON clidelta.idclient = entreprise.iddeltareal " +
                     "LEFT JOIN fact_unite ON fact_unite.idunite = fact_articles.idunite WHERE fact_articles.identreprise =" + Fmain.identreprisesel + " ORDER BY codearticle";
            //uf.afficherInfo(this, reqdon, comrealvista, gv_article, "");

            //if (gv_article.RowCount > 0)
            //    uf.afficherInfo(this, reqdon.Replace("ORDER", "WHERE idarticle =" + gv_article.Rows[0].Cells["g_idarticle"].Value.ToString() + " ORDER"), comrealvista, null, "");
            affichedonnees();
            //uf.enablecontrol(p_affiche, "2", false);
            //uf.enablemulticontrol(p_button, "1", "2,3");
        }
Ejemplo n.º 3
0
        private int numclisuivant()
        {
            int numsuiv = 0;

            string listeexistant = uf.ValeurParCond(comrealvistamod, "fact_client", "group_concat(idclient) as listecli", "listecli", "idclient > 0 order by idclient", "SET SESSION group_concat_max_len = 10000000;");

            if (listeexistant != "")
            {
                string   liste = "";
                string[] se    = listeexistant.Split(',');
                int      maxi  = int.Parse(se[se.Length - 1]);
                string[] sorig = new string[maxi];
                for (int i = 0; i < maxi; i++)
                {
                    sorig[i] = (i + 1).ToString();
                }

                for (int i = 0; i < sorig.Length; i++)
                {
                    if (se[i] == sorig[i])
                    {
                        continue;
                    }
                    else
                    {
                        numsuiv = int.Parse(sorig[i]);
                        return(numsuiv);
                    }
                }

                return(maxi + 1);
            }
            else
            {
                numsuiv = 0;
            }
            return(numsuiv + 1);
        }
Ejemplo n.º 4
0
 private void annule()
 {
     if (curligne > -1)
     {
         g_client.Rows[curligne].Selected = true;
         g_client.CurrentCell             = g_client.Rows[curligne].Cells[1];
     }
     if (g_client.RowCount > 0 && g_client.CurrentRow.Index > -1)
     {
         uf.afficherInfo(p_client, reqdon.Replace("ORDER", "WHERE client.identreprise =" + g_client.CurrentRow.Cells["g_refentreprise"].Value.ToString() + " ORDER"), comrealvista, null, "");
         pub.Text         = uf.ValeurParCond(comrealvistamod, "fact_entreprise", "pub", "pub", "identreprise =" + Fmain.identreprisesel);
         texterappel.Text = uf.ValeurParCond(comrealvistamod, "fact_entreprise", "texterappel", "texterappel", "identreprise =" + Fmain.identreprisesel);
         chargertypeadr(false, g_client.CurrentRow.Cells["g_refentreprise"].Value.ToString(), "");
         afficheadresse(g_client.CurrentRow.Cells["g_refentreprise"].Value.ToString(), "");
         affichefrais(g_client.CurrentRow.Cells["g_refentreprise"].Value.ToString());
         affichecommentaire(g_client.CurrentRow.Cells["g_refentreprise"].Value.ToString());
     }
     else
     {
         uf.initcontrol(p_client, "", socligne1);
     }
     uf.enablemulticontrol(p_button, "1", "2");
     uf.enablecontrol(p_client, "2", false);
     uf.enablecontrol(p_client, "3", false);
     uf.enablecontrol(p_client, "8", false);
     uf.enablecontrol(p_client, "12", false);
     pub.Enabled         = false;
     texterappel.Enabled = false;
     if (g_client.RowCount == 0)
     {
         bt_modif.Enabled = bt_suppr.Enabled = false;
     }
     etat      = 0;
     etatadr   = 0;
     etatfrais = 0;
 }
Ejemplo n.º 5
0
        public string generernumfacture(string ident)
        {
            int numsuiv = 0;

            string listeexistant = Util.ValeurParCond(DeltaSQLTmp, "fact_facturation", "group_concat(distinct right(reffacturedeltareal, 4) order by reffacturedeltareal asc) as listefact", "listefact", "identreprise =" + identreprisesel + " AND year(datefacturedeltareal) = " + DateTime.Now.Year.ToString() + " order by reffacturedeltareal", "SET SESSION group_concat_max_len = 10000000;");

            if (listeexistant != "")
            {
                string   liste = "";
                string[] se    = listeexistant.Split(',');
                int      maxi  = int.Parse(se[se.Length - 1]);
                string[] sorig = new string[maxi];
                for (int i = 0; i < maxi; i++)
                {
                    sorig[i] = (i + 1).ToString();
                }

                for (int i = 0; i < sorig.Length; i++)
                {
                    if (int.Parse(se[i]).ToString() == sorig[i])
                    {
                        continue;
                    }
                    else
                    {
                        numsuiv = int.Parse(sorig[i]);
                        return(DateTime.Now.Year.ToString() + identreprisesel.PadLeft(2, '0') + numsuiv.ToString().PadLeft(4, '0'));
                        //return numsuiv;
                    }
                }
                return(DateTime.Now.Year.ToString() + identreprisesel.PadLeft(2, '0') + (maxi + 1).ToString().PadLeft(4, '0'));

                //return maxi + 1;
            }
            else
            {
                numsuiv = 0;
            }
            return(DateTime.Now.Year.ToString() + identreprisesel.PadLeft(2, '0') + (numsuiv + 1).ToString().PadLeft(4, '0'));

            //return numsuiv + 1;
        }
Ejemplo n.º 6
0
        public int stypefat = 0; //0 si facture, 1 si rappel
        private void rep()
        {
            /*
             *
             * SELECT '' as fact_daterappel, 0 as fact_rappel, 0 as ent_echeancerappel, 0 as idfacture, ' ' as numbvrcomplet, '' as numbvrspace, '' as fact_nofacture, '' as fact_reffactureentreprise, '' as fact_datefacture, '' as fact_dateecheance, '' as fact_datecommande, '' as fact_datefacturedeltareal, '' as fact_datepaiement, 0.00 as fact_totalmontantbrut, '' as fact_tvapourcent, 0.00 as fact_totalrabais, 0.00 as fact_totaltvachf, 0.00 as fact_fraisenvoi, 0.00 as fact_fraisassurance, 0.00 as fact_interets, 0.00 as fact_fraisrappel, 0.00 as fact_montantapayer, 0.00 as fact_montantpaye, 0 as art_numligne, '' as art_codearticle, '' as art_libellearticle, '' as art_remarque, '' as art_unite, 0.00 as art_prixunitaire, 0 as art_nbrarticle, 0.00 as art_montantbrut, '' as art_rabaispourcent, 0.00 as art_rabaischf, 0 as identreprise, 0 as iddeltareal, '' as letter, '' as ent_societe, '' as ent_societecompl, '' as ent_politesse, '' as ent_nomprenom, '' as ent_adresse1, '' as ent_adresse2, '' as ent_co, '' as ent_npa, '' as ent_ville, '' as ent_iban, '' as ent_banqueccp, '' as ent_notva, 0 as ent_echeancejour, '' as ent_email, '' as ent_siteweb, '' as ent_nobvr, '' as ent_noccp, '' as ent_noremiseadherent, 0 as iCli, '' as cli_adressecomplet, '' as cli_societe, '' as cli_politesse, '' as cli_nom, '' as cli_prenom, '' as cli_co, '' as cli_adresse1, '' as cli_adresse2, '' as cli_npa, '' as cli_ville, '' as modemens, 0 as nbrmens FROM fact_facturation
             * PREPARE stmt FROM @tri;
             * EXECUTE stmt;
             *
             * PREPARE stmt FROM @tri;
             * SET lc_time_names = 'fr_FR';
             * EXECUTE stmt;
             */
            /*SELECT ' ' as numbvrcomplet, '' as numbvrspace, '' as fact_nofacture, '' as fact_reffactureentreprise, now() as fact_datefacture, now() as fact_dateecheance, now() as fact_datecommande, now() as fact_datefacturedeltareal, now() as fact_datepaiement, 0.00 as fact_totalmontantbrut, 0.00 as fact_tvapourcent, 0.00 as fact_totalrabais, 0.00 as fact_totaltvachf, 0.00 as fact_fraisenvoi, 0.00 as fact_fraisassurance, 0.00 as fact_interets, 0.00 as fact_fraisrappel, 0.00 as fact_montantapayer, 0.00 as fact_montantpaye, 0 as art_numligne, '' as art_codearticle, '' as art_libellearticle, '' as art_remarque, '' as art_unite, 0.00 as art_prixunitaire, 0 as art_nbrarticle, 0.00 as art_montantbrut, 0.00 as art_rabaispourcent, 0.00 as art_rabaischf, 0 as identreprise, 0 as iddeltareal, '' as letter, '' as ent_societe, '' as ent_societecompl, '' as ent_politesse, '' as ent_nomprenom, '' as ent_adresse1, '' as ent_adresse2, '' as ent_co, '' as ent_npa, '' as ent_ville, '' as ent_iban, '' as ent_banqueccp, '' as ent_notva, 0 as ent_echeancejour, '' as ent_email, '' as ent_siteweb, 0 as iCli, '' as cli_adressecomplet, '' as cli_societe, '' as cli_politesse, '' as cli_nom, '' as cli_prenom, '' as cli_co, '' as cli_adresse1, '' as cli_adresse2, '' as cli_npa, '' as cli_ville, '' as modemens, 0 as nbrmens FROM fact_facturation*/
            this.reportViewer1.RefreshReport();
            string tri = "";

            Microsoft.Reporting.WinForms.ReportDataSource dd = null;
            reportViewer1.LocalReport.ReportPath = Application.StartupPath + "\\Fact_modele\\Fact_modele1.rdlc";
            dd = new Microsoft.Reporting.WinForms.ReportDataSource("FactDataSet");
            //tri = "select 'modele_facture_1' as document, fbvr.numbvrcomplet, concat_ws(' ', mid(numbvrcomplet, 0, 2), mid(numbvrcomplet, 2, 5), mid(numbvrcomplet, 7, 5), mid(numbvrcomplet, 12, 5), mid(numbvrcomplet, 17, 5), mid(numbvrcomplet, 22)) as numbvrspace, fact.reffacturedeltareal as fact_nofacture, fact.reffactureentreprise as fact_reffactureentreprise,  date_format(fact.dateimpression, '%d.%m.%Y') as fact_datefacture, date_format(DATE_ADD(fact.dateimpression, INTERVAL entreprise.echeance day), '%d.%m.%Y') as fact_dateecheance, date_format(fact.datecommande, '%d.%m.%Y') as fact_datecommande, date_format(fact.datefacturedeltareal, '%d.%m.%Y') as fact_datefacturedeltareal, '' as fact_datepaiement, fact.totmontantbrut as fact_totalmontantbrut, concat(fact.tauxtva, '%') as fact_tvapourcent, fact.totrabais as fact_totalrabais, fact.tottva as fact_totaltvachf, fact.fraisenvoi as fact_fraisenvoi, fact.fraisassurance as fact_fraisassurance, fact.interets as fact_interets, fact.fraisrappel as fact_fraisrappel, (fact.totmontantbrut - fact.totrabais + fact.tottva) as fact_montantapayer, 0 as fact_montantpaye, " +
            tri = "Select 'modele_facture_1' as document, fbvr.numbvrcomplet, concat_ws(' ', mid(numbvrcomplet, 1, 2), mid(numbvrcomplet, 3, 5), mid(numbvrcomplet, 8, 5), mid(numbvrcomplet, 13, 5), mid(numbvrcomplet, 18, 5), mid(numbvrcomplet, 23)) as numbvrspace, fact.reffacturedeltareal as fact_nofacture, fact.reffactureentreprise as fact_reffactureentreprise, ";

            if (brappel)
            {
                if (brappelimp)
                {
                    tri += "date_format(DATE_ADD(fact.dateecheance, INTERVAL -entreprise.echeancerappel DAY), '%d %M %Y')";
                }
                else
                {
                    tri += "date_format(date(now()), '%d %M %Y')";
                }
            }
            else
            {
                tri += "date_format(if(isnull(dateimpression), date(now()), dateimpression), '%d %M %Y')";
            }
            //tri += "date_format(if(isnull(dateimpression), date(now()), dateimpression), '%d %M %Y')

            tri += " as fact_datefacture, rappel as fact_rappel, date_format(if(isnull(daterappel), date(now()), daterappel), '%d %M %Y') as fact_daterappel,  date_format(DATE_ADD(date(now()), INTERVAL entreprise.echeance day), '%d.%m.%Y') as fact_dateecheance, date_format(fact.datecommande, '%d.%m.%Y') as fact_datecommande, date_format(now(),'%d %M %Y') as fact_datefacturedeltareal, date_format(paiement.datepaiement,'%d.%m.%Y') as fact_datepaiement, 0 as fact_totalmontantbrut, fact.tauxtva as fact_tvapourcent, 0 as fact_totalrabais, 0 as fact_totaltvachf, fact.fraisenvoi as fact_fraisenvoi, fact.fraisassurance as fact_fraisassurance, fact.interets as fact_interets, fact.fraisrappel as fact_fraisrappel, fact.montantapayer as fact_montantapayer, paiement.montantpaye as fact_montantpaye, " +

                   "fact.numligne as art_numligne, article.codearticle as art_codearticle, concat_ws('\n', if (trim(article.descriptif_ligne1) = '', null, article.descriptif_ligne1), if (trim(article.descriptif_ligne2) = '', null, article.descriptif_ligne2), if (trim(article.descriptif_ligne3) = '', null, article.descriptif_ligne3), if (trim(article.descriptif_ligne4) = '', null, article.descriptif_ligne4), if (trim(fact.remarquearticle) = '', null, fact.remarquearticle)) as art_libellearticle, fact.remarquearticle as art_remarque, unite.unitecode as art_unite, prix.prix as art_prixunitaire, fact.nbr as art_nbrarticle, (prix.prix * fact.nbr) as art_montantbrut, if (rabais.rabaispourcent > 0, concat(rabais.rabaispourcent, '%'), '-') as art_rabaispourcent, if (if (isnull(rabais.rabaispourcent), 0, rabais.rabaispourcent) > 0, (fact.nbr * prix.prix) * rabais.rabaispourcent / 100, if (isnull(rabais.rabaismontant), 0, rabais.rabaismontant)) as art_rabaischf,  " +

                   "entreprise.identreprise, entreprise.iddeltareal, langent.letter, if (entreprise.iddeltareal > 0, clidel.socligne1, entreprise.socligne1) as ent_societe, if (entreprise.iddeltareal > 0, clidel.socligne2, entreprise.socligne2) as ent_societecompl, polent.politesselettre as ent_politesse, if (entreprise.iddeltareal > 0, foncdel.nomprenom, fonccli.nomprenom) as ent_nomprenom,   " +
                   "if (entreprise.iddeltareal > 0, foncdel.adresse1, fonccli.adresse1) as ent_adresse1, if (entreprise.iddeltareal > 0, foncdel.adresse2, fonccli.adresse2) as ent_adresse2,  " +
                   "if (entreprise.iddeltareal > 0, foncdel.co, fonccli.co) as ent_co, clicity.zip as ent_npa, clicity.cityname as ent_ville, if (entreprise.iddeltareal > 0, foncdel.comptebanque, fonccli.comptebanque) as ent_iban, if (entreprise.iddeltareal > 0, foncdel.ccp, fonccli.noccp) as ent_noccp, if (entreprise.iddeltareal > 0, '', fonccli.nobvr) as ent_nobvr, if (entreprise.iddeltareal > 0, '', fonccli.noremiseadherent) as ent_noremiseadherent, concat(banque.nombanque, ' - ', banque.adresse, ', ', banque.npa, ' ', banque.ville) as ent_banqueccp,  " +
                   "if (entreprise.iddeltareal > 0, clidel.numrc, entreprise.numtva) as ent_notva, ";

            /*if (brappel)
             *  tri += "concat(LPAD(entreprise.echeancerappel, 3, '0'), 'A', fact.rappel) ";
             * else
             *  tri += "entreprise.echeance ";
             */
            tri += "entreprise.echeance as ent_echeancejour, entreprise.echeancerappel as ent_echeancerappel,  if (entreprise.iddeltareal > 0, foncdel.email, fonccli.email) as ent_email, if (entreprise.iddeltareal > 0, foncdel.adresseweb, fonccli.siteweb) as ent_siteweb,  " +

                   "client.idclient as iCli, concat_ws('\n', if (trim(socligne) = '', null, socligne), if(trim(clientpolitesse.politesseadr)='',null,clientpolitesse.politesseadr), if(trim(concat(client.prenom, ' ', client.nom)) = '', null, trim(concat(client.prenom, ' ', client.nom))), if (trim(client.co) = '', null, client.co), if (trim(client.adresse1) = '', null, client.adresse1), if (trim(client.adresse2) = '', null, client.adresse2), concat(city.zip, ' ', city.cityname)) as cli_adressecomplet,  " +
                   "client.socligne as cli_societe, clientpolitesse.politesselettre as cli_politesse, client.nom as cli_nom, client.prenom as cli_prenom, client.co as cli_co, client.adresse1 as cli_adresse1, client.adresse2 as cli_adresse2, city.zip as cli_npa, city.cityname as cli_ville,  " +

                   "if (fact.nbrmens > 0, 'oui', 'non') as modemens, fact.nbrmens, article.idarticle, article.codearticle, concat_ws('\n', article.descriptif_ligne1, if (article.remarque = '', null, article.remarque)) as libellearticle, client.idclient, fact.identreprise, fact.idfacture, prix.idprix, rabais.idrabais " +

                   "fROM " +
                   "fact_facturation fact inner join (select idfacture, concat('000000', LPAD(identreprise, 4, '0'), LPAD(reffacturedeltareal, 10, '0'), date_format(if(isnull(dateimpression), now(), dateimpression), '%y%m%d'), ccpmodulo(concat('000000', LPAD(identreprise, 4, '0'), LPAD(reffacturedeltareal, 10, '0'), date_format(if(isnull(dateimpression), now(), dateimpression), '%y%m%d')))) as numbvrcomplet FROM fact_facturation) fbvr ON fbvr.idfacture = fact.idfacture " +

                   "INNER join fact_entreprise entreprise on entreprise.identreprise = fact.identreprise " +
                   "LEFT JOIN (select identreprise, numfacture, datepaiement, sum(montant) as montantpaye FROM fact_paiement GROUP BY identreprise, numfacture order by datepaiement desc) paiement ON paiement.identreprise = fact.identreprise AND fact.reffacturedeltareal = paiement.numfacture " +

                   "left join " + Fmain.baseInit + ".client clidel on clidel.idclient = entreprise.iddeltareal " +
                   "LEFT JOIN fact_entreprisefonction fonccli ON fonccli.identreprise = entreprise.identreprise AND(fonccli.idfonction = 10) " +
                   "LEFT JOIN " + Fmain.baseInit + ".clientfonction foncdel ON foncdel.idclient = entreprise.iddeltareal AND(foncdel.idfonctiondelta = 10) " +
                   "LEFT join " + Fmain.baseInit + ".typepolitesse polent ON polent.idpolitesse = if (entreprise.iddeltareal > 0, foncdel.idpolitesse, fonccli.idpolitesse)  " +
                   "LEFT join " + Fmain.baseInit + ".language langent ON langent.idlanguage = polent.idlangue " +
                   "left join " + Fmain.baseInit + ".city clicity ON clicity.idcity = if (entreprise.iddeltareal > 0, foncdel.idville, fonccli.idville)  " +
                   "LEFT JOIn " + Fmain.baseInit + ".cpta_banque banque ON banque.idbanque = if (entreprise.iddeltareal > 0, foncdel.idbanque, fonccli.idbanque) " +

                   "LEFT JOIN fact_client client ON client.idclient = fact.idclient left join   " + Fmain.baseInit + ".city ON city.idcity = client.idville left join " + Fmain.baseInit + ".typepolitesse clientpolitesse ON client.idpolitesse = clientpolitesse.idpolitesse " +

                   "LEFT join fact_articles article ON article.idarticle = fact.idarticle left join (select idprix, idarticleprix, prix, dateprix from fact_prix group by idarticleprix, idprix order by dateprix desc) prix on prix.idarticleprix = article.idarticle and prix.idprix = fact.idprix " +
                   "LEFT JOIN(Select idrabais, idarticlerabais, rabaismontant, rabaispourcent, daterabaisde, daterabaisa FROM fact_rabais group by idarticlerabais, idrabais order by daterabaisa desc) rabais ON rabais.idarticlerabais = article.idarticle AND fact.idrabais = rabais.idrabais " +
                   "LEFT JOIN fact_unite unite ON unite.idunite = article.idunite " +
                   "ORDER by fact.reffacturedeltareal, fact.idclient, fact.numligne";

            if (cond != "")
            {
                tri = tri.Replace("ORDER", "WHERE " + cond + " ORDER");
            }

            realvistaDataSetTableAdapters.facturationTableAdapter Facturations = new realvistaDataSetTableAdapters.facturationTableAdapter();
            clientBindingSource.ResetBindings(false);
            Facturations.ClearBeforeFill   = true;
            clientBindingSource.DataMember = "facturation";
            reportViewer1.LocalReport.DataSources.Clear();
            reportViewer1.LocalReport.DataSources.Add(dd);
            reportViewer1.LocalReport.DataSources[0].Value = clientBindingSource;
            //reportViewer1.LocalReport.EnableExternalImages = true;
            string p   = "";
            string rap = "";

            if (brappel)
            {
                p   = uf.ValeurParCond(comrech, "fact_entreprise", "texterappel", "texterappel", "identreprise =" + Fmain.identreprisesel);
                rap = "Rappel : ";
            }
            else
            {
                p   = uf.ValeurParCond(comrech, "fact_entreprise", "pub", "pub", "identreprise =" + Fmain.identreprisesel);
                rap = "";
            }
            reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("publicite", p));
            reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("rappel", rap));
            Facturations.Fill(realvistaDataSet.facturation, tri);
            if (clientBindingSource.Position == -1)
            {
                uf.message_info("Il n'y a pas de données !");
                return;
            }
            reportViewer1.Show();
            reportViewer1.Visible = true;
            reportViewer1.RefreshReport();
            reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
            reportViewer1.ZoomMode    = Microsoft.Reporting.WinForms.ZoomMode.Percent;
            reportViewer1.ZoomPercent = 100;
        }