OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 152 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 152 Rev 170
Line 373... Line 373...
373
 
373
 
374
        elt.addListColumn(new BaseSQLTableModelColumn("Affaire", String.class) {
374
        elt.addListColumn(new BaseSQLTableModelColumn("Affaire", String.class) {
375
 
375
 
376
            @Override
376
            @Override
377
            protected Object show_(SQLRowAccessor r) {
377
            protected Object show_(SQLRowAccessor r) {
378
                Collection<? extends SQLRowAccessor> rows = r.getReferentRows(elt.getTable().getTable("AFFAIRE"));
378
                final SQLRowAccessor foreignAff = r.getForeign("ID_AFFAIRE");
379
                if (rows.size() == 1) {
379
                if (foreignAff != null && !foreignAff.isUndefined()) {
380
                    return rows.iterator().next().getString("NUMERO");
380
                    return foreignAff.getString("NUMERO");
381
                } else {
381
                } else {
-
 
382
                    Collection<? extends SQLRowAccessor> rows = r.getReferentRows(elt.getTable().getTable("AFFAIRE"));
-
 
383
                    if (rows.size() == 1) {
-
 
384
                        return rows.iterator().next().getString("NUMERO");
-
 
385
                    } else {
382
                    return "";
386
                        return "";
-
 
387
                    }
383
                }
388
                }
384
            }
389
            }
385
 
390
 
386
            @Override
391
            @Override
387
            public Set<FieldPath> getPaths() {
392
            public Set<FieldPath> getPaths() {
388
                SQLTable table = elt.getTable();
393
                SQLTable table = elt.getTable();
-
 
394
                Path pDev = new Path(table).add(table.getField("ID_AFFAIRE"));
389
                Path p = new Path(table).add(table.getTable("AFFAIRE"), Direction.REFERENT);
395
                Path pAff = new Path(table).add(table.getTable("AFFAIRE"), Direction.REFERENT);
390
                return CollectionUtils.createSet(new FieldPath(p, "NUMERO"));
396
                return CollectionUtils.createSet(new FieldPath(pDev, "NUMERO"), new FieldPath(pAff, "NUMERO"));
391
            }
397
            }
392
        });
398
        });
393
        new CmdToBrSQLInjector();
399
        new CmdToBrSQLInjector();
394
        new QuoteToOrderSQLInjector();
400
        new QuoteToOrderSQLInjector();
395
        new QuoteToInvoiceSQLInjector();
401
        new QuoteToInvoiceSQLInjector();
Line 497... Line 503...
497
                        SQLRowValues rowValsDevis = row.asRowValues();
503
                        SQLRowValues rowValsDevis = row.asRowValues();
498
                        rowValsDevis.put("ID_AFFAIRE", box.getSelectedId());
504
                        rowValsDevis.put("ID_AFFAIRE", box.getSelectedId());
499
 
505
 
500
                        try {
506
                        try {
501
                            rowValsDevis.commit();
507
                            rowValsDevis.commit();
-
 
508
                            row.fetchValues();
-
 
509
                            if (createCommandeClient) {
-
 
510
                                Configuration.getInstance().getDirectory().getElement(DevisSQLElement.class).transfertCommandeClient(Arrays.asList(row.asRowValues()));
-
 
511
                            }
502
                        } catch (SQLException exn) {
512
                        } catch (SQLException exn) {
503
                            // TODO Bloc catch auto-généré
513
                            ExceptionHandler.handle("Erreur lors de la création de la commande client!", exn);
504
                            exn.printStackTrace();
-
 
505
                        }
514
                        }
506
                    }
515
                    }
507
                });
516
                });
508
                FrameUtil.show(f);
517
                FrameUtil.show(f);
509
                return f;
518
                return f;
Line 671... Line 680...
671
            public void actionPerformed(ActionEvent e) {
680
            public void actionPerformed(ActionEvent e) {
672
                ProjectImportExport importExport = new ProjectImportExport(ctxt.getElement("AFFAIRE").getTable().getDBRoot());
681
                ProjectImportExport importExport = new ProjectImportExport(ctxt.getElement("AFFAIRE").getTable().getDBRoot());
673
                importExport.importProjects();
682
                importExport.importProjects();
674
            }
683
            }
675
        }, MainFrame.HELP_MENU);
684
        }, MainFrame.HELP_MENU);
-
 
685
        if (false) {
-
 
686
            ctxt.addMenuItem(new AbstractAction("Fix ID_AFFAIRE") {
-
 
687
                @Override
-
 
688
                public void actionPerformed(ActionEvent e) {
-
 
689
                    {
-
 
690
                        SQLTable tableCmd = ctxt.getElement("COMMANDE_CLIENT").getTable();
-
 
691
                        SQLSelect selBadCmd = new SQLSelect();
-
 
692
                        selBadCmd.addSelect(tableCmd.getKey());
-
 
693
                        selBadCmd.addSelect(tableCmd.getField("ID_AFFAIRE"));
-
 
694
                        SQLSelectJoin joinTR = selBadCmd.addBackwardJoin("RIGHT", "tr", tableCmd.getTable().getTable("TR_DEVIS").getField("ID_COMMANDE_CLIENT"), null);
-
 
695
                        SQLSelectJoin joinDevis = selBadCmd.addJoin("LEFT", joinTR.getJoinedTable().getField("ID_DEVIS"));
-
 
696
                        SQLSelectJoin joinAff = selBadCmd.addBackwardJoin("LEFT", "aff", tableCmd.getTable().getTable("AFFAIRE").getField("ID_DEVIS"), null);
-
 
697
                        selBadCmd.addSelect(joinAff.getJoinedTable().getKey());
676
 
698
 
677
        ctxt.addMenuItem(new AbstractAction("Fix ID_AFFAIRE") {
-
 
678
            @Override
-
 
679
            public void actionPerformed(ActionEvent e) {
-
 
680
                {
-
 
681
                    SQLTable tableCmd = ctxt.getElement("COMMANDE_CLIENT").getTable();
-
 
682
                    SQLSelect selBadCmd = new SQLSelect();
-
 
683
                    selBadCmd.addSelect(tableCmd.getKey());
-
 
684
                    selBadCmd.addSelect(tableCmd.getField("ID_AFFAIRE"));
699
                        selBadCmd.setWhere(Where.isNull(tableCmd.getField("ID_AFFAIRE")));
685
                    SQLSelectJoin joinTR = selBadCmd.addBackwardJoin("RIGHT", "tr", tableCmd.getTable().getTable("TR_DEVIS").getField("ID_COMMANDE_CLIENT"), null);
-
 
686
                    SQLSelectJoin joinDevis = selBadCmd.addJoin("LEFT", joinTR.getJoinedTable().getField("ID_DEVIS"));
-
 
687
                    SQLSelectJoin joinAff = selBadCmd.addBackwardJoin("LEFT", "aff", tableCmd.getTable().getTable("AFFAIRE").getField("ID_DEVIS"), null);
-
 
688
                    selBadCmd.addSelect(joinAff.getJoinedTable().getKey());
700
                        System.err.println(selBadCmd.asString());
689
 
701
 
690
                    selBadCmd.setWhere(Where.isNull(tableCmd.getField("ID_AFFAIRE")));
-
 
691
                    System.err.println(selBadCmd.asString());
-
 
692
 
-
 
693
                    List<Object[]> result = (List<Object[]>) tableCmd.getDBSystemRoot().getDataSource().executeA(selBadCmd.asString());
702
                        List<Object[]> result = (List<Object[]>) tableCmd.getDBSystemRoot().getDataSource().executeA(selBadCmd.asString());
694
                    try {
703
                        try {
695
                        for (Object[] objects : result) {
704
                            for (Object[] objects : result) {
696
                            if (objects[2] != null && objects[2].toString().trim().length() > 0)
705
                                if (objects[2] != null && objects[2].toString().trim().length() > 0)
697
                                tableCmd.getRow(((Number) objects[0]).intValue()).createEmptyUpdateRow().put("ID_AFFAIRE", ((Number) objects[2]).intValue()).commit();
706
                                    tableCmd.getRow(((Number) objects[0]).intValue()).createEmptyUpdateRow().put("ID_AFFAIRE", ((Number) objects[2]).intValue()).commit();
-
 
707
                            }
-
 
708
                        } catch (SQLException e1) {
-
 
709
                            // TODO Auto-generated catch block
-
 
710
                            e1.printStackTrace();
698
                        }
711
                        }
699
                    } catch (SQLException e1) {
-
 
700
                        // TODO Auto-generated catch block
-
 
701
                        e1.printStackTrace();
-
 
702
                    }
-
 
703
 
712
 
704
                    // List<SQLRow> list = SQLRowListRSH.execute(selBadVF);
713
                        // List<SQLRow> list = SQLRowListRSH.execute(selBadVF);
705
                }
714
                    }
706
                {
715
                    {
707
                    SQLTable tableVF = ctxt.getElement("SAISIE_VENTE_FACTURE").getTable();
716
                        SQLTable tableVF = ctxt.getElement("SAISIE_VENTE_FACTURE").getTable();
708
                    SQLSelect selBadVF = new SQLSelect();
717
                        SQLSelect selBadVF = new SQLSelect();
709
                    selBadVF.addSelect(tableVF.getKey());
718
                        selBadVF.addSelect(tableVF.getKey());
710
                    selBadVF.addSelect(tableVF.getField("ID_AFFAIRE"));
719
                        selBadVF.addSelect(tableVF.getField("ID_AFFAIRE"));
711
                    SQLSelectJoin joinTR = selBadVF.addBackwardJoin("RIGHT", "tr", tableVF.getTable().getTable("TR_COMMANDE_CLIENT").getField("ID_SAISIE_VENTE_FACTURE"), null);
720
                        SQLSelectJoin joinTR = selBadVF.addBackwardJoin("RIGHT", "tr", tableVF.getTable().getTable("TR_COMMANDE_CLIENT").getField("ID_SAISIE_VENTE_FACTURE"), null);
712
                    SQLSelectJoin joinCmd = selBadVF.addJoin("LEFT", joinTR.getJoinedTable().getField("ID_COMMANDE_CLIENT"));
721
                        SQLSelectJoin joinCmd = selBadVF.addJoin("LEFT", joinTR.getJoinedTable().getField("ID_COMMANDE_CLIENT"));
713
                    selBadVF.addSelect(joinCmd.getJoinedTable().getField("ID_AFFAIRE"));
722
                        selBadVF.addSelect(joinCmd.getJoinedTable().getField("ID_AFFAIRE"));
714
 
723
 
715
                    selBadVF.setWhere(Where.isNull(tableVF.getField("ID_AFFAIRE")));
724
                        selBadVF.setWhere(Where.isNull(tableVF.getField("ID_AFFAIRE")));
716
                    System.err.println(selBadVF.asString());
725
                        System.err.println(selBadVF.asString());
717
                    List<Object[]> result = (List<Object[]>) tableVF.getDBSystemRoot().getDataSource().executeA(selBadVF.asString());
726
                        List<Object[]> result = (List<Object[]>) tableVF.getDBSystemRoot().getDataSource().executeA(selBadVF.asString());
718
                    try {
727
                        try {
719
                        for (Object[] objects : result) {
728
                            for (Object[] objects : result) {
720
                            if (objects[2] != null && objects[2].toString().trim().length() > 0)
729
                                if (objects[2] != null && objects[2].toString().trim().length() > 0)
721
                                tableVF.getRow(((Number) objects[0]).intValue()).createEmptyUpdateRow().put("ID_AFFAIRE", ((Number) objects[2]).intValue()).commit();
730
                                    tableVF.getRow(((Number) objects[0]).intValue()).createEmptyUpdateRow().put("ID_AFFAIRE", ((Number) objects[2]).intValue()).commit();
-
 
731
                            }
-
 
732
                        } catch (SQLException e1) {
-
 
733
                            // TODO Auto-generated catch block
-
 
734
                            e1.printStackTrace();
722
                        }
735
                        }
723
                    } catch (SQLException e1) {
-
 
724
                        // TODO Auto-generated catch block
-
 
725
                        e1.printStackTrace();
-
 
726
                    }
736
                    }
727
                }
737
                }
728
            }
-
 
729
        }, MainFrame.CREATE_MENU);
738
            }, MainFrame.CREATE_MENU);
730
 
739
        }
731
        ctxt.addMenuItem(new AbstractAction("Recalcul Total achat facture prorata") {
740
        ctxt.addMenuItem(new AbstractAction("Recalcul Total achat facture prorata") {
732
            @Override
741
            @Override
733
            public void actionPerformed(ActionEvent e) {
742
            public void actionPerformed(ActionEvent e) {
734
 
743
 
735
                {
744
                {