first commit

This commit is contained in:
maher
2026-05-16 17:34:53 +02:00
commit 80817b9be0
1619 changed files with 106327 additions and 0 deletions
@@ -0,0 +1,685 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Controllers.FactureFrs;
import Controllers.CommandeClt.CommandeCltPasserController;
import Controllers.Dialog.MessageControle;
import Controllers.Produit.RechercherProduitController;
import Controllers.Traitement.Adaptateur;
import Controllers.Traitement.MyWindow;
import Controllers.Traitement.ParametreSystem;
import Controllers.Traitement.contro;
import Models.FactureFrs.FactureFrs;
import Models.FactureFrs.FactureFrsDB;
import Models.Fournisseur.Fournisseur;
import Models.Fournisseur.FournisseurDB;
import Models.Produit.ListeProduit;
import Models.Produit.Produit;
import Models.Produit.ProduitDB;
import Models.Stock.StockDB;
import java.io.IOException;
import java.net.URL;
import java.time.LocalDate;
import java.time.LocalDateTime;
import javafx.application.Platform;
import java.util.ArrayList;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.util.Callback;
import org.controlsfx.control.textfield.TextFields;
/**
* FXML Controller class
*
* @author Maher
*/
public class FactureFrsAjouterController implements Initializable {
@FXML public AnchorPane PaneFactureFrsAjouter ;
@FXML public Text TotalTVA ;
@FXML public Text Remise ;
@FXML public Text NetAPayer ;
@FXML public Text Timbre ;
@FXML public Text TotalHTNet ;
@FXML public Button RechercheProduit ;
@FXML public Button ButtonFactureFrsAjouter;
@FXML public TableView<ListeProduit> TableViewListeProduit ;
@FXML public TableColumn<ListeProduit ,String> TabColReference;
@FXML public TableColumn<ListeProduit ,String> TabColDesignaton;
@FXML public TableColumn<ListeProduit ,String> TabColQuantite ;
@FXML public TableColumn<ListeProduit ,String> TabColPrixHT;
@FXML public TableColumn<ListeProduit ,String> TabColTotalHT;
@FXML public TableColumn<ListeProduit ,String> TabColRemise;
@FXML public TableColumn<ListeProduit ,String> TabColTVA;
@FXML public TableColumn<ListeProduit ,String> TabColTotalTTC;
@FXML public TableColumn<ListeProduit ,Boolean> TabColAddAction ;
@FXML public TextField TextFieldNumero ;
@FXML public TextField TextFieldTransporteur ;
@FXML public TextField TextFieldHeur ;
@FXML private TextField TextFieldFournisseur ;
@FXML public DatePicker DatePickerDateReception;
@FXML public ChoiceBox ChoiceBoxLocalReception ;
@FXML public Text TextNumero ;
@FXML public Text TextHeur ;
@FXML public Text TextDateReception;
@FXML public Text TextFournisseur ;
@FXML public Text TextLocalReception ;
@FXML public ProgressIndicator ProgressIndicatorSaveFactureFrs ;
public ObservableList<ListeProduit> ListProd = FXCollections.observableArrayList();
Produit produit= new Produit();
ProduitDB produitDB= new ProduitDB();
contro Controle = new contro();
public ArrayList<String> ListFournisseur = new ArrayList<>();
public ArrayList<String> ListLocale = new ArrayList<>();
float netaPayer = 0;
float Remises = 0;
float totalTVA = 0;
float total_H_T_Net= 0;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
DatePickerDateReception.setValue(LocalDate.now());
TextFieldHeur.setText(LocalDateTime.now().getHour()+":"+LocalDateTime.now().getMinute());
TabColReference.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("reference"));
TabColDesignaton.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("designation"));
TabColQuantite.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("quantite"));
TabColQuantite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColQuantite.getStyleClass().add("Center");
TabColPrixHT.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("PrixHT"));
TabColPrixHT.setStyle( "-fx-alignment: CENTER;");
TabColPrixHT.getStyleClass().add("Center");
TabColRemise.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("Remise"));
TabColRemise.setStyle( "-fx-alignment: CENTER;");
TabColRemise.getStyleClass().add("Center");
TabColTotalHT.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("TotalHT"));
TabColTotalHT.setStyle( "-fx-alignment: CENTER;");
TabColTotalHT.getStyleClass().add("Center");
TabColTVA.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("TVA"));
TabColTVA.setStyle( "-fx-alignment: CENTER;");
TabColTVA.getStyleClass().add("Center");
TabColTotalTTC.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("TotalTTC"));
TabColTotalTTC.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColTotalTTC.getStyleClass().add("Center");
TabColReference.setCellFactory(TextFieldTableCell.<ListeProduit>forTableColumn());
TabColQuantite.setCellFactory(TextFieldTableCell.<ListeProduit>forTableColumn());
TabColRemise.setCellFactory(TextFieldTableCell.<ListeProduit>forTableColumn());
TabColAddAction.setSortable(true);
TabColAddAction.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<ListeProduit, Boolean>,
ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(TableColumn.CellDataFeatures<ListeProduit, Boolean> p) {
return new SimpleBooleanProperty(p.getValue() != null);
}
});
// create a cell value factory with an add button for each row in the table.
TabColAddAction.setCellFactory(new Callback<TableColumn<ListeProduit, Boolean>, TableCell<ListeProduit, Boolean>>() {
@Override
public TableCell<ListeProduit, Boolean> call(TableColumn<ListeProduit, Boolean> personBooleanTableColumn) {
return new FactureFrsAjouterController.ButtonCell();
}
});
TabColAddAction.setStyle( "-fx-alignment: CENTER;");
TabColAddAction.getStyleClass().add("Center");
StockDB Stock = new StockDB();
ListLocale = Stock.getAllListLocal();
ChoiceBoxLocalReception.getItems().addAll(ListLocale);
ListFournisseur = new FournisseurDB().getAllFournisseur("CONCAT(`id_fourisseur`,' - ',`nom`)");
TextFields.bindAutoCompletion(TextFieldFournisseur, ListFournisseur);
this.ReferenceMouseClick();
this.QantiteMouseClick();
this.RemiseMouseClick();
TabColAddAction.setSortable(true);
TabColAddAction.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<ListeProduit, Boolean>,
ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(TableColumn.CellDataFeatures<ListeProduit, Boolean> p) {
return new SimpleBooleanProperty(p.getValue() != null);
}
});
// create a cell value factory with an add button for each row in the table.
TabColAddAction.setCellFactory(new Callback<TableColumn<ListeProduit, Boolean>, TableCell<ListeProduit, Boolean>>() {
@Override
public TableCell<ListeProduit, Boolean> call(TableColumn<ListeProduit, Boolean> personBooleanTableColumn) {
return new FactureFrsAjouterController.ButtonCell();
}
});
TableViewListeProduit.setItems(ListProd);
//Ajouter une ligne vide clors ce que en click sur la tableview
TableViewListeProduit.setOnMouseClicked(new EventHandler<javafx.scene.input.MouseEvent>(){
public void handle(MouseEvent event){
int nbrligne = TableViewListeProduit.getItems().size() ;
if(nbrligne == 0){
ListProd.add(new ListeProduit("","","","","","","",""));
TableViewListeProduit.setItems(ListProd);
}
else{
ListeProduit Liste = TableViewListeProduit.getItems().get(nbrligne - 1);
if(!Liste.getTotalTTC().isEmpty()){
ListProd.add(new ListeProduit("","","","","","","",""));
TableViewListeProduit.setItems(ListProd);
TableViewListeProduit.getSelectionModel().select(nbrligne);
}
}
}
});
ButtonFactureFrsAjouter.setOnAction(new EventHandler<ActionEvent>() { //supprimer le message du suucés et reaficher les formulaires
@Override
public void handle(ActionEvent event) {
ButtonFactureFrsAjouter.setText("");
ButtonFactureFrsAjouter.setDisable(true);
ProgressIndicatorSaveFactureFrs.setVisible(true);
if( Controle.ContrNumeriqueNotnull(TextFieldNumero, TextNumero) &&
Controle.ContrNull(TextFieldFournisseur, TextFournisseur) &&
Controle.ContrNullDatePicker(DatePickerDateReception, TextDateReception) &&
Controle.ContrHour(TextFieldHeur, TextHeur) &&
Controle.ContrNullValue(ChoiceBoxLocalReception, TextLocalReception)
){
Runnable task = new Runnable(){// Create a Runnable
public void run(){
Platform.runLater(new Runnable(){
@Override
public void run(){
String Numero = TextFieldNumero.getText();
String IdFournisseur = TextFieldFournisseur.getText().split(" - ", -1)[0];
FactureFrsDB FactureDB = new FactureFrsDB();
String IdFactureFrs = FactureDB.getFactureFrs(null, Numero, IdFournisseur).getIdFactureFrs();
if(IdFactureFrs != null){
TextFieldNumero.setStyle("-fx-border-color:#f20606;");
TextNumero.setText("Facture Fournisseur existe déja");
}else{
if(ListProd.size()>0){
FactureFrs FactureFrs = SetFacture();
FactureDB.setFactureFrsDB(FactureFrs);
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/FactureFrs/FactureFrsDetail.fxml"));
Parent ParentFxmlFournisseur = (Parent)fxmlLoader.load();
FactureFrsDetailController FactureFrsDetail = fxmlLoader.getController();
FactureFrsDetail.setDataFactureDetailFrs(FactureFrs.getIdFactureFrs());
FactureFrsDetail.PaneSucessFrs.setVisible(true);
PaneFactureFrsAjouter.getChildren().clear();
PaneFactureFrsAjouter.getChildren().add(ParentFxmlFournisseur);
}catch (IOException ex) {
Logger.getLogger(FactureFrsDetailController.class.getName()).log(Level.SEVERE, null, ex);
}
}else{
final MessageControle messagecontrol = new MessageControle();
Text text3 = new Text();
text3.setText("Vous devez ajouter au moin un produit à la liste des produits");
text3.setFont(Font.font("Arial", FontWeight.BOLD, 13));
text3.setFill(Color.web("#363a38"));
messagecontrol.DetailMSG.getChildren().add(text3);
messagecontrol.bouttonOK.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
messagecontrol.stackpane.setVisible(false);
}
});
messagecontrol.ShowNotification();
}
}
}
});
}
};
Thread backgroundThread = new Thread(task);// Run the task in a background thread
backgroundThread.setDaemon(true);// Terminate the running thread if the application exits
backgroundThread.start();// Start the thread
}
ButtonFactureFrsAjouter.setText("Enregister La Facture");
ButtonFactureFrsAjouter.setDisable(false);
ProgressIndicatorSaveFactureFrs.setVisible(false);
}
});
}
public FactureFrs SetFacture(){
FactureFrs Facture = new FactureFrs();
if(!TextFieldFournisseur.getText().equals("")){
String[] Fournisseur = TextFieldFournisseur.getText().split(" - ", -1);
Fournisseur Frs = new Fournisseur();
Frs.setCode(Fournisseur[0]);
Frs.setNom(Fournisseur[1]);
Facture.setFournisseur(Frs);
}
if(ChoiceBoxLocalReception.getValue() != null){
Facture.setLocal(ChoiceBoxLocalReception.getValue().toString());
}
if(DatePickerDateReception.getValue() != null){
Facture.setDateCreation(DatePickerDateReception.getValue().toString());
}
Facture.setNumero(TextFieldNumero.getText());
Facture.setHeurCreation(TextFieldHeur.getText());
Facture.setTotalHorsTaxNet(Adaptateur.floatDeleZero(total_H_T_Net));
Facture.setTotalTVA(Adaptateur.floatDeleZero(totalTVA));
Facture.setRemise(Adaptateur.floatDeleZero(Remises));
Facture.setNetAPayer(Adaptateur.floatDeleZero(netaPayer));
Facture.setTimbre(Timbre.getText());
Facture.setListProduit(ListProd);
Facture.setTypeReglement(null);
Facture.setEtatReglement(null);
return Facture;
}
public void getFacture(FactureFrs Facture){
TextFieldNumero.setText(Facture.getNumero());
TextFieldHeur.setText(Facture.getHeurCreation());
DatePickerDateReception.setValue(Adaptateur.StringToLocalDate(Facture.getDateCreation()));
Fournisseur Frs = Facture.getFournisseur();
if(Frs != null){
TextFieldFournisseur.setText(Frs.getCode()+" - "+Frs.getNom());
}
String Local = Facture.getLocal();
if(Local != null){
int indexLocale = ListLocale.indexOf(Local);
ChoiceBoxLocalReception.getSelectionModel().select(indexLocale);
}
}
//Define the button cell
private class ButtonCell extends TableCell<ListeProduit, Boolean> {
final Button cellButton = new Button();
ButtonCell(){
cellButton.getStyleClass().add("btn-danger");
Image coffeeImage = new Image(getClass().getResourceAsStream("/Public/icon/icondelete.png"));
ImageView buttonGraphic = new ImageView();
buttonGraphic.setImage(coffeeImage);
cellButton.setGraphic(buttonGraphic);
//Action when the button is pressed
cellButton.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
int selectdIndex = getTableRow().getIndex();
ListProd.remove(selectdIndex);
CalculeListeProduit();
TableViewListeProduit.setStyle(".table-row-cell:selected{ -fx-background-color:transparent ;}");
}
});
}
//Display button if the row is not empty
@Override
protected void updateItem(Boolean t, boolean empty) {
if(!empty){
setGraphic(cellButton);
} else {
setGraphic(null);
}
}
}
@FXML
private void AddLigneButtonAction(ActionEvent event) throws IOException {
int nbrligne = TableViewListeProduit.getItems().size() ;
if(nbrligne == 0){
ListProd.add(new ListeProduit("","","","","","","",""));
TableViewListeProduit.setItems(ListProd);
}
else{
ListeProduit Liste = TableViewListeProduit.getItems().get(nbrligne - 1);
if(!Liste.getTotalTTC().isEmpty()){
ListProd.add(new ListeProduit("","","","","","","",""));
TableViewListeProduit.setItems(ListProd);
TableViewListeProduit.getSelectionModel().select(nbrligne);
}
}
}
private void ReferenceMouseClick(){
TabColReference.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent<ListeProduit, String>>() {
@Override
public void handle(TableColumn.CellEditEvent<ListeProduit, String> t) {
produit = produitDB.getProduit(t.getNewValue());
if(produit.getReference() != null){
ListeProduit Liste = new ListeProduit(produit.getReference(),produit.getDesignation(),"1",produit.getPrixachatht(),"0","",produit.getTvaachat(),"0");
AffectationTableView(Liste,t.getTablePosition().getRow()) ;
}
else{
AffectationTableView(new ListeProduit("","","","","","","",""),t.getTablePosition().getRow()) ;
}
}
});
}
private void QantiteMouseClick(){
TabColQuantite.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent<ListeProduit, String>>() {
@Override
public void handle(TableColumn.CellEditEvent<ListeProduit, String> t) {
String newquantite = t.getNewValue() ;
try{
newquantite = newquantite.replace(',','.');
if(Float.parseFloat(newquantite)<1){
newquantite = "1";
}
}
catch(NumberFormatException nfe){
newquantite = "1";
}
ListeProduit Liste = t.getRowValue() ;
if(Liste.getReference().isEmpty()){ //le cas en ajoute un quantité dans un ligne vide
TableViewListeProduit.getColumns().get(t.getTablePosition().getRow()).setVisible(false);
TableViewListeProduit.getColumns().get(t.getTablePosition().getRow()).setVisible(true);
}
else{
Liste.setQuantite(newquantite);
ListeProduit NewList = new ListeProduit(Liste.getReference(),Liste.getDesignation(), newquantite,Liste.getPrixHT(), Liste.getRemise(),"",Liste.getTVA(),"");
//NewList = CalculeProduit(NewList);
AffectationTableView(NewList,t.getTablePosition().getRow()) ;
}
}
});
}
private void RemiseMouseClick(){
TabColRemise.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent<ListeProduit, String>>() {
@Override
public void handle(TableColumn.CellEditEvent<ListeProduit, String> t) {
String newRemise = t.getNewValue() ;
try{
newRemise = newRemise.replace(',','.');
if(Float.parseFloat(newRemise)<0){
newRemise = "0";
}
}
catch(NumberFormatException nfe){
newRemise = "0";
}
ListeProduit Liste = t.getRowValue() ;
if(Liste.getReference().isEmpty()){ //le cas en ajoute un remise dans un ligne vide
TableViewListeProduit.getColumns().get(t.getTablePosition().getRow()).setVisible(false);
TableViewListeProduit.getColumns().get(t.getTablePosition().getRow()).setVisible(true);
}
else{
Liste.setRemise(newRemise);
ListeProduit NewList = new ListeProduit(Liste.getReference(),Liste.getDesignation(), Liste.getQuantite(),Liste.getPrixHT(), newRemise, "", Liste.getTVA(), "");
AffectationTableView(NewList, t.getTablePosition().getRow());
}
}
});
}
private void AffectationTableView(ListeProduit ListeProd, int EmplacementLigne){
boolean result = false ;
int indise=0;
int Position = 0;
if(ListProd.size()>0){
do{ //Vérifier si le produit exsiste deja
if(ListProd.get(indise).getReference().equals(ListeProd.getReference())){
result = true ;
Position = indise ;
//System.out.println("existe Position:"+indise);
}
indise++;
}while(ListProd.size()>indise && !result);
if(result){ //si la ligne exsite déja
if(EmplacementLigne!= -1){
if(Position == EmplacementLigne){
ListProd.set(Position, ListeProd);
}
else{
ListProd.set(EmplacementLigne, new ListeProduit("","","","","","","",""));
}
}
}else{
if(EmplacementLigne!= -1){
ListProd.set(EmplacementLigne, ListeProd);
}else{
ListProd.add(ListeProd);
}
}
}
else{
ListProd.add(ListeProd);
}
CalculeListeProduit();
TableViewListeProduit.setItems(ListProd);
TableViewListeProduit.setVisible(false);
TableViewListeProduit.setVisible(true);
}
private void CalculeListeProduit(){ //calculer et afficher la détail des produits
netaPayer = 0;
Remises = 0;
totalTVA = 0;
total_H_T_Net= 0;
TotalTVA.setText("");
Remise.setText("");
NetAPayer.setText("");
Timbre.setText("");
TotalHTNet.setText("");
//calcule
for(ListeProduit liste : ListProd){
float totaht = Adaptateur.StringToFloat(liste.getTotalHT()) ;
float prix_U_H_T = Adaptateur.StringToFloat(liste.getPrixHT()) ;
float remises = Adaptateur.StringToFloat(liste.getRemise().replace("%", "")) ;
float tva = Adaptateur.StringToFloat(liste.getTVA().replace("%", ""));
float qte = Adaptateur.StringToFloat(liste.getQuantite());
totalTVA = totalTVA + ((totaht * tva) /100) ;
Remises = Remises + (prix_U_H_T * remises)/100 ;
total_H_T_Net = total_H_T_Net + totaht ;
}
if(total_H_T_Net>0){
float timbre = Adaptateur.StringToFloat(ParametreSystem.Timbre);
netaPayer = total_H_T_Net + totalTVA + timbre ;
TotalTVA.setText(Adaptateur.FloatToStringEspace(totalTVA));
Remise.setText(Adaptateur.FloatToStringEspace(Remises));
NetAPayer.setText(Adaptateur.FloatToStringEspaceCurrency(netaPayer));
Timbre.setText(ParametreSystem.Timbre);
TotalHTNet.setText(Adaptateur.FloatToStringEspace(total_H_T_Net));
}
}
public Object[] getDefaultSaveDataImport(){
Object[] ArrayObject = new Object[10];
ArrayObject[0] = this.ListProd;
ArrayObject[1] = SetFacture();
return ArrayObject;
}
public void SetDefaultSaveDataImport(Object[] ArrayObject){
if(ArrayObject[0] != null){
this.ListProd = (ObservableList<ListeProduit>) ArrayObject[0];
this.CalculeListeProduit();
this.TableViewListeProduit.setItems(ListProd);
}
if(ArrayObject[1] != null){
FactureFrs Facture = (FactureFrs) ArrayObject[1];
getFacture(Facture);
}
if(ArrayObject[6] != null){
this.SetProduit( (Produit) ArrayObject[6] );
}
}
@FXML
private void RechercheProduitButtonAction(ActionEvent event) throws IOException {
final RechercherProduitController rechercheproduit = new RechercherProduitController(false);
rechercheproduit.ArrayObjectDataSave = this.getDefaultSaveDataImport();
rechercheproduit.Show();
rechercheproduit.TabColAction.setCellFactory(new Callback<TableColumn<Produit, String>, TableCell<Produit, String>>() {
@Override
public TableCell<Produit, String> call(TableColumn<Produit, String> paramP) {
return new TableCell<Produit, String>() {
final Button cellButton = new Button("");
{
cellButton.getStyleClass().add("btn-icon-primary");
Image coffeeImage = new Image(getClass().getResourceAsStream("/Public/icon/iconaffecter.png"));
ImageView buttonGraphic = new ImageView();
buttonGraphic.setImage(coffeeImage);
cellButton.setGraphic(buttonGraphic);
cellButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
try {
// get Selected ItemButtonCell
rechercheproduit.ArrayObjectDataSave[6] = ((Produit)getTableRow().getItem());
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/FactureFrs/FactureFrsAjouter.fxml"));
Parent ParentBonReceptionAjouterFXML = (Parent) fxmlLoader.load();
FactureFrsAjouterController FactureFrsAjouter = fxmlLoader.getController();
FactureFrsAjouter.SetDefaultSaveDataImport(rechercheproduit.ArrayObjectDataSave);
MyWindow mywindows = new MyWindow();
mywindows.Refresh(ParentBonReceptionAjouterFXML, 2);
} catch (IOException ex) {
Logger.getLogger(CommandeCltPasserController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
@Override
protected void updateItem(String paramT, boolean isEmpty) {
super.updateItem(paramT, isEmpty);
if (!isEmpty) {
setGraphic(cellButton);
} else {
setGraphic(null);
}
}
};
}
});
}
public void SetProduit(Produit produit){
//Supprimer les igne vide
if((ListProd.size()>0) && (ListProd.get(ListProd.size()-1).getReference().isEmpty())){
ListProd.remove(ListProd.size()-1);
}
if(produit != null){
ListeProduit ListeProd = new ListeProduit(produit.getReference(),produit.getDesignation(),"1",produit.getPrixachatht(),"0",produit.getPrixachatttc(),produit.getTvaachat(),"0");
AffectationTableView(ListeProd,-1);
}
}
}
@@ -0,0 +1,633 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Controllers.FactureFrs;
import Controllers.Dialog.MessageControle;
import Controllers.Traitement.Adaptateur;
import Controllers.Traitement.ParametreSystem;
import Controllers.Traitement.contro;
import Models.BonReceptionFrs.BonReceptionDB;
import Models.BonReceptionFrs.BonReceptionFrs;
import Models.BonReceptionFrs.BonReceptionList;
import Models.BonReceptionFrs.BonReceptionProduitList;
import Models.FactureFrs.FactureFrs;
import Models.FactureFrs.FactureFrsDB;
import Models.Fournisseur.Fournisseur;
import Models.Fournisseur.FournisseurDB;
import Models.Produit.ListeProduit;
import Models.Stock.StockDB;
import Models.User.Profile;
import Models.User.User;
import java.io.IOException;
import java.net.URL;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import javafx.application.Platform;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.util.Callback;
import org.controlsfx.control.textfield.TextFields;
/**
* FXML Controller class
*
* @author Maher
*/
public class FactureFrsBonReceptionAjouterController implements Initializable {
@FXML public AnchorPane PaneFactureBRFrsAjouter ;
@FXML public TableView<BonReceptionList> TableViewBonReception ;
@FXML public TableColumn<BonReceptionList ,String> TabColReference;
@FXML public TableColumn<BonReceptionList ,String> TabColFournisseur;
@FXML public TableColumn<BonReceptionList ,String> TabColDate;
@FXML public TableColumn<BonReceptionList ,String> TabColLocalReception;
@FXML public TableColumn<BonReceptionList ,String> TabColNetPayer;
@FXML public TableColumn<BonReceptionList ,Boolean> TabColRechAddAction;
@FXML public TableView<BonReceptionList> TableViewBonReceptionSelected;
@FXML public TableColumn<BonReceptionList ,String> TabColReferenceSelected;
@FXML public TableColumn<BonReceptionList ,String> TabColFournisseurSelected;
@FXML public TableColumn<BonReceptionList ,String> TabColDateSelected;
@FXML public TableColumn<BonReceptionList ,String> TabColLocalReceptionSelected;
@FXML public TableColumn<BonReceptionList ,String> TabColNetPayerSelected;
@FXML public TableColumn<BonReceptionList ,Boolean> TabColSupprimer;
@FXML public TextField TextFieldNumero ;
@FXML public TextField TextFieldNetPayer ;
@FXML private TextField TextFieldFournisseur ;
@FXML public ChoiceBox ChoiceBoxLocalReception ;
@FXML public DatePicker DatePickerDateReception;
@FXML public TextField TextFieldNumeroFac ;
@FXML public TextField TextFieldHeurFac ;
@FXML public DatePicker DatePickerDateFac;
@FXML public Text TextCltNumeroFac ;
@FXML public Text TextCltHeurFac ;
@FXML public Text TextCltDateFac ;
@FXML public Text TextTotalFacture;
@FXML public Button ButtonFactureBLAjouter;
@FXML public ProgressIndicator ProgressIndicatorBonReception;
@FXML public ProgressIndicator ProgressIndicatorSaveFactureBLAjouter;
public ArrayList<String> ListFournisseur = new ArrayList<>();
public ArrayList<String> ListLocale = new ArrayList<>();
ObservableList<BonReceptionList> ObservableListBonReception = FXCollections.observableArrayList();
BonReceptionDB BonRecepDB= new BonReceptionDB();
contro Controle = new contro();
String StringSeleFournissuer ;
@Override
public void initialize(URL url, ResourceBundle rb) {
TabColReference.setCellValueFactory(new PropertyValueFactory<BonReceptionList, String>("Numero"));
TabColFournisseur.setCellValueFactory(new PropertyValueFactory<BonReceptionList, String>("Fournisseur"));
TabColFournisseur.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColFournisseur.getStyleClass().add("Center");
TabColDate.setCellValueFactory(new PropertyValueFactory<BonReceptionList, String>("Date"));
TabColDate.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDate.getStyleClass().add("Center");
TabColNetPayer.setCellValueFactory(new PropertyValueFactory<BonReceptionList, String>("NetPayer"));
TabColNetPayer.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColNetPayer.getStyleClass().add("Center");
TabColLocalReception.setCellValueFactory(new PropertyValueFactory<BonReceptionList, String>("LocalReception"));
TabColLocalReception.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColLocalReception.getStyleClass().add("Center");
TabColRechAddAction.setSortable(true);
TabColRechAddAction.setStyle( "-fx-alignment: CENTER;");
TabColRechAddAction.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<BonReceptionList, Boolean>,
ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(TableColumn.CellDataFeatures<BonReceptionList, Boolean> p) {
return new SimpleBooleanProperty(p.getValue() != null);
}
});
// create a cell value factory with an add button for each row in the table.
TabColRechAddAction.setCellFactory(new Callback<TableColumn<BonReceptionList, Boolean>, TableCell<BonReceptionList, Boolean>>() {
@Override
public TableCell<BonReceptionList, Boolean> call(TableColumn<BonReceptionList, Boolean> personBooleanTableColumn) {
return new FactureFrsBonReceptionAjouterController.ButtonCell();
}
});
TabColReferenceSelected.setCellValueFactory(new PropertyValueFactory<BonReceptionList, String>("Numero"));
TabColFournisseurSelected.setCellValueFactory(new PropertyValueFactory<BonReceptionList, String>("Fournisseur"));
TabColFournisseurSelected.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColFournisseurSelected.getStyleClass().add("Center");
TabColDateSelected.setCellValueFactory(new PropertyValueFactory<BonReceptionList, String>("Date"));
TabColDateSelected.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDateSelected.getStyleClass().add("Center");
TabColNetPayerSelected.setCellValueFactory(new PropertyValueFactory<BonReceptionList, String>("NetPayer"));
TabColNetPayerSelected.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColNetPayerSelected.getStyleClass().add("Center");
TabColLocalReceptionSelected.setCellValueFactory(new PropertyValueFactory<BonReceptionList, String>("LocalReception"));
TabColLocalReceptionSelected.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColLocalReceptionSelected.getStyleClass().add("Center");
TabColSupprimer.setSortable(true);
TabColSupprimer.setStyle( "-fx-alignment: CENTER;");
TabColSupprimer.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<BonReceptionList, Boolean>,
ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(TableColumn.CellDataFeatures<BonReceptionList, Boolean> p) {
return new SimpleBooleanProperty(p.getValue() != null);
}
});
// create a cell value factory with an add button for each row in the table.
TabColSupprimer.setCellFactory(new Callback<TableColumn<BonReceptionList, Boolean>, TableCell<BonReceptionList, Boolean>>() {
@Override
public TableCell<BonReceptionList, Boolean> call(TableColumn<BonReceptionList, Boolean> personBooleanTableColumn) {
return new FactureFrsBonReceptionAjouterController.ButtonCellRemove();
}
});
ListFournisseur = new FournisseurDB().getAllFournisseur("CONCAT(`id_fourisseur`,' - ',`nom`)");
TextFields.bindAutoCompletion(TextFieldFournisseur, ListFournisseur);
StockDB Stock = new StockDB();
ListLocale = Stock.getAllListLocal();
ChoiceBoxLocalReception.getItems().addAll(ListLocale);
DatePickerDateFac.setValue(LocalDate.now());
TextFieldHeurFac.setText(LocalDateTime.now().getHour()+":"+LocalDateTime.now().getMinute());
RechecheBonReception();
getRechecheBonReception("");
AjouterFactureBL();
}
//Define the button cell
private class ButtonCell extends TableCell<BonReceptionList, Boolean> {
final Button cellButton = new Button();
ButtonCell(){
cellButton.getStyleClass().add("btn-icon-primary");
Image coffeeImage = new Image(getClass().getResourceAsStream("/Public/icon/iconaffecter.png"));
ImageView buttonGraphic = new ImageView();
buttonGraphic.setImage(coffeeImage);
cellButton.setGraphic(buttonGraphic);
//Action when the button is pressed
cellButton.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
BonReceptionList BonReceptionListSelect = (BonReceptionList)getTableRow().getItem();
AffectBonReception(BonReceptionListSelect);
}
});
}
//Display button if the row is not empty
@Override
protected void updateItem(Boolean t, boolean empty) {
if(!empty){
setGraphic(cellButton);
} else {
setGraphic(null);
}
}
}
//Define the button cell
private class ButtonCellRemove extends TableCell<BonReceptionList, Boolean> {
final Button cellButton = new Button();
ButtonCellRemove(){
cellButton.getStyleClass().add("btn-danger");
Image coffeeImage = new Image(getClass().getResourceAsStream("/Public/icon/icondelete.png"));
ImageView buttonGraphic = new ImageView();
buttonGraphic.setImage(coffeeImage);
cellButton.setGraphic(buttonGraphic);
//Action when the button is pressed
cellButton.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
int selectdIndex = getTableRow().getIndex();
ObservableListBonReception.remove(selectdIndex);
CalculeFacture();
TableViewBonReceptionSelected.setItems(ObservableListBonReception);
TableViewBonReceptionSelected.refresh();
}
});
}
//Display button if the row is not empty
@Override
protected void updateItem(Boolean t, boolean empty) {
if(!empty){
setGraphic(cellButton);
} else {
setGraphic(null);
}
}
}
private void getRechecheBonReception(final String KeyWordSearch )
{
try {
ProgressIndicatorBonReception.setVisible(true);
TableViewBonReception.setVisible(false);
// Create a Runnable
Runnable task = new Runnable(){
public void run(){
Platform.runLater(new Runnable(){
@Override
public void run(){
TableViewBonReception.setItems(BonRecepDB.getBonReceptionNotFact(KeyWordSearch));
ProgressIndicatorBonReception.setVisible(false);
TableViewBonReception.setVisible(true);
}
});
}
};
Thread backgroundThread = new Thread(task); // Run the task in a background thread
backgroundThread.setDaemon(true); // Terminate the running thread if the application exits
backgroundThread.start(); // Start the thread
}catch (Exception ex) {
System.err.println("Exception getRechecheBonReception \n"+ex.getMessage());
}
}
private boolean ContrFournissuer()
{
final MessageControle messagecontrol = new MessageControle();
Text text3 = new Text();
text3.setFont(Font.font("Arial", FontWeight.BOLD, 13));
text3.setFill(Color.web("#363a38"));
if(ObservableListBonReception.size()>0){
boolean result = true ;
StringSeleFournissuer = ObservableListBonReception.get(0).getFournisseur();
int indise = 1;
//Verifier si la produit exsiste déja
while(indise<=ObservableListBonReception.size() && result){
result = ObservableListBonReception.get(indise-1).getFournisseur().equals(StringSeleFournissuer);
indise++;
}
//si le fournisseur n'exsiste pas
if(!result){
text3.setText("Les fournisseurs sélectionnés sont différents");
messagecontrol.DetailMSG.getChildren().add(text3);
messagecontrol.bouttonOK.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
messagecontrol.stackpane.setVisible(false);
}
});
messagecontrol.ShowNotification();
return false;
}
//si la facture existe déja
String IdFournisseur = StringSeleFournissuer.split(" - ", -1)[0];
FactureFrsDB FactureDB = new FactureFrsDB();
FactureFrs Facture = FactureDB.getFactureFrs(null, TextFieldNumeroFac.getText(), IdFournisseur);
if(Facture.getIdFactureFrs() != null){
text3.setText("Cette facture existe déja");
messagecontrol.DetailMSG.getChildren().add(text3);
messagecontrol.bouttonOK.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
messagecontrol.stackpane.setVisible(false);
}
});
messagecontrol.ShowNotification();
return false;
}
return true;
}
else{
//si la liste est vide
text3.setText("Vous devez ajouter au moin un Bon Réception à la liste");
messagecontrol.DetailMSG.getChildren().add(text3);
messagecontrol.bouttonOK.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
messagecontrol.stackpane.setVisible(false);
}
});
messagecontrol.ShowNotification();
return false;
}
}
private void AjouterFactureBL(){
ButtonFactureBLAjouter.setOnAction(new EventHandler<ActionEvent>() { //supprimer le message du suucés et reaficher les formulaires
@Override
public void handle(ActionEvent event) {
if( Controle.ContrNumeriqueNotnull(TextFieldNumeroFac, TextCltNumeroFac) &&
ContrFournissuer() &&
Controle.ContrHour(TextFieldHeurFac, TextCltHeurFac) &&
Controle.ContrNullDatePicker(DatePickerDateFac, TextCltDateFac)){
ButtonFactureBLAjouter.setText("");
ButtonFactureBLAjouter.setDisable(true);
ProgressIndicatorSaveFactureBLAjouter.setVisible(true);
Runnable task = new Runnable(){// Create a Runnable
public void run(){
Platform.runLater(new Runnable(){
@Override
public void run(){
FactureFrs Facture = setFactureBRFrs();
FactureFrsDB FactureDB = new FactureFrsDB();
FactureDB.setFactureBRDB(Facture);
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/FactureFrs/FactureFrsDetail.fxml"));
Parent ParentFxmlFournisseur = (Parent)fxmlLoader.load();
FactureFrsDetailController FactureFrsDetail = fxmlLoader.getController();
FactureFrsDetail.setDataFactureDetailFrs(Facture.getIdFactureFrs());
FactureFrsDetail.PaneSucessFrs.setVisible(true);
PaneFactureBRFrsAjouter.getChildren().clear();
PaneFactureBRFrsAjouter.getChildren().add(ParentFxmlFournisseur);
}catch (IOException ex) {
Logger.getLogger(FactureFrsDetailController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
};
Thread backgroundThread = new Thread(task);// Run the task in a background thread
backgroundThread.setDaemon(true);// Terminate the running thread if the application exits
backgroundThread.start();
}
ButtonFactureBLAjouter.setText("Enregister Facture BR");
ButtonFactureBLAjouter.setDisable(false);
ProgressIndicatorSaveFactureBLAjouter.setVisible(false);
}
});
}
public FactureFrs setFactureBRFrs(){
FactureFrs FactureBRFrs = new FactureFrs();
FactureBRFrs.setNumero(TextFieldNumeroFac.getText());
FactureBRFrs.setHeurCreation(TextFieldHeurFac.getText());
FactureBRFrs.setDateCreation(DatePickerDateFac.getValue().toString());
String IdFournisseur = StringSeleFournissuer.split(" - ", -1)[0];
Fournisseur Frs = new Fournisseur();
Frs.setCode(IdFournisseur);
FactureBRFrs.setFournisseur(Frs);
FactureBRFrs.setDevise(ParametreSystem.CurrencySign);
Profile profile= new Profile();
profile.setIdprofile(User.idprofile);
FactureBRFrs.setProfile(profile);
FactureBRFrs.setLocal(ParametreSystem.NomLocalPC);
float total_hors_tax_net = 0;
float total_tva = 0;
float net_a_payer = 0;
ArrayList<String> listRefeProduct = new ArrayList<>();
ArrayList<BonReceptionProduitList> listProd = new ArrayList<>();
ObservableList<ListeProduit> ListProduit = FXCollections.observableArrayList() ;
ObservableList<BonReceptionFrs> ListeBonReception = FXCollections.observableArrayList() ;
for(int i=0; i<ObservableListBonReception.size(); i++){
BonReceptionFrs BonReception = BonRecepDB.getBonReceptionFrs(ObservableListBonReception.get(i).getCode(), null, null);
ObservableList<BonReceptionProduitList> ObservableListProduit = BonReception.getListProduit();
for(int j=0; j<ObservableListProduit.size();j++){
listProd.add(ObservableListProduit.get(j));
listRefeProduct.add(ObservableListProduit.get(j).getReference());
float tva = Adaptateur.StringToFloat(ObservableListProduit.get(j).getTva());
float total_hors_tax = Adaptateur.StringToFloat(ObservableListProduit.get(j).getPrixUnitaireHorsTaxenNet());
total_tva += (total_hors_tax * tva) /100 ;
total_hors_tax_net += Adaptateur.StringToFloat(ObservableListProduit.get(j).getPrixUnitaireHorsTaxenNet());
net_a_payer += Adaptateur.StringToFloat(ObservableListProduit.get(j).getMontant());
}
ListeBonReception.add(BonReception);
}
listRefeProduct = (ArrayList) listRefeProduct.stream().distinct().collect(Collectors.toList());
for(String Refe : listRefeProduct){
float quantite = 0;
float p_u_h_t = 0;
float p_u_h_t_net = 0;
float tva = 0;
float montant = 0;
String designation = "";
for(int j=0; j<listProd.size(); j++){
if(Refe.equals(listProd.get(j).getReference())){
quantite += Adaptateur.StringToFloat(listProd.get(j).getQuantite());
p_u_h_t += Adaptateur.StringToFloat(listProd.get(j).getPrixUnitaireHorsTaxe());
p_u_h_t_net += Adaptateur.StringToFloat(listProd.get(j).getPrixUnitaireHorsTaxenNet());
tva = Adaptateur.StringToFloat(listProd.get(j).getTva());
montant += Adaptateur.StringToFloat(listProd.get(j).getMontant());
designation = listProd.get(j).getDesignation();
}
}
ListProduit.add(new ListeProduit(Refe, designation, Adaptateur.ArrondFloatToString(quantite), Adaptateur.ArrondFloatToString(p_u_h_t), "0", Adaptateur.ArrondFloatToString(p_u_h_t_net), Adaptateur.ArrondFloatToString(tva), Adaptateur.ArrondFloatToString(montant)));
}
FactureBRFrs.setListProduit(ListProduit);
FactureBRFrs.setTotalHorsTaxNet(Adaptateur.ArrondFloatToString(total_hors_tax_net));
FactureBRFrs.setTotalTVA(Adaptateur.ArrondFloatToString(total_tva));
FactureBRFrs.setRemise("0");
FactureBRFrs.setTimbre(ParametreSystem.Timbre);
FactureBRFrs.setListeBonReception(ListeBonReception);
net_a_payer += Adaptateur.StringToFloat(ParametreSystem.Timbre);
FactureBRFrs.setNetAPayer(Adaptateur.ArrondFloatToString(net_a_payer));
return FactureBRFrs;
}
private void AffectBonReception(BonReceptionList BRList){
//lorce qu'il y a plus que ligne
if(ObservableListBonReception.size()>0){
boolean result = false ;
int indise = 1;
//Verifier si la produit exsiste déja
while(indise<=ObservableListBonReception.size() && !result){
result = ObservableListBonReception.get(indise-1).getCode().equals(BRList.getCode());
indise++;
}
//si le produit n'exsiste pas on la joute à la table view
if(!result){
ObservableListBonReception.add(BRList);
}
}
else{
ObservableListBonReception.add(BRList);
}
CalculeFacture();
TableViewBonReceptionSelected.setItems(ObservableListBonReception);
TableViewBonReceptionSelected.refresh();
}
private void CalculeFacture(){
float somme = 0;
for(int i=0; i<ObservableListBonReception.size(); i++){
somme += Adaptateur.ArrondStringToFloat(ObservableListBonReception.get(i).getNetPayer());
}
if(somme > 0){
somme += Adaptateur.ArrondStringToFloat(ParametreSystem.Timbre);
TextTotalFacture.setText(Adaptateur.ArrondFloatToString(somme)+" "+ParametreSystem.CurrencySign);
}else{
TextTotalFacture.setText("");
}
}
private void RechecheBonReception(){
TextFieldNumero.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
String numero = Adaptateur.addSlashes(TextFieldNumero.getText());
if(numero.isEmpty()){
TableViewBonReception.setItems(null);
}
else{
getRechecheBonReception(" AND (BR.numero LIKE '"+numero+"%') ");
}
}
});
TextFieldNetPayer.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
String netpayer = TextFieldNetPayer.getText();
if(netpayer.isEmpty()){
TableViewBonReception.setItems(null);
}
else{
getRechecheBonReception(" AND (BR.net_a_payer LIKE '"+netpayer+"%') ");
}
}
});
DatePickerDateReception.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
try{
getRechecheBonReception(" AND (DATE(BR.date_reception) = "+"'"+DatePickerDateReception.getValue().toString()+"')");
}catch(Exception ex){}
}
});
DatePickerDateReception.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
try{
String DateReception = DatePickerDateReception.getConverter().fromString(DatePickerDateReception.getEditor().getText()).toString();
getRechecheBonReception(" AND (DATE(BR.date_reception) = "+"'"+DateReception+"')");
}catch(Exception ex){}
}
});
TextFieldFournisseur.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
if(newValue.contains(" - ")){
String[] array = newValue.split(" - ", -1);
getRechecheBonReception(" AND (BR.id_fournisseur = '"+array[0]+"') ");
}
}
});
ChoiceBoxLocalReception.valueProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue ov, String t, String ValLocal) {
getRechecheBonReception(" AND (BR.local_reception LIKE '"+ValLocal+"%') ");
}
});
}
}
@@ -0,0 +1,205 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Controllers.FactureFrs;
import Controllers.Traitement.Adaptateur;
import Models.BonReceptionFrs.BonReceptionFrs;
import Models.FactureFrs.FactureFrs;
import Models.FactureFrs.FactureFrsDB;
import Models.Fournisseur.Fournisseur;
import Models.Produit.ListeProduit;
import Models.User.Profile;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.application.Platform;
import javafx.collections.ObservableList;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.concurrent.WorkerStateEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Tab;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
/**
* FXML Controller class
*
* @author Maher
*/
public class FactureFrsDetailController implements Initializable {
@FXML private AnchorPane PaneFactureFrsDetail ;
@FXML private AnchorPane AnchorPaneLoading;
@FXML public AnchorPane PaneSucessFrs ;
@FXML private Tab TabBonReception;
@FXML private Text TextNumero;
@FXML private Text TextDateReception;
@FXML private Text TextTypeReglement; //type reglement: 0 comptant 1 facilité
@FXML private Text TextLocalReception;
@FXML private Text TextEtatReglement; //0 :payer 1 :en cour 3: non pays
@FXML private Text TextProfile;
@FXML private Text TextNomFrs;
@FXML private Text TextSpecialiteFrs;
@FXML private Text TextFormesFrs;
@FXML private Text TextAdresseFrs;
@FXML private Text TextTele1Frs;
@FXML private Text TextTele2Frs;
@FXML private Text TotalTVA ;
@FXML private Text Remise ;
@FXML private Text NetAPayer ;
@FXML private Text Timbre ;
@FXML private Text TotalHTNet ;
@FXML public TableView<ListeProduit> TableViewListeProduit ;
@FXML public TableColumn<ListeProduit ,String> TabColReference;
@FXML public TableColumn<ListeProduit ,String> TabColDesignation;
@FXML public TableColumn<ListeProduit ,String> TabColQuantite ;
@FXML public TableColumn<ListeProduit ,String> TabColPrixHT;
@FXML public TableColumn<ListeProduit ,String> TabColRemise;
@FXML public TableColumn<ListeProduit ,String> TabColTotalHT;
@FXML public TableColumn<ListeProduit ,String> TabColTVA;
@FXML public TableColumn<ListeProduit ,String> TabColTotalTTC;
@FXML public TableView<BonReceptionFrs> TableViewBonReception;
@FXML public TableColumn<BonReceptionFrs ,String> TabColNumero;
@FXML public TableColumn<BonReceptionFrs ,String> TabColDate;
@FXML public TableColumn<BonReceptionFrs ,String> TabColHeur;
@FXML public TableColumn<BonReceptionFrs ,String> TabColLocalReception;
@FXML public TableColumn<BonReceptionFrs ,String> TabColTransporteur;
@FXML public TableColumn<BonReceptionFrs ,String> TabColNetPayer;
private Service<Void> ThreadFactureFrsDetail;
FactureFrs Facture ;
@Override
public void initialize(URL url, ResourceBundle rb) {
TabColReference.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("reference"));
TabColDesignation.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("designation"));
TabColQuantite.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("quantite"));
TabColQuantite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColQuantite.getStyleClass().add("Center");
TabColPrixHT.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("PrixHT"));
TabColPrixHT.setStyle( "-fx-alignment: CENTER;");
TabColPrixHT.getStyleClass().add("Center");
TabColRemise.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("Remise"));
TabColRemise.setStyle( "-fx-alignment: CENTER;");
TabColRemise.getStyleClass().add("Center");
TabColTotalHT.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("TotalHT"));
TabColTotalHT.setStyle( "-fx-alignment: CENTER;");
TabColTotalHT.getStyleClass().add("Center");
TabColTVA.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("TVA"));
TabColTVA.setStyle( "-fx-alignment: CENTER;");
TabColTVA.getStyleClass().add("Center");
TabColTotalTTC.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("TotalTTC"));
TabColTotalTTC.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColTotalTTC.getStyleClass().add("Center");
TabColNumero.setCellValueFactory(new PropertyValueFactory<BonReceptionFrs, String>("Numero"));
TabColDate.setCellValueFactory(new PropertyValueFactory<BonReceptionFrs, String>("Date"));
TabColDate.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDate.getStyleClass().add("Center");
TabColHeur.setCellValueFactory(new PropertyValueFactory<BonReceptionFrs, String>("Heur"));
TabColHeur.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColHeur.getStyleClass().add("Center");
TabColLocalReception.setCellValueFactory(new PropertyValueFactory<BonReceptionFrs, String>("Local"));
TabColLocalReception.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColLocalReception.getStyleClass().add("Center");
TabColTransporteur.setCellValueFactory(new PropertyValueFactory<BonReceptionFrs, String>("Transporteur"));
TabColTransporteur.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColTransporteur.getStyleClass().add("Center");
TabColNetPayer.setCellValueFactory(new PropertyValueFactory<BonReceptionFrs, String>("NetPayer"));
TabColNetPayer.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColNetPayer.getStyleClass().add("Center");
}
public void setDataFactureDetailFrs(final String IdFactureFrs){
ThreadFactureFrsDetail = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
Facture = new FactureFrsDB().getFactureFrs(IdFactureFrs, null, null);
return null;
}
};
}
};
ThreadFactureFrsDetail.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
TextNumero.setText(Facture.getNumero());
TextDateReception.setText(Facture.getDateCreation()+" "+Facture.getHeurCreation());
TextTypeReglement.setText(Facture.getTypeReglementString());
TextLocalReception.setText(Facture.getLocal());
TextEtatReglement.setText(Facture.getEtatReglementString());
Profile profile = Facture.getProfile();
TextProfile.setText(profile.getNom()+" "+profile.getPrenom());
TotalTVA.setText(Adaptateur.FloatToStringEspaceCurrency(Facture.getFTotalTVA()));
Remise.setText(Adaptateur.FloatToStringEspaceCurrency(Facture.getFRemise()));
NetAPayer.setText(Adaptateur.FloatToStringEspaceCurrency(Facture.getFNetAPayer()));
Timbre.setText(Adaptateur.FloatToStringEspaceCurrency(Facture.getFTimbre()));
TotalHTNet.setText(Adaptateur.FloatToStringEspaceCurrency(Facture.getFTotalHorsTaxNet()));
Fournisseur Frs = Facture.getFournisseur();
TextNomFrs.setText(Frs.getNom());
TextSpecialiteFrs.setText(Frs.getSpecialite());
TextFormesFrs.setText(Frs.getFormes());
TextAdresseFrs.setText(Frs.getAdresse());
TextTele1Frs.setText(Frs.getTele1());
TextTele2Frs.setText(Frs.getTele2());
ObservableList<ListeProduit> ProduitList = Facture.getListProduit();
TableViewListeProduit.setItems(ProduitList);
TableViewListeProduit.refresh();
if(Facture.getBonReception() == null){
TabBonReception.setText("");
TabBonReception.setDisable(true);
}else{
ObservableList<BonReceptionFrs> ListBonReception = Facture.getListeBonReception();
TableViewBonReception.setItems(ListBonReception);
TableViewBonReception.refresh();
}
PaneFactureFrsDetail.setVisible(true);
AnchorPaneLoading.setVisible(false);
}
});
ThreadFactureFrsDetail.start();
}
}
@@ -0,0 +1,487 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Controllers.FactureFrs;
import Models.FactureFrs.FactureFrs;
import Models.FactureFrs.FactureFrsDB;
import Models.Fournisseur.FournisseurDB;
import Models.Stock.StockDB;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.ResourceBundle;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.concurrent.WorkerStateEvent;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableColumn.CellDataFeatures;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Text;
import javafx.util.Callback;
import org.controlsfx.control.textfield.TextFields;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class FactureFrsGestionController implements Initializable {
@FXML private AnchorPane AnchorPaneFactureFrsGestion ;
@FXML private ProgressBar ProgressBarFactureFrs;
@FXML private Button ButtonSearchFactureFrs;
@FXML public TableView<FactureFrs> TableViewBonReception;
@FXML public TableColumn<FactureFrs ,String> TabColNumero;
@FXML public TableColumn<FactureFrs ,String> TabColFrs;
@FXML public TableColumn<FactureFrs ,String> TabColDate;
@FXML public TableColumn<FactureFrs ,String> TabColHeur;
@FXML public TableColumn<FactureFrs ,String> TabColLocalReception;
@FXML public TableColumn<FactureFrs ,String> TabColNetPayer;
@FXML public TableColumn<FactureFrs ,Boolean>TabColDetail ;
@FXML public TextField TextFieldNumero ;
@FXML public TextField TextFieldFournisseur ;
@FXML public DatePicker DatePickerDateReception;
@FXML public ChoiceBox ChoiceBoxLocalReception ;
@FXML private Text ActuellePage ;
@FXML private Text NbrPage ;
@FXML private Group nextgroupe ;
@FXML private Group avancergroupe ;
@FXML private Group lastgroupe ;
@FXML private Group retourgroupe ;
@FXML private Label LabelCount;
@FXML private ChoiceBox NbrLigne ;
private Service<Void> ThreadSearchFactureFrs;
ObservableList cursors = FXCollections.observableArrayList("10","15","20");
private Integer nbrligne = 10 ;
private Integer totalcount = 0;
private Integer nbrpage = 0;
private Integer actuellepage = 1;
Integer position = 0;
String LocalReception = "";
String IdFournisseur = "";
public ArrayList<String> ListFournisseur = new ArrayList<>();
public ArrayList<String> ListLocale = new ArrayList<>();
DecimalFormat Formatter = new DecimalFormat("##,###.## ");
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
NbrLigne.setItems(cursors);
NbrLigne.getSelectionModel().selectFirst();
setDefaultFormData();
TabColNumero.setCellValueFactory(new PropertyValueFactory<FactureFrs, String>("Numero"));
TabColFrs.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColFrs.getStyleClass().add("Center");
TabColFrs.setCellValueFactory(new Callback<CellDataFeatures<FactureFrs,String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(CellDataFeatures<FactureFrs, String> data) {
return new SimpleStringProperty(data.getValue().getFournisseur().getNom());
}
});
TabColDate.setCellValueFactory(new PropertyValueFactory<FactureFrs, String>("DateCreation"));
TabColDate.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDate.getStyleClass().add("Center");
TabColHeur.setCellValueFactory(new PropertyValueFactory<FactureFrs, String>("HeurCreation"));
TabColHeur.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColHeur.getStyleClass().add("Center");
TabColLocalReception.setCellValueFactory(new PropertyValueFactory<FactureFrs, String>("Local"));
TabColLocalReception.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColLocalReception.getStyleClass().add("Center");
TabColNetPayer.setCellValueFactory(new PropertyValueFactory<FactureFrs, String>("NetAPayer"));
TabColNetPayer.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColNetPayer.getStyleClass().add("Center");
TabColNetPayer.setCellFactory(new Callback<TableColumn<FactureFrs,String>,TableCell<FactureFrs,String>>(){
@Override
public TableCell<FactureFrs, String> call(TableColumn<FactureFrs, String> param) {
TableCell<FactureFrs, String> cell = new TableCell<FactureFrs, String>(){
@Override
public void updateItem(String item, boolean empty) {
if(item!= null){
Text text = new Text(Formatter.format(Float.parseFloat(item)));
setGraphic(text);
}else{
setGraphic(null);
}
}
};
return cell;
}
});
TabColDetail.setStyle( "-fx-alignment: CENTER;");TabColDetail.getStyleClass().add("Center");
TabColDetail.setCellFactory(new Callback<TableColumn<FactureFrs, Boolean>, TableCell<FactureFrs, Boolean>>() {
@Override
public TableCell<FactureFrs, Boolean> call(TableColumn<FactureFrs, Boolean> personBooleanTableColumn) {
return new ButtonCell();
}
});
TextFieldFournisseur.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
if(newValue.contains(" - ")){
String[] array = newValue.split(" - ", -1);
IdFournisseur = array[0];
}
}
});
ChoiceBoxLocalReception.valueProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue ov, String t, String ValLocal) {
LocalReception = ValLocal;
}
});
ButtonSearchFactureFrs.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchFactureFrs();
}
});
AnchorPaneFactureFrsGestion.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchFactureFrs();
}
}
});
GestionSearchFactureFrs();
}
private class ButtonCell extends TableCell<FactureFrs, Boolean> {
final Button cellButton = new Button();
ButtonCell(){
cellButton.getStyleClass().add("btn-icon-primary");
Image coffeeImage = new Image(getClass().getResourceAsStream("/Public/icon/detailbutton.png"));
ImageView buttonGraphic = new ImageView();
buttonGraphic.setImage(coffeeImage);
cellButton.setGraphic(buttonGraphic);
cellButton.setOnAction(new EventHandler<ActionEvent>(){ //Action when the button is pressed
@Override
public void handle(ActionEvent t) {
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/FactureFrs/FactureFrsDetail.fxml"));
Parent ParentFxmlFournisseur = (Parent)fxmlLoader.load();
FactureFrs FournisseurList = ((FactureFrs)getTableRow().getItem());
FactureFrsDetailController FactureFrsDetail = fxmlLoader.getController();
FactureFrsDetail.setDataFactureDetailFrs(FournisseurList.getIdFactureFrs());
FactureFrsDetail.PaneSucessFrs.setVisible(false);
AnchorPaneFactureFrsGestion.getChildren().clear();
AnchorPaneFactureFrsGestion.getChildren().add(ParentFxmlFournisseur);
} catch (Exception ex) {
System.err.println("FactureFrsGestionController ButtonCell ! \n"+ex.getMessage());
}
}
});
}
//Display button if the row is not empty
@Override
protected void updateItem(Boolean t, boolean empty) {
if(!empty){
setGraphic(cellButton);
} else {
setGraphic(null);
}
}
}
@FXML
private void FactureFrsBonReceptionAjouterButtonAction(ActionEvent event) throws IOException {
AnchorPaneFactureFrsGestion.getChildren().clear();
AnchorPaneFactureFrsGestion.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/FactureFrs/FactureFrsBonReceptionAjouter.fxml")));
}
@FXML
private void FactureFrsAjouterButtonAction(ActionEvent event) throws IOException {
AnchorPaneFactureFrsGestion.getChildren().clear();
AnchorPaneFactureFrsGestion.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/FactureFrs/FactureFrsAjouter.fxml")));
}
private void setDefaultFormData()
{
ProgressBarFactureFrs.setVisible(true);
ThreadSearchFactureFrs = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
ListFournisseur = new FournisseurDB().getAllFournisseur("CONCAT(`id_fourisseur`,' - ',`nom`)");
TextFields.bindAutoCompletion(TextFieldFournisseur, ListFournisseur);
ListLocale = new StockDB().getAllListLocal();
ChoiceBoxLocalReception.getItems().addAll(ListLocale);
return null;
}
};
}
};
ThreadSearchFactureFrs.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarFactureFrs.setVisible(false);
}
});
ThreadSearchFactureFrs.start();
}
/****************************************************************************** *
* *
* Methode last Next TableView *
* * *
******************************************************************************/
private void SearchFactureFrs()
{
ProgressBarFactureFrs.setVisible(true);
ButtonSearchFactureFrs.setDisable(true);
ThreadSearchFactureFrs = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
position = 0;
actuellepage = 1;
String DateReception = "";
if(DatePickerDateReception.getValue() != null){
DateReception = DatePickerDateReception.getValue().toString();
}
ObservableList<FactureFrs> ListFactureFrss = new FactureFrsDB().SearchFactureFrsGestion(
position,
nbrligne,
TextFieldNumero.getText(),
IdFournisseur,
LocalReception,
DateReception);
TableViewBonReception.setItems(ListFactureFrss);
totalcount = new FactureFrsDB().nbrFactureFrsGestion(TextFieldNumero.getText(), IdFournisseur, LocalReception, DateReception);
if(totalcount > 0){
ActuellePage.setText("1");
}else{
ActuellePage.setText("0");
}
if(totalcount % nbrligne==0){
nbrpage = totalcount / nbrligne ;
}
else{
nbrpage = (totalcount / nbrligne) + 1 ;
}
NbrPage.setText(Integer.toString(nbrpage));
return null;
}
};
}
};
ThreadSearchFactureFrs.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarFactureFrs.setVisible(false);
ButtonSearchFactureFrs.setDisable(false);
LabelCount.setText(totalcount.toString());
}
});
ThreadSearchFactureFrs.start();
}
private void NextLastSearchFactureFrs(Integer ParmPosition, Integer ParamNbrligne)
{
ProgressBarFactureFrs.setVisible(true);
ButtonSearchFactureFrs.setDisable(true);
ThreadSearchFactureFrs = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
String DateReception = "";
if(DatePickerDateReception.getValue() != null){
DateReception = DatePickerDateReception.getValue().toString();
}
ObservableList<FactureFrs> ListFactureFrs = new FactureFrsDB().SearchFactureFrsGestion(ParmPosition, ParamNbrligne, TextFieldNumero.getText(), IdFournisseur, LocalReception, DateReception);
TableViewBonReception.setItems(ListFactureFrs);
return null;
}
};
}
};
ThreadSearchFactureFrs.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarFactureFrs.setVisible(false);
ButtonSearchFactureFrs.setDisable(false);
}
});
ThreadSearchFactureFrs.start();
}
private void GestionSearchFactureFrs()
{
NbrLigne.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
public void changed(ObservableValue ov, Number value, Number new_value) {
nbrligne= Integer.parseInt((String) cursors.get(new_value.intValue()));
if(totalcount % nbrligne==0){ nbrpage = totalcount / nbrligne ;}
else{ nbrpage = (totalcount / nbrligne) + 1 ; }
NbrPage.setText(Integer.toString(nbrpage));
position=0;
ActuellePage.setText("1");
actuellepage=1;
NextLastSearchFactureFrs(position, nbrligne);
}
});
if(totalcount % nbrligne==0){ nbrpage = totalcount / nbrligne ;}
else{ nbrpage = (totalcount / nbrligne) + 1 ; }
NbrPage.setText(Integer.toString(nbrpage));
//next page
nextgroupe.setOnMousePressed(new EventHandler<MouseEvent>(){
@Override
public void handle(MouseEvent event) {
if(actuellepage<nbrpage)
{
position=position+nbrligne;
NextLastSearchFactureFrs(position, nbrligne);
actuellepage=actuellepage+1 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
//last page
lastgroupe.setOnMousePressed(new EventHandler<MouseEvent>(){
@Override
public void handle(MouseEvent event) {
if(actuellepage>1)
{
position=position-nbrligne;
NextLastSearchFactureFrs(position, nbrligne);
actuellepage=actuellepage-1 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
//next page avec pas de 5
avancergroupe.setOnMousePressed(new EventHandler<MouseEvent>(){
@Override
public void handle(MouseEvent event) {
if(actuellepage+3<nbrpage)
{
position=(position+4)+nbrligne;
NextLastSearchFactureFrs(position, nbrligne);
actuellepage=actuellepage+3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
//last page avec un pas de -5
retourgroupe.setOnMousePressed(new EventHandler<MouseEvent>(){
@Override
public void handle(MouseEvent event) {
if(actuellepage-3>1){
position=(position-4)-nbrligne;
NextLastSearchFactureFrs(position, nbrligne);
actuellepage=actuellepage-3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
}
}