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
+1
View File
@@ -0,0 +1 @@
2024-12-25 17:20:33 ERROR App:26 - Error message
+40
View File
@@ -0,0 +1,40 @@
package Controllers;
import Controllers.Traitement.MyWindow;
import Controllers.Traitement.ParametreSystem;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
import org.apache.log4j.xml.DOMConfigurator;
/**
* JavaFX App
*/
public class App extends Application {
@Override
public void start(Stage stage) throws IOException {
DOMConfigurator.configure("./conf/log4j.xml");
ParametreSystem parametre = new ParametreSystem();
parametre.SetParametre();
MyWindow.NewMyStage();
MyWindow.setMyParent((Parent) FXMLLoader.load(getClass().getResource("/Views/Authentification.fxml")));
Scene scene = new Scene(MyWindow.myParent);
MyWindow.myStage.setScene(scene);
MyWindow.myStage.show();
}
public static void main(String[] args) {
launch();
}
}
@@ -0,0 +1,197 @@
package Controllers;
import Controllers.Traitement.MyWindow;
import Controllers.Traitement.ParametreSystem;
import Models.User.Profile;
import Models.User.ProfileDB;
import Models.User.User;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
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.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Text;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
public class AuthentificationController implements Initializable{
@FXML
private Text Erreurresult;
@FXML
private Label label;
@FXML
private TextField Login;
@FXML
private PasswordField Password;
@FXML
private AnchorPane Content;
@FXML
private ImageView ImageViewLogo;
@FXML
private ProgressBar ProgressBarAuthentification;
private Service<Void> ThreadAuthentification;
Profile profile;
@Override
public void initialize(URL url, ResourceBundle rb) {
Content.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
Connexion();
}
}
});
setImageLogo();
}
@FXML
private void handleButtonAction(ActionEvent event) throws IOException {
this.Connexion();
}
private void Connexion()
{
Erreurresult.setText(null);
Login.setStyle("-fx-border-color: transparent;");
Login.setStyle("-fx-border-color: transparent;");
String login=Login.getText();
String password=Password.getText();
if(login.length()==0){
Erreurresult.setText(null);
Erreurresult.setText("champ login vide.");
Login.setStyle("-fx-border-color:#ff0000;");
}
else if(password.length()==0){
Erreurresult.setText(null);
Erreurresult.setText("champ password vide.");
Password.setStyle("-fx-border-color:#ff0000;");
}
else{
Login.setStyle("-fx-border-color: transparent;");
Password.setStyle("-fx-border-color: transparent;");
ProgressBarAuthentification.setVisible(true);
ThreadAuthentification = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
profile = new ProfileDB().getProfileByConnexion(login, password);
return null;
}
};
}
};
ThreadAuthentification.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
if(profile.getIdprofile() > 0){
User.idprofile= profile.getIdprofile();
User.nom = profile.getNom();
User.prenom=profile.getPrenom();
User.UserLocal=profile.getAuthentification().getLocalNom();
User.SotckNegatif= profile.getAuthentification().isStockNegatif();
if(ParametreSystem.NomLocalPC.equals(profile.getAuthentification().getLocalNom())){
//Fermer la fenétre de authentification
//((Node)(event.getSource())).getScene().getWindow().hide();
Content.getScene().getWindow().hide();
MyWindow.NewMyStage();
try {
MyWindow.setMyParent((Parent) FXMLLoader.load(getClass().getResource("/Views/Principal.fxml")));
Scene scene = new Scene(MyWindow.myParent);
MyWindow.myStage.setScene(scene);
MyWindow.myStage.show();
} catch (IOException ex) {
Logger.getLogger(AuthentificationController.class.getName()).log(Level.SEVERE, null, ex);
}
}else{
//Fermer la fenétre de authentification else{
Erreurresult.setText("Accès interdit a ce locale");
}
}else{
Erreurresult.setText("Login ou password est incorrect");
}
ProgressBarAuthentification.setVisible(false);
}
});
ThreadAuthentification.start();
}
}
private void setImageLogo()
{
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
// optional, but recommended
// process XML securely, avoid attacks like XML External Entities (XXE)
dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
// parse XML file
DocumentBuilder db = dbf.newDocumentBuilder();
//PowerERP\conf\logo.xml
Document doc = db.parse(new File("./conf/logo.xml"));
doc.getDocumentElement().normalize();
Element elementCNX = (Element) doc.getElementsByTagName("Connexion").item(0);
String pathLogo = elementCNX.getElementsByTagName("PathImage").item(0).getTextContent();
FileInputStream fis = new FileInputStream(pathLogo);
ImageViewLogo.setImage(new Image(fis));
ImageViewLogo.setFitWidth(Double.parseDouble(elementCNX.getElementsByTagName("FitWidth").item(0).getTextContent()));
ImageViewLogo.setFitHeight(Double.parseDouble(elementCNX.getElementsByTagName("FitHeight").item(0).getTextContent()));
ImageViewLogo.setLayoutX(Double.parseDouble(elementCNX.getElementsByTagName("LayoutX").item(0).getTextContent()));
ImageViewLogo.setLayoutY(Double.parseDouble(elementCNX.getElementsByTagName("LayoutY").item(0).getTextContent()));
}
catch (ParserConfigurationException | SAXException | IOException e) {
System.out.println("error AuthentificationController/setImageLogo "+e.getMessage());
}
}
}
@@ -0,0 +1,409 @@
package Controllers.BonLivraisonClt;
import Models.CommandeClt.CommandeCltDB;
import Models.CommandeClt.CommandeCltListe;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
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.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.RadioButton;
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.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;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class BonLivraisonCltAjouterController implements Initializable {
@FXML private AnchorPane AnchorPaneBLCltAjouterEtape1;
@FXML private ProgressBar ProgressBarBLCltAjouter;
@FXML private Button ButtonSearchBLCltAjouter;
@FXML public TableView<CommandeCltListe> TableViewCommande;
@FXML public TableColumn<CommandeCltListe ,String> TabColCodeCommande;
@FXML public TableColumn<CommandeCltListe ,String> TabColModePaiement;
@FXML public TableColumn<CommandeCltListe ,String> TabColTypeClient;
@FXML public TableColumn<CommandeCltListe ,String> TabColCodeClient;
@FXML public TableColumn<CommandeCltListe ,String> TabColTotalCommande;
@FXML public TableColumn<CommandeCltListe ,String> TabColDateCreation ;
@FXML public TableColumn<CommandeCltListe ,String> TabColCodeDevis;
@FXML public TableColumn<CommandeCltListe ,Boolean>TabColAction ;
@FXML public TextField TextFieldCodeCommande;
@FXML public DatePicker DatePickerCreation;
@FXML public RadioButton RadioComptant;
@FXML public RadioButton RadioFacilite;
@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> ThreadSearchBLCltAjouter;
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;
@Override
public void initialize(URL url, ResourceBundle rb) {
NbrLigne.setItems(cursors);
NbrLigne.getSelectionModel().selectFirst();
TableViewCommande.setEditable(true);
TabColCodeCommande.setStyle( "-fx-alignment: CENTER;");TabColCodeCommande.getStyleClass().add("Center");
TabColCodeCommande.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("CodeCommande"));
TabColTypeClient.setStyle( "-fx-alignment: CENTER;");TabColTypeClient.getStyleClass().add("Center");
TabColTypeClient.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("TypeClient"));
TabColCodeClient.setStyle( "-fx-alignment: CENTER;");TabColCodeClient.getStyleClass().add("Center");
TabColCodeClient.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("CodeClient"));
TabColModePaiement.setStyle( "-fx-alignment: CENTER;");TabColModePaiement.getStyleClass().add("Center");
TabColModePaiement.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("ModePaiement"));
TabColTotalCommande.setStyle( "-fx-alignment: CENTER;");TabColTotalCommande.getStyleClass().add("Center");
TabColTotalCommande.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("TotalCommande"));
TabColDateCreation.setStyle( "-fx-alignment: CENTER;");TabColDateCreation.getStyleClass().add("Center");
TabColDateCreation.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("DateCreation"));
TabColCodeDevis.setStyle( "-fx-alignment: CENTER;");TabColCodeDevis.getStyleClass().add("Center");
TabColCodeDevis.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("CodeDevis"));
TabColAction.setSortable(true);
TabColAction.setStyle( "-fx-alignment: CENTER;");TabColAction.getStyleClass().add("Center");
TabColAction.setCellFactory(new Callback<TableColumn<CommandeCltListe, Boolean>, TableCell<CommandeCltListe, Boolean>>() {
@Override
public TableCell<CommandeCltListe, Boolean> call(TableColumn<CommandeCltListe, Boolean> personBooleanTableColumn) {
return new BonLivraisonCltAjouterController.ButtonCell();
}
});
ButtonSearchBLCltAjouter.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchBLCltAjouter();
}
});
AnchorPaneBLCltAjouterEtape1.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchBLCltAjouter();
}
}
});
RadioComptant.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchBLCltAjouter();
}
});
RadioFacilite.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchBLCltAjouter();
}
});
GestionSearchBLCltAjouter();
}
private class ButtonCell extends TableCell<CommandeCltListe, Boolean> {
final Button cellButton = new Button();
ButtonCell(){
cellButton.getStyleClass().add("btn-icon-primary");
Image coffeeImage = new Image(getClass().getResourceAsStream("/Public/icon/iconedit.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 {
CommandeCltListe current = (CommandeCltListe) ButtonCell.this.getTableView().getItems().get(ButtonCell.this.getIndex());
String CodeCommande = current.getCodeCommande();
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/BonLivraisonClt/BonLivraisonCltAjouterEtape2.fxml"));
Parent NodeBonLivraisonCltAjouterEtape2 = (Parent)fxmlLoader.load();
BonLivraisonCltAjouterEtape2Controller BonLivraisonCltAjouterEtape2= fxmlLoader.getController();
AnchorPaneBLCltAjouterEtape1.getChildren().clear();
AnchorPaneBLCltAjouterEtape1.getChildren().add(NodeBonLivraisonCltAjouterEtape2);
BonLivraisonCltAjouterEtape2.SetDataCommandeClt(CodeCommande);
} catch (IOException ex) {
Logger.getLogger(BonLivraisonCltAjouterController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
//Display button if the row is not empty
@Override
protected void updateItem(Boolean t, boolean empty) {
if(!empty){
setGraphic(cellButton);
} else {
setGraphic(null);
}
}
}
/****************************************************************************** *
* *
* Methode last Next TableView *
* * *
******************************************************************************/
private void SearchBLCltAjouter()
{
ProgressBarBLCltAjouter.setVisible(true);
ButtonSearchBLCltAjouter.setDisable(true);
ThreadSearchBLCltAjouter = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
position = 0;
actuellepage = 1;
String DateCreation = "";
if(DatePickerCreation.getValue() != null){
DateCreation = DatePickerCreation.getValue().toString();
}
// 0comptant 1facilité
String TypeRegement = "";
if(RadioComptant.isSelected()){
TypeRegement = "0";
}else if(RadioFacilite.isSelected()){
TypeRegement = "1";
}
ObservableList<CommandeCltListe> ListBLCltAjouters = new CommandeCltDB().SearchCommandeCltNotBonLivrison(
position,
nbrligne,
TextFieldCodeCommande.getText(),
DateCreation,
TypeRegement);
TableViewCommande.setItems(ListBLCltAjouters);
totalcount = new CommandeCltDB().nbrCommandeCltNotBonLivrison(TextFieldCodeCommande.getText(), DateCreation, TypeRegement);
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;
}
};
}
};
ThreadSearchBLCltAjouter.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarBLCltAjouter.setVisible(false);
ButtonSearchBLCltAjouter.setDisable(false);
LabelCount.setText(totalcount.toString());
}
});
ThreadSearchBLCltAjouter.start();
}
private void NextLastSearchBLCltAjouter(Integer ParmPosition, Integer ParamNbrligne)
{
ProgressBarBLCltAjouter.setVisible(true);
ButtonSearchBLCltAjouter.setDisable(true);
ThreadSearchBLCltAjouter = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
String DateCreation = "";
if(DatePickerCreation.getValue() != null){
DateCreation = DatePickerCreation.getValue().toString();
}
// 0comptant 1facilité
String TypeRegement = "";
if(RadioComptant.isSelected()){
TypeRegement = "0";
}else if(RadioFacilite.isSelected()){
TypeRegement = "1";
}
ObservableList<CommandeCltListe> ListBLCltAjouters = new CommandeCltDB().SearchCommandeCltNotBonLivrison(ParmPosition, ParamNbrligne, TextFieldCodeCommande.getText(), DateCreation, TypeRegement);
TableViewCommande.setItems(ListBLCltAjouters);
return null;
}
};
}
};
ThreadSearchBLCltAjouter.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarBLCltAjouter.setVisible(false);
ButtonSearchBLCltAjouter.setDisable(false);
}
});
ThreadSearchBLCltAjouter.start();
}
private void GestionSearchBLCltAjouter()
{
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;
NextLastSearchBLCltAjouter(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;
NextLastSearchBLCltAjouter(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;
NextLastSearchBLCltAjouter(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;
NextLastSearchBLCltAjouter(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;
NextLastSearchBLCltAjouter(position, nbrligne);
actuellepage=actuellepage-3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
}
}
@@ -0,0 +1,299 @@
/*
* 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.BonLivraisonClt;
import Controllers.Dialog.Dialog;
import Controllers.Traitement.Adaptateur;
import Models.Produit.ListeProduit;
import Controllers.Traitement.contro;
import Models.BonLivraisonClt.BonLivraisonClt;
import Models.BonLivraisonClt.BonLivraisonCltDB;
import Models.BonLivraisonClt.BonLivraisonCltProduitList;
import Models.CommandeClt.CommandeClt;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.text.Text;
import Models.Client.Client;
import Models.Client.ClientEntreprise;
import Models.Client.ClientPassager;
import Models.CommandeClt.CommandeCltDB;
import java.io.IOException;
import java.time.LocalDate;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.control.DatePicker;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.AnchorPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.util.Callback;
/**
* FXML Controller class
*
* @author Maher
*/
public class BonLivraisonCltAjouterEtape2Controller implements Initializable {
@FXML private AnchorPane AnchorPaneBLCltAjouterEtape2;
@FXML private Text TextType;
@FXML private Text TextCode;
@FXML private Text TextNom;
@FXML private Text TextPrenom;
@FXML private Text TextAdresse;
@FXML private Text TextDateNaissance;
@FXML private Text TextTele1;
@FXML private Text TextTele2;
@FXML private Text TxtPrenom;
@FXML private Text TxtDateNaissance;
@FXML public TableView<BonLivraisonCltProduitList> TableViewBonLivraisonCltProduitList;
@FXML public TableColumn<BonLivraisonCltProduitList ,String> TabColReference;
@FXML public TableColumn<BonLivraisonCltProduitList ,String> TabColDesignation ;
@FXML public TableColumn<BonLivraisonCltProduitList ,String> TabColMarque;
@FXML public TableColumn<BonLivraisonCltProduitList ,String> TabColCategorie;
@FXML public TableColumn<BonLivraisonCltProduitList ,String> TabColProdDisponible;
@FXML public TableColumn<BonLivraisonCltProduitList ,String> TabColQuantite;
@FXML public TableColumn<BonLivraisonCltProduitList ,String> TabColPrixTTC;
@FXML private TextField TextFieldHeurLivraison ;
@FXML private TextField TextFieldNumTele1 ;
@FXML private TextField TextFieldNumTele2 ;
@FXML private TextField TextFieldTransporteur ;
@FXML private TextField TextFieldPoidProduit;
@FXML private DatePicker DatePickerDateLivraison;
@FXML private TextArea TextAreaAdressLivraison;
@FXML private TextField TextFieldFraisTransport ;
ObservableList<BonLivraisonCltProduitList> ObservableListBLCltPro = FXCollections.observableArrayList();
BonLivraisonClt BonLivraison = new BonLivraisonClt();
Text Txt = new Text();
contro clt = new contro();
public CommandeClt Commande;
boolean DisponibleProduit = true;
@Override
public void initialize(URL url, ResourceBundle rb) {
TabColReference.setCellValueFactory(new PropertyValueFactory<BonLivraisonCltProduitList, String>("Reference"));
TabColDesignation.setCellValueFactory(new PropertyValueFactory<BonLivraisonCltProduitList, String>("Designation"));
TabColMarque.setCellValueFactory(new PropertyValueFactory<BonLivraisonCltProduitList, String>("Marque"));
TabColCategorie.setCellValueFactory(new PropertyValueFactory<BonLivraisonCltProduitList, String>("Categorie"));
TabColProdDisponible.setCellValueFactory(new PropertyValueFactory<BonLivraisonCltProduitList, String>("ProdDisponible"));
TabColProdDisponible.setStyle( "-fx-alignment: CENTER;");
TabColProdDisponible.getStyleClass().add("Center");
TabColQuantite.setStyle( "-fx-alignment: CENTER;");
TabColQuantite.getStyleClass().add("Center");
TabColQuantite.setCellValueFactory(new PropertyValueFactory<BonLivraisonCltProduitList, String>("QuantiteProd"));
TabColPrixTTC.setStyle( "-fx-alignment: CENTER;");
TabColPrixTTC.getStyleClass().add("Center");
TabColPrixTTC.setCellValueFactory(new PropertyValueFactory<BonLivraisonCltProduitList, String>("PrixTTC"));
TabColProdDisponible.setCellFactory(new Callback<TableColumn<BonLivraisonCltProduitList,String>,TableCell<BonLivraisonCltProduitList,String>>(){
@Override
public TableCell<BonLivraisonCltProduitList, String> call(TableColumn<BonLivraisonCltProduitList, String> param) {
TableCell<BonLivraisonCltProduitList, String> cell = new TableCell<BonLivraisonCltProduitList, String>(){
@Override
public void updateItem(String item, boolean empty) {
if(item!= null && item.equals("1")){
Text text = new Text("Oui");
text.setFill(Color.web("#428BCA"));
text.setFont(Font.font("Arial", FontWeight.BOLD, 14));
setGraphic(text);
}else if(item!= null && item.equals("0")){
DisponibleProduit = false;
Text text = new Text("Non");
text.setFill(Color.web("#EA4335"));
text.setFont(Font.font("Arial", FontWeight.BOLD, 14));
setGraphic(text);
}else{
setGraphic(null);
}
}
};
return cell;
}
});
TextFieldFraisTransport.setText("0");
}
@FXML
private void CreateBonLivraisonCltButtonAction(ActionEvent event) throws IOException {
if( clt.ContrNumerique(TextFieldNumTele1, Txt) &&
clt.ContrNumerique(TextFieldNumTele2, Txt) &&
clt.ContrNumerique(TextFieldPoidProduit, Txt) &&
clt.ContrNull(TextAreaAdressLivraison, Txt)&&
clt.ContrHour(TextFieldHeurLivraison, Txt) ){
if(DisponibleProduit){
NextEtap();
}else{
final Dialog MyDialog= new Dialog();
Node node = MyDialog.DialogNotification();
MyDialog.Titre.setText("Attention produit non disponible en stock");
MyDialog.Message.setText("Lorsque vous cliquez sur Valider votre stock sera négative");
MyDialog.DefaultAnnuler();
MyDialog.Valider.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
MyDialog.PaneDialog.setVisible(false);
NextEtap();
}
});
MyDialog.Show(node);
}
}
}
public void SetBonLivraision(){
BonLivraison.setTele1(TextFieldNumTele1.getText());
BonLivraison.setTele2(TextFieldNumTele2.getText());
BonLivraison.setHeurLivraison(TextFieldHeurLivraison.getText());
if(DatePickerDateLivraison.getValue()!=null){
BonLivraison.setDateLivraisonPreveu(DatePickerDateLivraison.getValue().toString());
}
BonLivraison.setTransporteur(TextFieldTransporteur.getText());
BonLivraison.setPoidProduit(TextFieldPoidProduit.getText());
BonLivraison.setAdresseLivraison(TextAreaAdressLivraison.getText());
BonLivraison.setFrais(TextFieldFraisTransport.getText());
if(clt.isNumericNotnull(TextFieldFraisTransport.getText())){
float PayerAFraisT = Adaptateur.StringToFloat(BonLivraison.getNetAPayer());
float FraisTransport = Adaptateur.StringToFloat(TextFieldFraisTransport.getText());
float NetAPayer = PayerAFraisT + FraisTransport;
BonLivraison.setNetAPayer(Adaptateur.floatDeleZero(NetAPayer));
}
}
public void NextEtap(){
try {
ConvertCommandeToBonLivraision();
SetBonLivraision();
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/BonLivraisonClt/BonLivraisonCltAjouterEtape3.fxml"));
Parent NodeBonLivraisonCltAjouterEtape3 = (Parent)fxmlLoader.load();
BonLivraisonCltAjouterEtape3Controller BonLivraisonCltAjouterEtape3= fxmlLoader.getController();
BonLivraisonCltAjouterEtape3.BonLivraisonStep2ToStep3(BonLivraison, Commande.getCodecommandeclt());
AnchorPaneBLCltAjouterEtape2.getChildren().clear();
AnchorPaneBLCltAjouterEtape2.getChildren().add(NodeBonLivraisonCltAjouterEtape3);
} catch (IOException ex) {
Logger.getLogger(BonLivraisonCltAjouterEtape2Controller.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void ConvertCommandeToBonLivraision(){
BonLivraison.setIdCommande(Commande.getCodecommandeclt());
//0 Personne 1 Entreprise 2 Passager
Integer TypeClt = Commande.getTypeClient();
BonLivraison.setTypeClient(TypeClt);
if(TypeClt == 0){
BonLivraison.setCltPersonne(Commande.getCltPersonne());
BonLivraison.setAdresseLivraison(Commande.CltPersonne.getAdresse());
}else if(TypeClt == 1){
BonLivraison.setCltEntreprise(Commande.getCltEntreprise());
BonLivraison.setAdresseLivraison(Commande.CltEntreprise.getAdresse());
}else if(TypeClt == 2){
BonLivraison.setCltPassager(Commande.getCltPassager());
BonLivraison.setAdresseLivraison(Commande.CltPassager.getAdresse());
}
BonLivraison.setListeproduit(Commande.getListeproduit());
BonLivraison.setTotalHorsTaxNet(Commande.getTotalHorsTaxNet());
BonLivraison.setTotalTVA(Commande.getTotalTVA());
BonLivraison.setRemise(Commande.getRemise());
BonLivraison.setNetAPayer(Commande.getNetAPayer());
}
public void SetDataCommandeClt(String CodeCommande){
CommandeCltDB CommandeDB= new CommandeCltDB();
Commande = CommandeDB.getCommandeClt(CodeCommande);
Integer TypeClient = Commande.getTypeClient();
if(TypeClient == 0){
Client Personne= Commande.getCltPersonne();
TextType.setText("ancien client");
TextCode.setText(Personne.getCodeclient());
TextNom.setText(Personne.getNom());
TextPrenom.setText(Personne.getPrenom());
TextAdresse.setText(Personne.getAdresse());
TextAreaAdressLivraison.setText(Personne.getAdresse());
TextDateNaissance.setText(Adaptateur.NormalDateFormat(Personne.getNaissance().toString()));
TextTele1.setText(Personne.getTelefixString());
TextTele2.setText(Personne.getTelemobileString());
TextFieldNumTele1.setText(Personne.getTelefixString());
TextFieldNumTele2.setText(Personne.getTelemobileString());
}else if(TypeClient == 1){
ClientEntreprise Entreprise = Commande.getCltEntreprise();
TextType.setText("Entrepise");
TextCode.setText(Entreprise.getCodeString());
TxtPrenom.setText("Matricule");
TextPrenom.setText(Entreprise.getMatricule());
TxtDateNaissance.setText("E-Mail");
TextDateNaissance.setText(Entreprise.getMail());
TextNom.setText(Entreprise.getNom());
TextAdresse.setText(Entreprise.getAdresse());
TextAreaAdressLivraison.setText(Entreprise.getAdresse());
TextTele1.setText(Entreprise.getTele1String());
TextTele2.setText(Entreprise.getTele2String());
TextFieldNumTele1.setText(Entreprise.getTele1String());
TextFieldNumTele2.setText(Entreprise.getTele2String());
}else if(TypeClient == 2){
ClientPassager Passager = Commande.getCltPassager();
TextType.setText("Passager");
TextCode.setText(Passager.getCodeclient());
TextNom.setText(Passager.getNom());
TextPrenom.setText(Passager.getPrenom());
TextAdresse.setText(Passager.getAdresse());
TextAreaAdressLivraison.setText(Passager.getAdresse());
TextDateNaissance.setText(Passager.getNaissance());
TextTele1.setText(Passager.getTelefixString());
TextTele2.setText(Passager.getTelemobileString());
TextFieldNumTele1.setText(Passager.getTelefixString());
TextFieldNumTele2.setText(Passager.getTelemobileString());
}
DatePickerDateLivraison.setValue(LocalDate.now());
SetDataListeproduit();
}
public void SetDataListeproduit(){
ObservableList<ListeProduit> DataListeproduit = Commande.getListeproduit();
BonLivraisonCltDB BonLivraisonDB= new BonLivraisonCltDB();
ObservableListBLCltPro = BonLivraisonDB.GetListBonLivraisonCltSotck(DataListeproduit);
TableViewBonLivraisonCltProduitList.setItems(ObservableListBLCltPro);
}
}
@@ -0,0 +1,81 @@
/*
* 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.BonLivraisonClt;
import Models.BonLivraisonClt.BonLivraisonClt;
import Models.BonLivraisonClt.BonLivraisonCltDB;
import Models.CommandeClt.CommandeCltDB;
import java.net.URL;
import java.util.ResourceBundle;
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.ProgressIndicator;
import javafx.scene.image.ImageView;
import javafx.scene.layout.GridPane;
import javafx.scene.text.Text;
/**
*
* @author Maher
*/
public class BonLivraisonCltAjouterEtape3Controller implements Initializable {
@FXML public ProgressIndicator ProgressBonLivraion;
@FXML public ImageView ImageBonLivraion;
@FXML public GridPane GridPaneBonLivraion;
@FXML public Text TextBonLivraion;
BonLivraisonClt BonLivraison = new BonLivraisonClt();
BonLivraisonCltDB BonLivraisonDB = new BonLivraisonCltDB();
private String IdBonLivraison;
private String CodeCommandeclt;
private Service<Void> ThreadBonLivraison;
@Override
public void initialize(URL url, ResourceBundle rb) {
}
public void BonLivraisonStep2ToStep3(BonLivraisonClt bon_livraison_clt, String code_commandeclt){
BonLivraison = bon_livraison_clt;
CodeCommandeclt = code_commandeclt;
LanchSaveBonLivraison();
}
public void LanchSaveBonLivraison(){
ThreadBonLivraison = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call(){
IdBonLivraison = BonLivraisonDB.AddBonLivraisonClt(BonLivraison);
new CommandeCltDB().UpdateCommandeCltSetIdBonLivraison(CodeCommandeclt, IdBonLivraison);
return null;
}
};
}
};
ThreadBonLivraison.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBonLivraion.setVisible(false);
TextBonLivraion.setText("La bon livraison numéro "+IdBonLivraison+" a été enregistrés avec succès");
ImageBonLivraion.setVisible(true);
//GridPaneBonLivraion.setVisible(true);
}
});
ThreadBonLivraison.start();
}
}
@@ -0,0 +1,347 @@
package Controllers.BonLivraisonClt;
import Controllers.Traitement.MyWindow;
import Models.BonLivraisonClt.BonLivraisonClt;
import Models.BonLivraisonClt.BonLivraisonCltDB;
import Models.Produit.ListeProduit;
import Models.User.Profile;
import Models.User.ProfileDB;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Platform;
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.print.PageRange;
import javafx.print.PrinterJob;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Control;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.util.Callback;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class BonLivraisonCltDetailController{
@FXML private TableView<ListeProduit> TableViewListeProduit ;
@FXML private TableColumn<ListeProduit ,String> TabColReference;
@FXML private TableColumn<ListeProduit ,String> TabColDesignation;
@FXML private TableColumn<ListeProduit ,String> TabColQuantite ;
@FXML private TableColumn<ListeProduit ,String> TabColPrixHT;
@FXML private TableColumn<ListeProduit ,String> TabColRemise;
@FXML private TableColumn<ListeProduit ,String> TabColTotalHT;
@FXML private TableColumn<ListeProduit ,String> TabColTVA;
@FXML private TableColumn<ListeProduit ,String> TabColTotalTTC;
@FXML private TableView<ListeProduit> TableViewListeProduitTempo ;
@FXML private TableColumn<ListeProduit ,String> TabColReferenceTempo;
@FXML private TableColumn<ListeProduit ,String> TabColDesignationTempo;
@FXML private TableColumn<ListeProduit ,String> TabColQuantiteTempo ;
@FXML private TableColumn<ListeProduit ,String> TabColPrixHTTempo;
@FXML private TableColumn<ListeProduit ,String> TabColRemiseTempo;
@FXML private TableColumn<ListeProduit ,String> TabColTotalHTTempo;
@FXML private TableColumn<ListeProduit ,String> TabColTVATempo;
@FXML private TableColumn<ListeProduit ,String> TabColTotalTTCTempo;
@FXML public AnchorPane AnchorPrincipal ;
@FXML public AnchorPane AnchorSecondaire ;
@FXML private ProgressIndicator ProgressBonLivraion ;
@FXML public Text TextIdBonLivraison ;
@FXML private Text TextTypeClt ;
@FXML private Text TextNom ;
@FXML private Text TextPrenom ;
@FXML private Text TextAdressClt ;
@FXML private Text TextDateCreation ;
@FXML private Text TextLocale ;
@FXML private Text TextNomPrenomProfile ;
@FXML private Text TextHeurLivraison ;
@FXML private Text TextDateLivraison ;
@FXML private Text TextTransporteur ;
@FXML private Text TextFraisLivraison ;
@FXML private Text TextAdressLivraison ;
private Service<Void> ThreadBonLivraison;
public Node nodeFxml;
public String IdBonLivraison;
ObservableList<Map<String, Object>> items = FXCollections.<Map<String, Object>>observableArrayList();
int TotalHeightPage = 0;
BonLivraisonClt BonLivraison = new BonLivraisonClt();
Profile profile = new Profile();
public BonLivraisonCltDetailController(){
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/BonLivraisonClt/BonLivraisonCltDetail.fxml"));
fxmlLoader.setController(this);
nodeFxml = (Node) fxmlLoader.load();
} catch (IOException ex) {
Logger.getLogger(BonLivraisonCltDetailController.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void SetIdBonLivraison(String id_bon_livraison){
IdBonLivraison = id_bon_livraison;
TableViewListeProduit.setEditable(true);
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");
TabColReference.setCellFactory(TextFieldTableCell.<ListeProduit>forTableColumn());
TabColQuantite.setCellFactory(TextFieldTableCell.<ListeProduit>forTableColumn());
TabColRemise.setCellFactory(TextFieldTableCell.<ListeProduit>forTableColumn());
initializeTempo();
LanchBonLivraison();
}
public void LanchBonLivraison(){
ThreadBonLivraison = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
BonLivraison = new BonLivraisonCltDB().GetBonLivraisonClt(IdBonLivraison);
profile = new ProfileDB().getpro(Integer.parseInt(BonLivraison.getIdProfileEditeur()));
return null;
}
};
}
};
ThreadBonLivraison.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
TextIdBonLivraison.setText(BonLivraison.getIdBonLivrasionClt());
//0 Personne 1 Entreprise 2 Passager
if(BonLivraison.getTypeClient() == 0){
TextTypeClt.setText("Ancien client") ;
TextNom.setText(BonLivraison.CltPersonne.getNom()) ;
TextPrenom.setText(BonLivraison.CltPersonne.getPrenom()) ;
TextAdressClt.setText(BonLivraison.CltPersonne.getAdresse());
}else if(BonLivraison.getTypeClient() == 1){
TextTypeClt.setText("Entreprise") ;
TextNom.setText(BonLivraison.CltEntreprise.getNom()) ;
TextPrenom.setText(BonLivraison.CltEntreprise.getMatricule()) ;
TextAdressClt.setText(BonLivraison.CltEntreprise.getAdresse());
}else if(BonLivraison.getTypeClient() == 2){
TextTypeClt.setText("Passager") ;
TextNom.setText(BonLivraison.CltPassager.getNom()) ;
TextPrenom.setText(BonLivraison.CltPassager.getPrenom()) ;
TextAdressClt.setText(BonLivraison.CltPassager.getAdresse());
}
TextNomPrenomProfile.setText(profile.getNom()+" "+profile.getPrenom()) ;
TextDateCreation.setText(BonLivraison.getDateCreation()) ;
TextLocale.setText(BonLivraison.getLocalNom()) ;
TextHeurLivraison.setText(BonLivraison.getHeurLivraison()) ;
TextDateLivraison.setText(BonLivraison.getDateLivraisonPreveu()) ;
TextTransporteur.setText(BonLivraison.getTransporteur()) ;
TextFraisLivraison.setText(BonLivraison.getFrais()) ;
TextAdressLivraison.setText(BonLivraison.getAdresseLivraison()) ;
ObservableList<ListeProduit> DataListeProduit = BonLivraison.getListeproduit();
TableViewListeProduit.setItems(DataListeProduit);
TableViewListeProduitTempo.setItems(DataListeProduit);
ProgressBonLivraion.setVisible(false);
AnchorSecondaire.setVisible(true);
}
});
ThreadBonLivraison.start();
}
public void Show()
{
StackPane Sp = new StackPane();
Scene scene = new Scene(Sp);
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Stage stage = MyWindow.myStage;
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(nodeFxml);
stage.setScene(scene);
stage.show();
}
@FXML
private void ExitButtonAction(ActionEvent event) throws IOException {
AnchorPrincipal.setVisible(false);
}
@FXML
private void PDFBonLivraisonCltButtonAction(ActionEvent event) throws IOException {
}
private void initializeTempo()
{
TabColReferenceTempo.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("reference"));
TabColReferenceTempo.setStyle( "-fx-alignment: CENTER;");
TabColReferenceTempo.getStyleClass().add("Center");
TabColDesignationTempo.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("designation"));
TabColDesignationTempo.setCellFactory(new Callback<TableColumn<ListeProduit,String>,TableCell<ListeProduit,String>>(){
@Override
public TableCell<ListeProduit, String> call(TableColumn<ListeProduit, String> param) {
TableCell<ListeProduit, String> cell = new TableCell<ListeProduit, String>(){
@Override
public void updateItem(String item, boolean empty) {
if (item == null) {
super.setText(null);
super.setGraphic(null);
} else {
String newItem = item.trim().toLowerCase();
Text text = new Text(newItem);
super.setPrefHeight(Control.USE_COMPUTED_SIZE);
text.wrappingWidthProperty().bind(super.widthProperty());
super.setGraphic(text);
Platform.runLater(new Runnable() {
@Override
public void run() {
int selectdIndex = getTableRow().getIndex();
if(selectdIndex>=0){
Map<String, Object> item1 = new HashMap<>();
item1.put("produit", (ListeProduit) getTableRow().getItem());
item1.put("designation", newItem);
item1.put("height", text.getBoundsInLocal().getHeight());
items.add(item1);
TotalHeightPage += text.getBoundsInLocal().getHeight();
}
}
});
}
}
};
return cell;
}
});
TabColQuantiteTempo.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("quantite"));
TabColQuantiteTempo.setStyle( "-fx-alignment: CENTER;");
TabColQuantiteTempo.getStyleClass().add("Center");
TabColPrixHTTempo.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("PrixHT"));
TabColPrixHTTempo.setStyle( "-fx-alignment: CENTER;");
TabColPrixHTTempo.getStyleClass().add("Center");
TabColRemiseTempo.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("Remise"));
TabColRemiseTempo.setStyle( "-fx-alignment: CENTER;");
TabColRemiseTempo.getStyleClass().add("Center");
TabColTotalHTTempo.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("TotalHT"));
TabColTotalHTTempo.setStyle( "-fx-alignment: CENTER;");
TabColTotalHTTempo.getStyleClass().add("Center");
TabColTVATempo.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("TVA"));
TabColTVATempo.setStyle( "-fx-alignment: CENTER;");
TabColTVATempo.getStyleClass().add("Center");
TabColTotalTTCTempo.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("TotalTTC"));
TabColTotalTTCTempo.setStyle( "-fx-alignment: CENTER;");
TabColTotalTTCTempo.getStyleClass().add("Center");
TabColReferenceTempo.setCellFactory(TextFieldTableCell.<ListeProduit>forTableColumn());
TabColQuantiteTempo.setCellFactory(TextFieldTableCell.<ListeProduit>forTableColumn());
TabColRemiseTempo.setCellFactory(TextFieldTableCell.<ListeProduit>forTableColumn());
}
@FXML
private void PrintBonLivraisonCltButtonAction(ActionEvent event) throws IOException {
ObservableList<ListeProduit> ListProd = BonLivraison.getListeproduit();
PrinterJob jobPrint = PrinterJob.createPrinterJob();
try {
jobPrint.getJobSettings().setPageRanges(new PageRange(1, 1));
if (jobPrint.showPrintDialog(null)) {
FXMLLoader fxmlLoaderPrintLivraison = new FXMLLoader(getClass().getResource("/Views/BonLivraisonClt/BonLivraisonCltPrint.fxml"));
final Node ParentFxmlPrintLivraison = (Node)fxmlLoaderPrintLivraison.load();
BonLivraisonCltPrintController PrintLivraison = fxmlLoaderPrintLivraison.getController();
PrintLivraison.setBonLivraisonClt(BonLivraison, ListProd, "1/1", true);
jobPrint.printPage(ParentFxmlPrintLivraison);
jobPrint.endJob();
}
} catch (IOException ex) {
System.err.println("BondeEntrerDetailController PrintBonEntreButtonAction ! \n"+ex.getMessage());
}
}
}
@@ -0,0 +1,379 @@
package Controllers.BonLivraisonClt;
import Models.BonLivraisonClt.BonLivraisonCltDB;
import Models.BonLivraisonClt.BonLivraisonCltGestionList;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
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.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.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;
/**
*
* @author maher
*/
public class BonLivraisonCltGestionController implements Initializable {
@FXML private AnchorPane PaneBonLivraisonCltGestion;
@FXML private ProgressBar ProgressBarBonLivraisonClt;
@FXML private Button ButtonSearchBonLivraisonClt;
@FXML public TableView<BonLivraisonCltGestionList> TableViewBonLivraisonCltListGestion;
@FXML public TableColumn<BonLivraisonCltGestionList ,String> TabColIdBonLivrasionClt;
@FXML public TableColumn<BonLivraisonCltGestionList ,String> TabColDateHeurLivraison ;
@FXML public TableColumn<BonLivraisonCltGestionList ,String> TabColAdresseLivraison;
@FXML public TableColumn<BonLivraisonCltGestionList ,String> TabColCodeClt;
@FXML public TableColumn<BonLivraisonCltGestionList ,String> TabColIdFactureClt ;
@FXML public TableColumn<BonLivraisonCltGestionList ,String> TabColTransporteur;
@FXML public TableColumn<BonLivraisonCltGestionList ,Boolean>TabColBlDetail ;
@FXML public TextField TextFieldIdBonLivrasionClt ;
@FXML public DatePicker DatePickerDateLivraison;
@FXML public TextField TextFieldCodeClt;
@FXML public TextField TextFieldIdFactureClt;
@FXML public TextField TextFieldTransporteur;
@FXML public TextField TextFieldAdresseLivraison;
@FXML private AnchorPane ListerPages;
@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> ThreadSearchBonLivraisonClt;
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;
@Override
public void initialize(URL url, ResourceBundle rb) {
//comboboxnombre des lignes tableview
NbrLigne.setItems(cursors);
NbrLigne.getSelectionModel().selectFirst();
TableViewBonLivraisonCltListGestion.setEditable(true);
TabColIdBonLivrasionClt.setStyle( "-fx-alignment: CENTER;");TabColIdBonLivrasionClt.getStyleClass().add("Center");
TabColIdBonLivrasionClt.setCellValueFactory(new PropertyValueFactory<BonLivraisonCltGestionList, String>("IdBonLivrasionClt"));
TabColDateHeurLivraison.setStyle( "-fx-alignment: CENTER;");TabColDateHeurLivraison.getStyleClass().add("Center");
TabColDateHeurLivraison.setCellValueFactory(new PropertyValueFactory<BonLivraisonCltGestionList, String>("DateHeurLivraison"));
TabColAdresseLivraison.setStyle( "-fx-alignment: CENTER;");TabColAdresseLivraison.getStyleClass().add("Center");
TabColAdresseLivraison.setCellValueFactory(new PropertyValueFactory<BonLivraisonCltGestionList, String>("AdresseLivraison"));
TabColCodeClt.setStyle( "-fx-alignment: CENTER;");TabColCodeClt.getStyleClass().add("Center");
TabColCodeClt.setCellValueFactory(new PropertyValueFactory<BonLivraisonCltGestionList, String>("CodeClt"));
TabColIdFactureClt.setStyle( "-fx-alignment: CENTER;");TabColIdFactureClt.getStyleClass().add("Center");
TabColIdFactureClt.setCellValueFactory(new PropertyValueFactory<BonLivraisonCltGestionList, String>("IdFactureClt"));
TabColTransporteur.setStyle( "-fx-alignment: CENTER;");TabColTransporteur.getStyleClass().add("Center");
TabColTransporteur.setCellValueFactory(new PropertyValueFactory<BonLivraisonCltGestionList, String>("Transporteur"));
TabColBlDetail.setStyle( "-fx-alignment: CENTER;");TabColBlDetail.getStyleClass().add("Center");
TabColBlDetail.setCellFactory(new Callback<TableColumn<BonLivraisonCltGestionList, Boolean>, TableCell<BonLivraisonCltGestionList, Boolean>>() {
@Override
public TableCell<BonLivraisonCltGestionList, Boolean> call(TableColumn<BonLivraisonCltGestionList, Boolean> personBooleanTableColumn) {
return new ButtonCell();
}
});
ButtonSearchBonLivraisonClt.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchBonLivraisonClt();
}
});
PaneBonLivraisonCltGestion.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchBonLivraisonClt();
}
}
});
GestionSearchBonLivraisonClt();
}
@FXML
private void AjouterBonLivraisonCltButtonAction(ActionEvent event) throws IOException {
PaneBonLivraisonCltGestion.getChildren().clear();
PaneBonLivraisonCltGestion.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/BonLivraisonClt/BonLivraisonCltAjouter.fxml")));
}
private class ButtonCell extends TableCell<BonLivraisonCltGestionList, 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) {
BonLivraisonCltGestionList current = (BonLivraisonCltGestionList) ButtonCell.this.getTableView().getItems().get(ButtonCell.this.getIndex());
String IdBonLivrasionClt = current.getIdBonLivrasionClt();
BonLivraisonCltDetailController BonLivraisonCltDetail = new BonLivraisonCltDetailController();
BonLivraisonCltDetail.Show();
BonLivraisonCltDetail.SetIdBonLivraison(IdBonLivrasionClt);
}
});
}
//Display button if the row is not empty
@Override
protected void updateItem(Boolean t, boolean empty) {
if(!empty){
setGraphic(cellButton);
} else {
setGraphic(null);
}
}
}
/****************************************************************************** *
* *
* Methode last Next TableView client Entreprise *
* * *
******************************************************************************/
private void SearchBonLivraisonClt()
{
ProgressBarBonLivraisonClt.setVisible(true);
ButtonSearchBonLivraisonClt.setDisable(true);
ThreadSearchBonLivraisonClt = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
position = 0;
actuellepage = 1;
String DateLivraison = "";
if(DatePickerDateLivraison.getValue() != null){
DateLivraison = DatePickerDateLivraison.getValue().toString();
}
ObservableList<BonLivraisonCltGestionList> ListBonLivraisonClts = new BonLivraisonCltDB().SearchBonLivraisonCltGestion(
position,
nbrligne,
TextFieldIdBonLivrasionClt.getText(),
DateLivraison,
TextFieldCodeClt.getText(),
TextFieldIdFactureClt.getText(),
TextFieldTransporteur.getText(),
TextFieldAdresseLivraison.getText());
TableViewBonLivraisonCltListGestion.setItems(ListBonLivraisonClts);
totalcount = new BonLivraisonCltDB().nbrSearchBonLivraisonCltGestion(TextFieldIdBonLivrasionClt.getText(), DateLivraison, TextFieldCodeClt.getText(), TextFieldIdFactureClt.getText(), TextFieldTransporteur.getText(), TextFieldAdresseLivraison.getText());
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;
}
};
}
};
ThreadSearchBonLivraisonClt.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarBonLivraisonClt.setVisible(false);
ButtonSearchBonLivraisonClt.setDisable(false);
LabelCount.setText(totalcount.toString());
}
});
ThreadSearchBonLivraisonClt.start();
}
private void NextLastSearchBonLivraisonClt(Integer ParmPosition, Integer ParamNbrligne)
{
ProgressBarBonLivraisonClt.setVisible(true);
ButtonSearchBonLivraisonClt.setDisable(true);
ThreadSearchBonLivraisonClt = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
String DateLivraison = "";
if(DatePickerDateLivraison.getValue() != null){
DateLivraison = DatePickerDateLivraison.getValue().toString();
}
ObservableList<BonLivraisonCltGestionList> ListBonLivraisonClts = new BonLivraisonCltDB().SearchBonLivraisonCltGestion(ParmPosition, ParamNbrligne, TextFieldIdBonLivrasionClt.getText(), DateLivraison, TextFieldCodeClt.getText(), TextFieldIdFactureClt.getText(), TextFieldTransporteur.getText(), TextFieldAdresseLivraison.getText());
TableViewBonLivraisonCltListGestion.setItems(ListBonLivraisonClts);
return null;
}
};
}
};
ThreadSearchBonLivraisonClt.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarBonLivraisonClt.setVisible(false);
ButtonSearchBonLivraisonClt.setDisable(false);
}
});
ThreadSearchBonLivraisonClt.start();
}
private void GestionSearchBonLivraisonClt()
{
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;
NextLastSearchBonLivraisonClt(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;
NextLastSearchBonLivraisonClt(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;
NextLastSearchBonLivraisonClt(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;
NextLastSearchBonLivraisonClt(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;
NextLastSearchBonLivraisonClt(position, nbrligne);
actuellepage=actuellepage-3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
}
}
@@ -0,0 +1,242 @@
/*
* 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.BonLivraisonClt;
import Controllers.Traitement.Adaptateur;
import static Controllers.Traitement.Adaptateur.StringToStringEspaceCurrency;
import static Controllers.Traitement.Adaptateur.StringToStringEspace;
import Controllers.Traitement.ParametreSystem;
import Controllers.Traitement.contro;
import Models.BonLivraisonClt.BonLivraisonClt;
import Models.Client.Client;
import Models.Client.ClientEntreprise;
import Models.Client.ClientPassager;
import Models.Produit.ListeProduit;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Control;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
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.layout.AnchorPane;
import javafx.scene.text.Text;
import javafx.util.Callback;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class BonLivraisonCltPrintController implements Initializable {
@FXML private AnchorPane AnchorPaneTotal;
@FXML public ImageView ImageViewLogo;
@FXML private Text TextSteNom;
@FXML private Text TextSteAdress;
@FXML private Text TextSteTeleFax;
@FXML private Text TextSteIFCR;
@FXML private Text TextSteRIB;
@FXML private Text TextSteEmailSite;
@FXML private Text TextNumBonLivraison;
@FXML private Text TextDateBonLivraison;
@FXML private Text TextNumCommande;
@FXML private Text TextCltNomPrenom;
@FXML private Text TextCltTele;
@FXML private Text TextCltAdress;
@FXML private TableView<ListeProduit> TableViewListeProduit ;
@FXML private TableColumn<ListeProduit ,String> TabColReference;
@FXML private TableColumn<ListeProduit ,String> TabColDesignation;
@FXML private TableColumn<ListeProduit ,String> TabColQuantite ;
@FXML private TableColumn<ListeProduit ,String> TabColPrixHT;
@FXML private TableColumn<ListeProduit ,String> TabColRemise;
@FXML private TableColumn<ListeProduit ,String> TabColTotalHT;
@FXML private TableColumn<ListeProduit ,String> TabColTVA;
@FXML private TableColumn<ListeProduit ,String> TabColTotalTTC;
@FXML private Text TextTotalRemise;
@FXML private Text TextTotalHT;
@FXML private Text TextTotalTVA;
@FXML private Text TexFraisTransport;
@FXML private Text TextNetPayer;
@FXML private Text TextPagination;
contro clt = new contro();
@Override
public void initialize(URL url, ResourceBundle rb) {
setImageLogo();
TextSteNom.setText(ParametreSystem.CompanyName);
TextSteAdress.setText(ParametreSystem.CompanyAddress);
TextSteTeleFax.setText(ParametreSystem.CompanyTele+" | Fax: "+ParametreSystem.CompanyFax);
TextSteIFCR.setText(ParametreSystem.CompanyIF+" | M.F: "+ParametreSystem.CompanyMF);
TextSteRIB.setText(ParametreSystem.RIB);
TextSteEmailSite.setText(ParametreSystem.CompanyMail+" | Site:"+ParametreSystem.CompanySite);
TabColReference.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("reference"));
TabColReference.setStyle( "-fx-alignment: CENTER;");
TabColReference.getStyleClass().add("Center");
TabColDesignation.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("designation"));
TabColDesignation.setCellFactory(new Callback<TableColumn<ListeProduit,String>,TableCell<ListeProduit,String>>(){
@Override
public TableCell<ListeProduit, String> call(TableColumn<ListeProduit, String> param) {
TableCell<ListeProduit, String> cell = new TableCell<ListeProduit, String>(){
@Override
public void updateItem(String item, boolean empty) {
if (item == null) {
super.setText(null);
super.setGraphic(null);
} else {
String newItem = item.trim().toLowerCase();
Text text = new Text(newItem);
super.setPrefHeight(Control.USE_COMPUTED_SIZE);
text.wrappingWidthProperty().bind(super.widthProperty());
super.setGraphic(text);
}
}
};
return cell;
}
});
TabColQuantite.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("quantite"));
TabColQuantite.setStyle( "-fx-alignment: CENTER;");
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;");
TabColTotalTTC.getStyleClass().add("Center");
TabColReference.setCellFactory(TextFieldTableCell.<ListeProduit>forTableColumn());
TabColQuantite.setCellFactory(TextFieldTableCell.<ListeProduit>forTableColumn());
TabColRemise.setCellFactory(TextFieldTableCell.<ListeProduit>forTableColumn());
}
public void setBonLivraisonClt(BonLivraisonClt BonLivraison, ObservableList<ListeProduit> ListProd, String Pagination, boolean PaneTotalVisible) {
TextNumBonLivraison.setText(""+BonLivraison.getIdBonLivrasionClt());
TextNumCommande.setText(BonLivraison.getIdCommande());
TextDateBonLivraison.setText(Adaptateur.NormalDateFormat(BonLivraison.getDateLivraisonPreveu()));
TextPagination.setText(Pagination);
String AdressClt = "";
//0 Personne 1 Entreprise 2 Passager
if(BonLivraison.getTypeClient() == 0){
Client CltPersonne = BonLivraison.getCltPersonne();
TextCltNomPrenom.setText(CltPersonne.getCodeclient()+" - "+CltPersonne.getPrenom()+" "+CltPersonne.getNom());
AdressClt = CltPersonne.getAdresse();
if( (!clt.isStringNull(CltPersonne.getTelemobileString())) && (!clt.isStringNull(CltPersonne.getTelefixString())) ) {
TextCltTele.setText(CltPersonne.getTelemobile()+" | "+CltPersonne.getTelefix());
}else if(!clt.isStringNull(CltPersonne.getTelemobileString())){
TextCltTele.setText(CltPersonne.getTelemobileString());
}else if(!clt.isStringNull(CltPersonne.getTelefixString())){
TextCltTele.setText(CltPersonne.getTelefixString());
}
}else if(BonLivraison.getTypeClient() == 1){
ClientEntreprise CltEntreprise = BonLivraison.getCltEntreprise();
TextCltNomPrenom.setText(CltEntreprise.getCodeString()+" - "+CltEntreprise.getNom());
TextCltTele.setText(CltEntreprise.getTele1()+" | "+CltEntreprise.getTele2());
AdressClt = CltEntreprise.getAdresse();
}else if(BonLivraison.getTypeClient() == 2){
ClientPassager CltPassager = BonLivraison.getCltPassager();
TextCltNomPrenom.setText(CltPassager.getCodeclient()+" - "+CltPassager.getNom()+" "+CltPassager.getPrenom());
TextCltTele.setText(CltPassager.getTelemobile()+" | "+CltPassager.getTelefix());
AdressClt = CltPassager.getAdresse();
}
if(clt.isNumericNotnull(BonLivraison.getAdresseLivraison())){
TextCltAdress.setText(BonLivraison.getAdresseLivraison());
}else{
TextCltAdress.setText(AdressClt);
}
TextTotalHT.setText(StringToStringEspace(BonLivraison.getTotalHorsTaxNet()));
TextTotalTVA.setText(StringToStringEspace(BonLivraison.getTotalTVA()));
TextTotalRemise.setText(StringToStringEspace(BonLivraison.getRemise()));
TexFraisTransport.setText(StringToStringEspace(BonLivraison.getFrais()));
TextNetPayer.setText(StringToStringEspaceCurrency(BonLivraison.getNetAPayer()));
TableViewListeProduit.setItems(ListProd);
AnchorPaneTotal.setVisible(PaneTotalVisible);
}
private void setImageLogo()
{
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
// optional, but recommended
// process XML securely, avoid attacks like XML External Entities (XXE)
dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
// parse XML file
DocumentBuilder db = dbf.newDocumentBuilder();
//PowerERP\conf\logo.xml
Document doc = db.parse(new File("./conf/logo.xml"));
doc.getDocumentElement().normalize();
Element elementCNX = (Element) doc.getElementsByTagName("BonLivraisonCltPrint").item(0);
String pathLogo = elementCNX.getElementsByTagName("PathImage").item(0).getTextContent();
FileInputStream fis = new FileInputStream(pathLogo);
ImageViewLogo.setImage(new Image(fis));
ImageViewLogo.setFitWidth(Double.parseDouble(elementCNX.getElementsByTagName("FitWidth").item(0).getTextContent()));
ImageViewLogo.setFitHeight(Double.parseDouble(elementCNX.getElementsByTagName("FitHeight").item(0).getTextContent()));
ImageViewLogo.setLayoutX(Double.parseDouble(elementCNX.getElementsByTagName("LayoutX").item(0).getTextContent()));
ImageViewLogo.setLayoutY(Double.parseDouble(elementCNX.getElementsByTagName("LayoutY").item(0).getTextContent()));
}
catch (ParserConfigurationException | SAXException | IOException e) {
System.out.println("error AuthentificationController/setImageLogo "+e.getMessage());
}
}
}
@@ -0,0 +1,624 @@
/*
* 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.BonReceptionFrs;
import Controllers.CommandeClt.CommandeCltPasserController;
import Controllers.Dialog.MessageControle;
import Controllers.Produit.RechercherProduitController;
import Controllers.Traitement.Adaptateur;
import Controllers.Traitement.MyWindow;
import Controllers.Traitement.contro;
import Models.BonReceptionFrs.BonReceptionDB;
import Models.BonReceptionFrs.BonReceptionFrs;
import Models.BonReceptionFrs.BonReceptionProduitList;
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 java.util.ArrayList;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Platform;
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 Ben Tili
*/
public class BonReceptionAjouterFrsController implements Initializable {
@FXML public AnchorPane PaneBonReceptionAjouterFrs ;
@FXML public Text NetAPayer ;
@FXML public Button RechercheProduit ;
@FXML public Button ButtonBonReceptionAjouter;
@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> 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 ProgressIndicatorSaveBonReception ;
public ObservableList<ListeProduit> data = 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<>();
@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");
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());
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 BonReceptionAjouterFrsController.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();
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 BonReceptionAjouterFrsController.ButtonCell();
}
});
TableViewListeProduit.setItems(data);
//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){
data.add(new ListeProduit("","","","","","","",""));
TableViewListeProduit.setItems(data);
}
else{
ListeProduit Liste = TableViewListeProduit.getItems().get(nbrligne - 1);
if(!Liste.getTotalTTC().isEmpty()){
data.add(new ListeProduit("","","","","","","",""));
TableViewListeProduit.setItems(data);
TableViewListeProduit.getSelectionModel().select(nbrligne);
}
}
}
});
ButtonBonReceptionAjouter.setOnAction(new EventHandler<ActionEvent>() { //supprimer le message du suucés et reaficher les formulaires
@Override
public void handle(ActionEvent event) {
ButtonBonReceptionAjouter.setText("");
ButtonBonReceptionAjouter.setDisable(true);
ProgressIndicatorSaveBonReception.setVisible(true);
if( Controle.ContrNull(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(){
if(data.size()>0){
BonReceptionDB BonRecepDB= new BonReceptionDB();
String Numero = TextFieldNumero.getText();
String IdFournisseur = TextFieldFournisseur.getText().split(" - ", -1)[0];
String IdBonReception = BonRecepDB.getBonReceptionFrs(null, Numero, IdFournisseur).getIdBonReception();
if(IdBonReception != null){
TextFieldNumero.setStyle("-fx-border-color:#f20606;");
TextNumero.setText("Bon réception existe déja");
}else{
BonReceptionFrs BonReception = setBonReceptionFrs();
BonReception = BonRecepDB.setBonReceptionFrsDB(BonReception);
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/BonReceptionFrs/BonReceptionDetailFrs.fxml"));
Parent ParentFxmlFournisseur = (Parent)fxmlLoader.load();
BonReceptionDetailFrsController BonReceptionDetailFrs = fxmlLoader.getController();
BonReceptionDetailFrs.setDataBonReceptionDetailFrs(BonReception.getIdBonReception());
BonReceptionDetailFrs.PaneSucessFrs.setVisible(true);
PaneBonReceptionAjouterFrs.getChildren().clear();
PaneBonReceptionAjouterFrs.getChildren().add(ParentFxmlFournisseur);
}catch (IOException ex) {
Logger.getLogger(BonReceptionDetailFrsController.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
}
ButtonBonReceptionAjouter.setText("Enregister La Bon de Réception");
ButtonBonReceptionAjouter.setDisable(false);
ProgressIndicatorSaveBonReception.setVisible(false);
}
});
}
public void getBonReceptionFrs(BonReceptionFrs BonReception)
{
TextFieldNumero.setText(BonReception.getNumero());
TextFieldHeur.setText(BonReception.getHeur());
TextFieldTransporteur.setText(BonReception.getTransporteur());
DatePickerDateReception.setValue(Adaptateur.StringToLocalDate(BonReception.getDate()));
Fournisseur Frs = BonReception.getFournisseur();
if(Frs != null){
TextFieldFournisseur.setText(Frs.getCode()+" - "+Frs.getNom());
}
String Local = BonReception.getLocal();
if(Local != null){
int indexLocale = ListLocale.indexOf(Local);
ChoiceBoxLocalReception.getSelectionModel().select(indexLocale);
}
}
public BonReceptionFrs setBonReceptionFrs()
{
BonReceptionFrs BonReception = new BonReceptionFrs();
if(!TextFieldFournisseur.getText().equals("")){
String[] Fournisseur = TextFieldFournisseur.getText().split(" - ", -1);
Fournisseur Frs = new Fournisseur();
Frs.setCode(Fournisseur[0]);
Frs.setNom(Fournisseur[1]);
BonReception.setFournisseur(Frs);
}
if(DatePickerDateReception.getValue() != null){
BonReception.setDate(DatePickerDateReception.getValue().toString());
}
if(ChoiceBoxLocalReception.getValue() != null){
BonReception.setLocal(ChoiceBoxLocalReception.getValue().toString());
}
BonReception.setHeur(TextFieldHeur.getText());
BonReception.setNumero(Adaptateur.addSlashes(TextFieldNumero.getText()));
BonReception.setTransporteur(Adaptateur.addSlashes(TextFieldTransporteur.getText()));
BonReception.setNetPayer(NetAPayer.getText());
ObservableList<BonReceptionProduitList> ObservableListBonReceptionFrs = FXCollections.observableArrayList();
for(ListeProduit liste : data){
if(!liste.getReference().equals("")){
ObservableListBonReceptionFrs.add(new BonReceptionProduitList("", "", liste.getReference(), "", liste.getQuantite(), liste.getPrixHT(), liste.getTotalHT(), liste.getTVA(), liste.getTotalTTC()));
}
}
BonReception.setListProduit(ObservableListBonReceptionFrs);
return BonReception;
}
//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();
data.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){
data.add(new ListeProduit("","","","","","","",""));
TableViewListeProduit.setItems(data);
}
else{
ListeProduit Liste = TableViewListeProduit.getItems().get(nbrligne - 1);
if(!Liste.getTotalTTC().isEmpty()){
data.add(new ListeProduit("","","","","","","",""));
TableViewListeProduit.setItems(data);
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 AffectationTableView(ListeProduit ListeProd, int EmplacementLigne){
boolean result = false ;
int indise=0;
int Position = 0;
if(data.size()>0){
do{ //Vérifier si le produit exsiste deja
if(data.get(indise).getReference().equals(ListeProd.getReference())){
result = true ;
Position = indise ;
//System.out.println("existe Position:"+indise);
}
indise++;
}while(data.size()>indise && !result);
if(result){ //si la ligne exsite déja
if(EmplacementLigne!= -1){
if(Position == EmplacementLigne){
data.set(Position, ListeProd);
}
else{
data.set(EmplacementLigne, new ListeProduit("","","","","","","",""));
}
}
}else{
if(EmplacementLigne!= -1){
data.set(EmplacementLigne, ListeProd);
}else{
data.add(ListeProd);
}
}
}
else{
data.add(ListeProd);
}
CalculeListeProduit();
TableViewListeProduit.setItems(data);
TableViewListeProduit.setVisible(false);
TableViewListeProduit.setVisible(true);
}
private void CalculeListeProduit(){ //calculer et afficher la détail des produits
float netaPayer = 0;
float Remises = 0;
float totalTVA = 0;
float total_H_T_Net= 0;
NetAPayer.setText("");
//calcule
for(ListeProduit liste : data){
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){
netaPayer = total_H_T_Net + totalTVA;
NetAPayer.setText(Adaptateur.ArrondFloatToString(netaPayer));
}
}
public Object[] getDefaultSaveDataImport(){
Object[] ArrayObject = new Object[10];
ArrayObject[0] = this.data;
ArrayObject[1] = setBonReceptionFrs();
return ArrayObject;
}
public void SetDefaultSaveDataImport(Object[] ArrayObject){
if(ArrayObject[0] != null){
this.data = (ObservableList<ListeProduit>) ArrayObject[0];
this.CalculeListeProduit();
this.TableViewListeProduit.setItems(data);
}
if(ArrayObject[1] != null){
BonReceptionFrs BonReception = (BonReceptionFrs) ArrayObject[1];
getBonReceptionFrs(BonReception);
}
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/BonReceptionFrs/BonReceptionAjouterFrs.fxml"));
Parent ParentBonReceptionAjouterFXML = (Parent) fxmlLoader.load();
BonReceptionAjouterFrsController BonReceptionAjouterFrs = fxmlLoader.getController();
BonReceptionAjouterFrs.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((data.size()>0) && (data.get(data.size()-1).getReference().isEmpty())){
data.remove(data.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,150 @@
package Controllers.BonReceptionFrs;
import Controllers.Traitement.Adaptateur;
import Models.BonReceptionFrs.BonReceptionDB;
import Models.BonReceptionFrs.BonReceptionFrs;
import Models.BonReceptionFrs.BonReceptionProduitList;
import Models.Fournisseur.Fournisseur;
import Models.User.Profile;
import java.net.URL;
import java.util.ResourceBundle;
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.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Text;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class BonReceptionDetailFrsController implements Initializable {
@FXML private AnchorPane PaneBonReceptionDetailFrs ;
@FXML public AnchorPane PaneSucessFrs ;
@FXML public AnchorPane AnchorPaneDetailInformation;
@FXML private AnchorPane AnchorPaneLoading;
@FXML private Text TextNumero;
@FXML private Text TextDateReception;
@FXML private Text TextHeurReception;
@FXML private Text TextLocalReception;
@FXML private Text TextTransporteur;
@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 TextNetPayer;
@FXML public TableView<BonReceptionProduitList> TableViewListeProduit ;
@FXML public TableColumn<BonReceptionProduitList ,String> TabColReference;
@FXML public TableColumn<BonReceptionProduitList ,String> TabColDesignation;
@FXML public TableColumn<BonReceptionProduitList ,String> TabColQuantite ;
@FXML public TableColumn<BonReceptionProduitList ,String> TabColPrixHT;
@FXML public TableColumn<BonReceptionProduitList ,String> TabColTotalHT;
@FXML public TableColumn<BonReceptionProduitList ,String> TabColTVA;
@FXML public TableColumn<BonReceptionProduitList ,String> TabColTotalTTC;
private Service<Void> ThreadBonReceptionDetailFrs;
BonReceptionFrs BonReception;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
TabColReference.setCellValueFactory(new PropertyValueFactory<BonReceptionProduitList, String>("reference"));
TabColDesignation.setCellValueFactory(new PropertyValueFactory<BonReceptionProduitList, String>("designation"));
TabColQuantite.setCellValueFactory(new PropertyValueFactory<BonReceptionProduitList, String>("quantite"));
TabColQuantite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColQuantite.getStyleClass().add("Center");
TabColPrixHT.setCellValueFactory(new PropertyValueFactory<BonReceptionProduitList, String>("PrixUnitaireHorsTaxe"));
TabColPrixHT.setStyle( "-fx-alignment: CENTER;");
TabColPrixHT.getStyleClass().add("Center");
TabColTotalHT.setCellValueFactory(new PropertyValueFactory<BonReceptionProduitList, String>("PrixUnitaireHorsTaxenNet"));
TabColTotalHT.setStyle( "-fx-alignment: CENTER;");
TabColTotalHT.getStyleClass().add("Center");
TabColTVA.setCellValueFactory(new PropertyValueFactory<BonReceptionProduitList, String>("Tva"));
TabColTVA.setStyle( "-fx-alignment: CENTER;");
TabColTVA.getStyleClass().add("Center");
TabColTotalTTC.setCellValueFactory(new PropertyValueFactory<BonReceptionProduitList, String>("Montant"));
TabColTotalTTC.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColTotalTTC.getStyleClass().add("Center");
}
public void setDataBonReceptionDetailFrs(final String IdBonReceptionFrs){
ThreadBonReceptionDetailFrs = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
BonReception = new BonReceptionDB().getBonReceptionFrs(IdBonReceptionFrs, null, null);
return null;
}
};
}
};
ThreadBonReceptionDetailFrs.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
TextNumero.setText(BonReception.getNumero());
TextDateReception.setText(BonReception.getDate());
TextHeurReception.setText(BonReception.getHeur());
TextLocalReception.setText(BonReception.getLocal());
TextTransporteur.setText(BonReception.getTransporteur());
Profile profile = BonReception.getProfile();
TextProfile.setText(profile.getNom()+" "+profile.getPrenom());
Fournisseur Frs = BonReception.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<BonReceptionProduitList> BRProduitList = BonReception.getListProduit();
float NetPayer = 0;
for(int i=0; i<BRProduitList.size(); i++){
String TTC = BRProduitList.get(i).getMontant();
NetPayer += Adaptateur.StringToFloat(TTC);
}
TextNetPayer.setText(Adaptateur.FloatToStringEspaceCurrency(NetPayer));
TableViewListeProduit.setItems(BRProduitList);
PaneBonReceptionDetailFrs.setVisible(true);
AnchorPaneLoading.setVisible(false);
}
});
ThreadBonReceptionDetailFrs.start();
}
public void setContainsDetailInformation()
{
AnchorPane.setTopAnchor(AnchorPaneDetailInformation, 15.0);
}
}
@@ -0,0 +1,480 @@
package Controllers.BonReceptionFrs;
import Models.BonReceptionFrs.BonReceptionGestionDB;
import Models.BonReceptionFrs.BonReceptionGestionList;
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.util.ArrayList;
import java.util.ResourceBundle;
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.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.apache.log4j.Logger;
import org.controlsfx.control.textfield.TextFields;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class BonReceptionGestionFrsController implements Initializable {
@FXML public AnchorPane PaneBonReceptionGestion ;
@FXML private ProgressBar ProgressBarBonReceptionFrs;
@FXML public TableView<BonReceptionGestionList> TableViewBonReceptionGestion;
@FXML public TableColumn<BonReceptionGestionList ,String> TabColNumero;
@FXML public TableColumn<BonReceptionGestionList ,String> TabColFournisseur;
@FXML public TableColumn<BonReceptionGestionList ,String> TabColDate;
@FXML public TableColumn<BonReceptionGestionList ,String> TabColHeur;
@FXML public TableColumn<BonReceptionGestionList ,String> TabColLocalReception;
@FXML public TableColumn<BonReceptionGestionList ,String> TabColTransporteur;
@FXML public TableColumn<BonReceptionGestionList ,String> TabColFacture;
@FXML public TableColumn<BonReceptionGestionList ,Boolean> TabColDetail;
@FXML public TextField TextFieldNumero ;
@FXML public TextField TextFieldTransporteur ;
@FXML public TextField TextFieldFacture ;
@FXML public DatePicker DatePickerDateReception;
@FXML private TextField TextFieldFournisseur;
@FXML public ChoiceBox ChoiceBoxLocalReception ;
@FXML public AnchorPane PaneProgressBonReception;
@FXML private Button ButtonSearchBonReceptionFrs;
@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 ;
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;
private Service<Void> ThreadSearchBonReceptionGestionFrs;
public static ArrayList<String> ListFournisseur = new ArrayList<>();
public static ArrayList<String> ListLocale = new ArrayList<>();
String LocalReception = "";
String IdFournisseur = "";
Logger logger = Logger.getLogger(BonReceptionGestionFrsController.class.getName());
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
NbrLigne.setItems(cursors);
NbrLigne.getSelectionModel().selectFirst();
TabColNumero.setStyle( "-fx-alignment: CENTER;");
TabColNumero.getStyleClass().add("Center");
TabColNumero.setCellValueFactory(new PropertyValueFactory<BonReceptionGestionList, String>("Numero"));
TabColFournisseur.setStyle( "-fx-alignment: CENTER;");
TabColFournisseur.getStyleClass().add("Center");
TabColFournisseur.setCellValueFactory(new PropertyValueFactory<BonReceptionGestionList, String>("Fournisseur"));
TabColDate.setStyle( "-fx-alignment: CENTER;");
TabColDate.getStyleClass().add("Center");
TabColDate.setCellValueFactory(new PropertyValueFactory<BonReceptionGestionList, String>("Date"));
TabColHeur.setStyle( "-fx-alignment: CENTER;");
TabColHeur.getStyleClass().add("Center");
TabColHeur.setCellValueFactory(new PropertyValueFactory<BonReceptionGestionList, String>("Heur"));
TabColLocalReception.setStyle( "-fx-alignment: CENTER;");
TabColLocalReception.getStyleClass().add("Center");
TabColLocalReception.setCellValueFactory(new PropertyValueFactory<BonReceptionGestionList, String>("LocalReception"));
TabColTransporteur.setStyle( "-fx-alignment: CENTER;");
TabColTransporteur.getStyleClass().add("Center");
TabColTransporteur.setCellValueFactory(new PropertyValueFactory<BonReceptionGestionList, String>("Transporteur"));
TabColFacture.setStyle( "-fx-alignment: CENTER;");
TabColFacture.getStyleClass().add("Center");
TabColFacture.setCellValueFactory(new PropertyValueFactory<BonReceptionGestionList, String>("Facture"));
TabColDetail.setStyle( "-fx-alignment: CENTER;");TabColDetail.getStyleClass().add("Center");
TabColDetail.setCellFactory(new Callback<TableColumn<BonReceptionGestionList, Boolean>, TableCell<BonReceptionGestionList, Boolean>>() {
@Override
public TableCell<BonReceptionGestionList, Boolean> call(TableColumn<BonReceptionGestionList, Boolean> personBooleanTableColumn) {
return new ButtonCell();
}
});
setDefaultFormData();
ChoiceBoxLocalReception.valueProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue ov, String t, String ValLocal) {
LocalReception = ValLocal;
}
});
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];
}
}
});
ButtonSearchBonReceptionFrs.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchBonReceptionGestionFrs();
}
});
PaneBonReceptionGestion.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchBonReceptionGestionFrs();
}
}
});
GestionSearchBonReceptionFrs();
}
private class ButtonCell extends TableCell<BonReceptionGestionList, 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 {
BonReceptionGestionList BonReceptionGestion = (BonReceptionGestionList)getTableRow().getItem();
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/BonReceptionFrs/BonReceptionDetailFrs.fxml"));
Parent ParentFxmlFournisseur = (Parent)fxmlLoader.load();
BonReceptionDetailFrsController BonReceptionDetailFrs = fxmlLoader.getController();
BonReceptionDetailFrs.setDataBonReceptionDetailFrs(BonReceptionGestion.getCode());
PaneBonReceptionGestion.getChildren().clear();
PaneBonReceptionGestion.getChildren().add(ParentFxmlFournisseur);
BonReceptionDetailFrs.setContainsDetailInformation();
}catch (IOException ex) {
logger.error(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 BonReceptionAjouterFrsButtonAction(ActionEvent event) throws IOException {
PaneBonReceptionGestion.getChildren().clear();
PaneBonReceptionGestion.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/BonReceptionFrs/BonReceptionAjouterFrs.fxml")));
}
private void setDefaultFormData()
{
ProgressBarBonReceptionFrs.setVisible(true);
ThreadSearchBonReceptionGestionFrs = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
try{
ListFournisseur = new FournisseurDB().getAllFournisseur("CONCAT(`id_fourisseur`,' - ',`nom`)");
TextFields.bindAutoCompletion(TextFieldFournisseur, ListFournisseur);
ListLocale = new StockDB().getAllListLocal();
ChoiceBoxLocalReception.getItems().addAll(ListLocale);
}catch (Exception ex) {
logger.error(ex.getMessage());
}
return null;
}
};
}
};
ThreadSearchBonReceptionGestionFrs.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarBonReceptionFrs.setVisible(false);
}
});
ThreadSearchBonReceptionGestionFrs.setOnFailed(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
logger.error(ThreadSearchBonReceptionGestionFrs.getException());
}
});
ThreadSearchBonReceptionGestionFrs.start();
}
/****************************************************************************** *
* *
* Methode last Next TableView *
* * *
******************************************************************************/
private void SearchBonReceptionGestionFrs()
{
ProgressBarBonReceptionFrs.setVisible(true);
ButtonSearchBonReceptionFrs.setDisable(true);
ThreadSearchBonReceptionGestionFrs = 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<BonReceptionGestionList> ListBonReceptionGestionFrs = new BonReceptionGestionDB().SearchBonReceptionGestionFrs(
position,
nbrligne,
TextFieldNumero.getText(),
TextFieldTransporteur.getText(),
TextFieldFacture.getText(),
DateReception,
IdFournisseur,
LocalReception);
TableViewBonReceptionGestion.setItems(ListBonReceptionGestionFrs);
totalcount = new BonReceptionGestionDB().nbrBonReceptionGestionFrsGestion(TextFieldNumero.getText(), TextFieldTransporteur.getText(), TextFieldFacture.getText(), DateReception, IdFournisseur, LocalReception);
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;
}
};
}
};
ThreadSearchBonReceptionGestionFrs.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarBonReceptionFrs.setVisible(false);
ButtonSearchBonReceptionFrs.setDisable(false);
LabelCount.setText(totalcount.toString());
}
});
ThreadSearchBonReceptionGestionFrs.start();
}
private void NextLastSearchBonReceptionGestionFrs(Integer ParmPosition, Integer ParamNbrligne)
{
ProgressBarBonReceptionFrs.setVisible(true);
ButtonSearchBonReceptionFrs.setDisable(true);
ThreadSearchBonReceptionGestionFrs = 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<BonReceptionGestionList> ListBonReceptionGestionFrss = new BonReceptionGestionDB().SearchBonReceptionGestionFrs(ParmPosition, ParamNbrligne, TextFieldNumero.getText(), TextFieldTransporteur.getText(), TextFieldFacture.getText(), DateReception, IdFournisseur, LocalReception);
TableViewBonReceptionGestion.setItems(ListBonReceptionGestionFrss);
return null;
}
};
}
};
ThreadSearchBonReceptionGestionFrs.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarBonReceptionFrs.setVisible(false);
ButtonSearchBonReceptionFrs.setDisable(false);
}
});
ThreadSearchBonReceptionGestionFrs.start();
}
private void GestionSearchBonReceptionFrs()
{
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;
NextLastSearchBonReceptionGestionFrs(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;
NextLastSearchBonReceptionGestionFrs(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;
NextLastSearchBonReceptionGestionFrs(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;
NextLastSearchBonReceptionGestionFrs(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;
NextLastSearchBonReceptionGestionFrs(position, nbrligne);
actuellepage=actuellepage-3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
}
}
@@ -0,0 +1,457 @@
package Controllers.Caisse;
import Controllers.Traitement.Adaptateur;
import Controllers.Traitement.ParametreSystem;
import Controllers.Traitement.contro;
import Models.Caisse.CaisseDB;
import Models.Caisse.CaisseEntreListe;
import Models.Caisse.CaisseListe;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.time.LocalDate;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
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.print.PageLayout;
import javafx.print.PageOrientation;
import javafx.print.PageRange;
import javafx.print.Paper;
import javafx.print.Printer;
import javafx.print.PrinterJob;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Text;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class CaisseEntreController implements Initializable {
@FXML private AnchorPane AnchorPaneCaisseClt;
@FXML private ProgressBar ProgressBarCaisseEnterClt;
@FXML private DatePicker DatePickerDebut;
@FXML private DatePicker DatePickerFin;
@FXML private Text TotalEnter;
@FXML private CheckBox CheckBoxChequeClt;
@FXML private CheckBox CheckBoxEspace;
@FXML private CheckBox CheckBoxCarteBancaire;
@FXML private CheckBox CheckBoxPaiementTraite ;
@FXML private CheckBox CheckBoxVenteComptant ;
@FXML private CheckBox CheckBoxVenteCommandeAvance ;
@FXML private CheckBox CheckBoxVenteFaciliteAvance ;
@FXML private CheckBox CheckBoxVersementCheque ; //lencaissement
@FXML public TableView<CaisseListe> TableViewCaisseCltEnter ;
@FXML private TableColumn<CaisseListe ,String> TabColChequeClt;
@FXML private TableColumn<CaisseListe ,String> TabColEspace;
@FXML private TableColumn<CaisseListe ,String> TabColCarteBancaire;
@FXML private TableColumn<CaisseListe ,String> TabColIdCaisse;
@FXML private TableColumn<CaisseListe ,String> TabColType;
@FXML private TableColumn<CaisseListe ,String> TabColDate;
@FXML private TableColumn<CaisseListe ,String> TabColMontant;
@FXML private TableColumn<CaisseListe ,String> TabColChequeCltNumero;
@FXML private TableColumn<CaisseListe ,String> TabColChequeCltBanque;
@FXML private TableColumn<CaisseListe ,String> TabColEspaceNom;
@FXML private TableColumn<CaisseListe ,String> TabColEspacePrenom;
@FXML private TableColumn<CaisseListe ,String> TabColCateBancaireNumero;
@FXML private TableColumn<CaisseListe ,String> TabColCateBancaireBanque;
@FXML private Button ButtonEnter;
@FXML private Button ButtonPrintCaisseEntre;
private Service<Void> ThreadCaisseEnter;
CaisseDB CaisseDB= new CaisseDB();
ObservableList<CaisseListe> ObsListCaisseCltEnter;
ObservableList<CaisseListe> TempoObsListCaisseCltEnter;
private String DateDebut ;
private String DateFin;
contro clt = new contro();
public void getDetailEnterCheck()
{
TempoObsListCaisseCltEnter = FXCollections.observableArrayList();
boolean CheckChequeClt = CheckBoxChequeClt.isSelected();
boolean CheckEspace = CheckBoxEspace.isSelected();
boolean CheckCarteBancaire= CheckBoxCarteBancaire.isSelected();
boolean CheckPaiementTraite = CheckBoxPaiementTraite.isSelected();
boolean CheckVenteComptant = CheckBoxVenteComptant.isSelected();
boolean CheckVenteCommandeAvance = CheckBoxVenteCommandeAvance.isSelected();
boolean CheckVenteFaciliteAvance = CheckBoxVenteFaciliteAvance.isSelected();
boolean CheckVersementCheque = CheckBoxVersementCheque.isSelected();
boolean SelectedCheck;
boolean SelectedCheckEspace;
boolean SelectedCheckChequeClt;
boolean SelectedCheckCarteBancaire;
float FloatTotalEnter = 0;
// 0-Vente Comptant | 1-Vente Facilité Avance | 2 Vente Commande Avance | 3 traite clt | 4 ChequeClt
if(ObsListCaisseCltEnter.size()>0){
int indice = 0;
while(indice<ObsListCaisseCltEnter.size()){
CaisseListe ListCaisseCltEnter = ObsListCaisseCltEnter.get(indice);
SelectedCheck = false;
SelectedCheckEspace = false;
SelectedCheckChequeClt = false;
SelectedCheckCarteBancaire = false;
//Paiement Espace
if(CheckEspace && ( (ListCaisseCltEnter.getEspaceNom()!= "") || (ListCaisseCltEnter.getEspacePrenom()!= "")) ){
SelectedCheckEspace = true;
}
//Paiement Chèque
if(CheckChequeClt && ( (ListCaisseCltEnter.getChequeCltBanque()!= "") || (ListCaisseCltEnter.getChequeCltNumero()!= "")) ){
SelectedCheckChequeClt = true;
}
//Paiement Carte Bancaire
if(CheckCarteBancaire && ( (ListCaisseCltEnter.getCateBancaireBanque()!= "") || (ListCaisseCltEnter.getCateBancaireNumero()!= "")) ){
SelectedCheckCarteBancaire = true;
}
//0-Vente Comptant
if(CheckVenteComptant && (ListCaisseCltEnter.getCodeType().equals("0")) && (SelectedCheckEspace || SelectedCheckChequeClt || SelectedCheckCarteBancaire) ){
SelectedCheck = true;
}
//1-Vente Facilité Avance
if(CheckVenteFaciliteAvance && (ListCaisseCltEnter.getCodeType().equals("1")) && (SelectedCheckEspace || SelectedCheckChequeClt || SelectedCheckCarteBancaire) ){ SelectedCheck = true; }
//2 Vente Commande Avance
if(CheckVenteCommandeAvance && (ListCaisseCltEnter.getCodeType().equals("2")) && (SelectedCheckEspace || SelectedCheckChequeClt || SelectedCheckCarteBancaire) ){ SelectedCheck = true; }
//3 traite clt
if(CheckPaiementTraite && (ListCaisseCltEnter.getCodeType().equals("3")) && (SelectedCheckEspace || SelectedCheckChequeClt || SelectedCheckCarteBancaire) ){ SelectedCheck = true; }
//4 ChequeClt
if(CheckVersementCheque && (ListCaisseCltEnter.getCodeType().equals("4")) && (SelectedCheckEspace || SelectedCheckChequeClt || SelectedCheckCarteBancaire) ){ SelectedCheck = true; }
//5 Vente Sans Facture
if(CheckVenteComptant && (ListCaisseCltEnter.getCodeType().equals("5")) && (SelectedCheckEspace || SelectedCheckChequeClt || SelectedCheckCarteBancaire) ){ SelectedCheck = true; }
if(SelectedCheck){
FloatTotalEnter += ListCaisseCltEnter.getFloatMontant();
TempoObsListCaisseCltEnter.add(ListCaisseCltEnter);
}
indice++;
}
TableViewCaisseCltEnter.setItems(TempoObsListCaisseCltEnter);
TotalEnter.setText(Adaptateur.FloatToStringEspaceCurrency(FloatTotalEnter));
}
}
@Override
public void initialize(URL url, ResourceBundle rb) {
DatePickerDebut.setValue(LocalDate.now());
DatePickerFin.setValue(LocalDate.now());
DateDebut = DatePickerDebut.getValue().toString();
DateFin = DatePickerFin.getValue().toString();
TabColChequeClt.setStyle( "-fx-alignment: CENTER;");TabColChequeClt.getStyleClass().add("Center");
TabColEspace.setStyle( "-fx-alignment: CENTER;");TabColEspace.getStyleClass().add("Center");
TabColCarteBancaire.setStyle( "-fx-alignment: CENTER;");TabColCarteBancaire.getStyleClass().add("Center");
TabColIdCaisse.setStyle( "-fx-alignment: CENTER;");TabColIdCaisse.getStyleClass().add("Center");
TabColIdCaisse.setCellValueFactory(new PropertyValueFactory<CaisseListe, String>("IdCaisseClt"));
TabColType.setStyle( "-fx-alignment: CENTER;");TabColType.getStyleClass().add("Center");
TabColType.setCellValueFactory(new PropertyValueFactory<CaisseListe, String>("Type"));
TabColDate.setStyle( "-fx-alignment: CENTER;");TabColDate.getStyleClass().add("Center");
TabColDate.setCellValueFactory(new PropertyValueFactory<CaisseListe, String>("Date"));
TabColMontant.setStyle( "-fx-alignment: CENTER;");TabColMontant.getStyleClass().add("Center");
TabColMontant.setCellValueFactory(new PropertyValueFactory<CaisseListe, String>("Montant"));
TabColChequeCltNumero.setStyle( "-fx-alignment: CENTER;");TabColChequeCltNumero.getStyleClass().add("Center");
TabColChequeCltNumero.setCellValueFactory(new PropertyValueFactory<CaisseListe, String>("ChequeCltNumero"));
TabColChequeCltBanque.setStyle( "-fx-alignment: CENTER;");TabColChequeCltBanque.getStyleClass().add("Center");
TabColChequeCltBanque.setCellValueFactory(new PropertyValueFactory<CaisseListe, String>("ChequeCltBanque"));
TabColEspaceNom.setStyle( "-fx-alignment: CENTER;");TabColEspaceNom.getStyleClass().add("Center");
TabColEspaceNom.setCellValueFactory(new PropertyValueFactory<CaisseListe, String>("EspaceNom"));
TabColEspacePrenom.setStyle( "-fx-alignment: CENTER;");TabColEspacePrenom.getStyleClass().add("Center");
TabColEspacePrenom.setCellValueFactory(new PropertyValueFactory<CaisseListe, String>("EspacePrenom"));
TabColCateBancaireNumero.setStyle( "-fx-alignment: CENTER;");TabColCateBancaireNumero.getStyleClass().add("Center");
TabColCateBancaireNumero.setCellValueFactory(new PropertyValueFactory<CaisseListe, String>("CateBancaireNumero"));
TabColCateBancaireBanque.setStyle( "-fx-alignment: CENTER;");TabColCateBancaireBanque.getStyleClass().add("Center");
TabColCateBancaireBanque.setCellValueFactory(new PropertyValueFactory<CaisseListe, String>("CateBancaireBanque"));
ButtonEnter.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
try{
DateDebut = DatePickerDebut.getConverter().fromString(DatePickerDebut.getEditor().getText()).toString();
DateFin = DatePickerFin.getConverter().fromString(DatePickerFin.getEditor().getText()).toString();
getCaisseEnterThread();
}catch(Exception ex){}
}
});
this.FiltreCaisse();
this.CaisseEntrePrintButton();
}
private void FiltreCaisse()
{
CheckBoxChequeClt.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
getDetailEnterCheck();
}
});
CheckBoxEspace.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
getDetailEnterCheck();
}
});
CheckBoxCarteBancaire.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
getDetailEnterCheck();
}
});
CheckBoxPaiementTraite.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
getDetailEnterCheck();
}
});
CheckBoxVenteComptant.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
getDetailEnterCheck();
}
});
CheckBoxVenteCommandeAvance.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
getDetailEnterCheck();
}
});
CheckBoxVenteFaciliteAvance.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
getDetailEnterCheck();
}
});
CheckBoxVersementCheque.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
getDetailEnterCheck();
}
});
CheckBoxVersementCheque.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
getDetailEnterCheck();
}
});
}
public void getCaisseEnterThread()
{
TotalEnter.setText("--");
DatePickerDebut.setDisable(true);
DatePickerFin.setDisable(true);
ButtonEnter.setDisable(true);
ButtonPrintCaisseEntre.setDisable(true);
ProgressBarCaisseEnterClt.setVisible(true);
TableViewCaisseCltEnter.setItems(null);
CheckBoxChequeClt.setSelected(true);
CheckBoxEspace.setSelected(true);
CheckBoxCarteBancaire.setSelected(true);
CheckBoxPaiementTraite.setSelected(true);
CheckBoxVenteComptant.setSelected(true);
CheckBoxVenteCommandeAvance.setSelected(true);
CheckBoxVenteFaciliteAvance.setSelected(true);
CheckBoxVersementCheque.setSelected(true);
ThreadCaisseEnter = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
ObsListCaisseCltEnter = CaisseDB.GetDataCaisseCltEnter(DateDebut, DateFin);
int indice = 0;
float FloatTotalEnter = 0;
while(indice<ObsListCaisseCltEnter.size()){
FloatTotalEnter += ObsListCaisseCltEnter.get(indice).getFloatMontant();
indice++;
}
TotalEnter.setText(Adaptateur.FloatToStringEspaceCurrency(FloatTotalEnter));
TempoObsListCaisseCltEnter = ObsListCaisseCltEnter;
TableViewCaisseCltEnter.setItems(ObsListCaisseCltEnter);
return null;
}
};
}
};
ThreadCaisseEnter.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarCaisseEnterClt.setVisible(false);
DatePickerDebut.setDisable(false);
DatePickerFin.setDisable(false);
ButtonEnter.setDisable(false);
ButtonPrintCaisseEntre.setDisable(false);
}
});
ThreadCaisseEnter.start();
}
private void CaisseEntrePrintButton()
{
ButtonPrintCaisseEntre.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
String strPaiment = "";
if(CheckBoxChequeClt.isSelected()){ strPaiment += "Chéque | "; }
if(CheckBoxEspace.isSelected()){ strPaiment += "Espéce | "; }
if(CheckBoxCarteBancaire.isSelected()){ strPaiment += "Carte Bancaire | "; }
strPaiment = strPaiment.substring(0, strPaiment.length() - 3);
String strType = "";
if(CheckBoxPaiementTraite.isSelected()){ strType += "Traite | "; }
if(CheckBoxVenteComptant.isSelected()){ strType += "Vente Comptant | "; }
if(CheckBoxVenteCommandeAvance.isSelected()){ strType += "Vente Commande Avance | "; }
if(CheckBoxVenteFaciliteAvance.isSelected()){ strType += "Vente Facilité Avance | "; }
if(CheckBoxVersementCheque.isSelected()){ strType += "Chèque | "; }
strType = strType.substring(0, strType.length() - 3);
int SizelistCaisseCltEntert = TempoObsListCaisseCltEnter.size();
int total = SizelistCaisseCltEntert / 13 + 1 ;
int page = 0;
String strEspace; String strCheque; String strCarteBancaire;
PrinterJob jobPrint = PrinterJob.createPrinterJob();
jobPrint.getJobSettings().setPageRanges(new PageRange(1, total));
if (jobPrint.showPrintDialog(null))
{
Printer printer = jobPrint.getPrinter();
PageLayout pageLayout = printer.createPageLayout(Paper.A4, PageOrientation.LANDSCAPE, Printer.MarginType.DEFAULT);
for (int i=0; i<SizelistCaisseCltEntert; i+=13)
{
try {
ObservableList<CaisseEntreListe> listTemp = FXCollections.observableArrayList();
for (int j=i; (j<(i+13)) && (j<SizelistCaisseCltEntert); j++)
{
CaisseListe ListCaisseClt = TempoObsListCaisseCltEnter.get(j);
strEspace =""; strCheque=""; strCarteBancaire="";
if(!clt.isStringNull(ListCaisseClt.getChequeCltNumero())){
strCheque = ListCaisseClt.getChequeCltNumero()+" - " +ListCaisseClt.getChequeCltBanque();
}else if(!clt.isStringNull(ListCaisseClt.getCateBancaireNumero())){
strCarteBancaire = ListCaisseClt.getCateBancaireNumero()+" - "+ListCaisseClt.getCateBancaireBanque();
}else{
strEspace = ListCaisseClt.getEspaceNom()+" "+ListCaisseClt.getEspacePrenom();
}
listTemp.add(new CaisseEntreListe(
ListCaisseClt.getIdCaisseClt(),
ListCaisseClt.getCodeType(),
ListCaisseClt.getType(),
ListCaisseClt.getDate(),
ListCaisseClt.getMontant(),
strCheque,
strEspace,
strCarteBancaire,
ListCaisseClt.getFloatMontant()
));
}
FXMLLoader fxmlLoaderCaisseEntrePrint = new FXMLLoader(getClass().getResource("/Views/Caisse/CaisseEntrePrint.fxml"));
final Node ParentFxmlCaisseEntrePrint = (Node)fxmlLoaderCaisseEntrePrint.load();
CaisseEntrePrintController caisseEntrePrintController = fxmlLoaderCaisseEntrePrint.getController();
page++;
caisseEntrePrintController.setCaisseEntrePrint(
Adaptateur.NormalDateFormat(DateDebut)+" à "+Adaptateur.NormalDateFormat(DateFin),
ParametreSystem.NomLocalPC,
TotalEnter.getText(),
strPaiment,
page+"/"+total,
strType,
listTemp);
jobPrint.printPage(pageLayout, ParentFxmlCaisseEntrePrint);
} catch (IOException ex) {
Logger.getLogger(CaisseEntreController.class.getName()).log(Level.SEVERE, null, ex);
}
}
jobPrint.endJob();
}
}
});
}
}
@@ -0,0 +1,78 @@
package Controllers.Caisse;
import Models.Caisse.CaisseEntreListe;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.text.Text;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class CaisseEntrePrintController implements Initializable {
@FXML private Text TextDate;
@FXML private Text TextLocal;
@FXML private Text TextMontant;
@FXML private Text TextPaiement;
@FXML private Text TextPage;
@FXML private Text TextType;
@FXML public TableView<CaisseEntreListe> TableViewCaisseCltEnter ;
@FXML private TableColumn<CaisseEntreListe ,String> TabColIdCaisse;
@FXML private TableColumn<CaisseEntreListe ,String> TabColType;
@FXML private TableColumn<CaisseEntreListe ,String> TabColDate;
@FXML private TableColumn<CaisseEntreListe ,String> TabColMontant;
@FXML private TableColumn<CaisseEntreListe ,String> TabColChequeClt;
@FXML private TableColumn<CaisseEntreListe ,String> TabColEspece;
@FXML private TableColumn<CaisseEntreListe ,String> TabColCateBancaire;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
TabColIdCaisse.setStyle( "-fx-alignment: CENTER;");TabColIdCaisse.getStyleClass().add("Center");
TabColIdCaisse.setCellValueFactory(new PropertyValueFactory<CaisseEntreListe, String>("IdCaisseClt"));
TabColType.setCellValueFactory(new PropertyValueFactory<CaisseEntreListe, String>("Type"));
TabColDate.setCellValueFactory(new PropertyValueFactory<CaisseEntreListe, String>("Date"));
TabColMontant.setStyle( "-fx-alignment: CENTER;");TabColMontant.getStyleClass().add("Center");
TabColMontant.setCellValueFactory(new PropertyValueFactory<CaisseEntreListe, String>("Montant"));
TabColChequeClt.setCellValueFactory(new PropertyValueFactory<CaisseEntreListe, String>("Cheque"));
TabColEspece.setCellValueFactory(new PropertyValueFactory<CaisseEntreListe, String>("Espece"));
TabColCateBancaire.setCellValueFactory(new PropertyValueFactory<CaisseEntreListe, String>("CateBancaire"));
}
public void setCaisseEntrePrint(String Date,
String Local,
String Montant,
String Paiement,
String Page,
String Type,
ObservableList<CaisseEntreListe> obsListCaisseCltEnter )
{
TextDate.setText(Date);
TextLocal.setText(Local);
TextMontant.setText(Montant);
TextPaiement.setText(Paiement);
TextPage.setText(Page);
TextType.setText(Type);
TableViewCaisseCltEnter.setItems(obsListCaisseCltEnter);
}
}
@@ -0,0 +1,437 @@
package Controllers.Caisse;
import Controllers.Traitement.Adaptateur;
import Controllers.Traitement.ParametreSystem;
import Controllers.Traitement.contro;
import Models.Caisse.CaisseDB;
import Models.Caisse.CaisseSortieListe;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.time.LocalDate;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
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.print.PageLayout;
import javafx.print.PageOrientation;
import javafx.print.PageRange;
import javafx.print.Paper;
import javafx.print.Printer;
import javafx.print.PrinterJob;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Text;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class CaisseSortieController implements Initializable {
@FXML private AnchorPane AnchorPaneCaisseClt;
@FXML private DatePicker DatePickerDebut;
@FXML private DatePicker DatePickerFin;
@FXML private Text TotalSortie;
@FXML private CheckBox CheckBoxChequeClt;
@FXML private CheckBox CheckBoxEspace;
@FXML private CheckBox CheckBoxCarteBancaire;
@FXML private CheckBox CheckBoxAchatFrs;
@FXML private CheckBox CheckBoxFraisFrs;
@FXML private CheckBox CheckBoxTraiteFrs;
@FXML private CheckBox CheckBoxAvoirV;
@FXML private Button ButtonSortie;
@FXML private Button ButtonPrintCaisseSortie;
@FXML private ProgressBar ProgressBarCaisseSortieFrs;
@FXML private TableView<CaisseSortieListe> TableViewCaisseFrsSortie ;
@FXML private TableColumn<CaisseSortieListe ,String> TabColIdCaisseFrs;
@FXML private TableColumn<CaisseSortieListe ,String> TabColTypeFrs;
@FXML private TableColumn<CaisseSortieListe ,String> TabColDateFrs;
@FXML private TableColumn<CaisseSortieListe ,String> TabColMontantFrs;
@FXML private TableColumn<CaisseSortieListe ,String> TabColEspeceFrs;
@FXML private TableColumn<CaisseSortieListe ,String> TabColChequeFrs;
@FXML private TableColumn<CaisseSortieListe ,String> TabColCarteBancaireFrs;
private Service<Void> ThreadCaisseSortie;
CaisseDB CaisseDB= new CaisseDB();
ObservableList<CaisseSortieListe> ObsListCaisseFrsSortie;
ObservableList<CaisseSortieListe> TempoObsListCaisseFrsSortie;
private String DateDebut ;
private String DateFin;
contro clt = new contro();
@Override
public void initialize(URL url, ResourceBundle rb) {
DatePickerDebut.setValue(LocalDate.now());
DatePickerFin.setValue(LocalDate.now());
DateDebut = DatePickerDebut.getValue().toString();
DateFin = DatePickerFin.getValue().toString();
TabColIdCaisseFrs.setStyle( "-fx-alignment: CENTER;");TabColIdCaisseFrs.getStyleClass().add("Center");
TabColIdCaisseFrs.setCellValueFactory(new PropertyValueFactory<CaisseSortieListe, String>("IdCaisseClt"));
TabColTypeFrs.setStyle( "-fx-alignment: CENTER;");TabColTypeFrs.getStyleClass().add("Center");
TabColTypeFrs.setCellValueFactory(new PropertyValueFactory<CaisseSortieListe, String>("Type"));
TabColDateFrs.setStyle( "-fx-alignment: CENTER;");TabColDateFrs.getStyleClass().add("Center");
TabColDateFrs.setCellValueFactory(new PropertyValueFactory<CaisseSortieListe, String>("Date"));
TabColMontantFrs.setStyle( "-fx-alignment: CENTER;");TabColMontantFrs.getStyleClass().add("Center");
TabColMontantFrs.setCellValueFactory(new PropertyValueFactory<CaisseSortieListe, String>("Montant"));
TabColEspeceFrs.setStyle( "-fx-alignment: CENTER;");TabColEspeceFrs.getStyleClass().add("Center");
TabColEspeceFrs.setCellValueFactory(new PropertyValueFactory<CaisseSortieListe, String>("Espece"));
TabColChequeFrs.setStyle( "-fx-alignment: CENTER;");TabColChequeFrs.getStyleClass().add("Center");
TabColChequeFrs.setCellValueFactory(new PropertyValueFactory<CaisseSortieListe, String>("Cheque"));
TabColCarteBancaireFrs.setStyle( "-fx-alignment: CENTER;");TabColCarteBancaireFrs.getStyleClass().add("Center");
TabColCarteBancaireFrs.setCellValueFactory(new PropertyValueFactory<CaisseSortieListe, String>("CarteBancaire"));
ButtonSortie.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
try{
DateDebut = DatePickerDebut.getConverter().fromString(DatePickerDebut.getEditor().getText()).toString();
DateFin = DatePickerFin.getConverter().fromString(DatePickerFin.getEditor().getText()).toString();
getCaisseSortieThread();
}catch(Exception ex){}
}
});
this.FiltreCaisse();
this.CaisseSortiePrintButton();
}
private void FiltreCaisse(){
CheckBoxChequeClt.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
getDetailSortieCheck();
}
});
CheckBoxEspace.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
getDetailSortieCheck();
}
});
CheckBoxCarteBancaire.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
getDetailSortieCheck();
}
});
CheckBoxAchatFrs.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
getDetailSortieCheck();
}
});
CheckBoxFraisFrs.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
getDetailSortieCheck();
}
});
CheckBoxTraiteFrs.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
getDetailSortieCheck();
}
});
CheckBoxAvoirV.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
getDetailSortieCheck();
}
});
}
public void getCaisseSortieThread()
{
TotalSortie.setText("--");
DatePickerDebut.setDisable(true);
DatePickerFin.setDisable(true);
ButtonSortie.setDisable(true);
ButtonPrintCaisseSortie.setDisable(true);
ProgressBarCaisseSortieFrs.setVisible(true);
TableViewCaisseFrsSortie.setItems(null);
CheckBoxChequeClt.setSelected(true);
CheckBoxEspace.setSelected(true);
CheckBoxCarteBancaire.setSelected(true);
//Sortie
CheckBoxAchatFrs.setSelected(true);
CheckBoxFraisFrs.setSelected(true);
ThreadCaisseSortie = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
/*******************Sortie**********************/
ObsListCaisseFrsSortie = CaisseDB.GetDataCaisseFrsSortie(DateDebut, DateFin);
System.out.println(ObsListCaisseFrsSortie.size());
TempoObsListCaisseFrsSortie = ObsListCaisseFrsSortie;
int indiceSortie = 0;
float FloatTotalSortie = 0;
while(indiceSortie<ObsListCaisseFrsSortie.size()){
FloatTotalSortie += ObsListCaisseFrsSortie.get(indiceSortie).getFloatMontant();
indiceSortie++;
}
TotalSortie.setText(Adaptateur.FloatToStringEspaceCurrency(FloatTotalSortie));
TableViewCaisseFrsSortie.setItems(ObsListCaisseFrsSortie);
return null;
}
};
}
};
ThreadCaisseSortie.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarCaisseSortieFrs.setVisible(false);
DatePickerDebut.setDisable(false);
DatePickerFin.setDisable(false);
ButtonPrintCaisseSortie.setDisable(false);
ButtonSortie.setDisable(false);
}
});
ThreadCaisseSortie.start();
}
public void getDetailSortieCheck(){
TempoObsListCaisseFrsSortie = FXCollections.observableArrayList();
boolean CheckCheque = CheckBoxChequeClt.isSelected();
boolean CheckEspace = CheckBoxEspace.isSelected();
boolean CheckCarteBancaire= CheckBoxCarteBancaire.isSelected();
boolean CheckFrais = CheckBoxFraisFrs.isSelected();
boolean CheckAchat = CheckBoxAchatFrs.isSelected();
boolean CheckTraite = CheckBoxTraiteFrs.isSelected();
boolean CheckAvoirV = CheckBoxAvoirV.isSelected();
float FloatTotalSortie = 0;
// 0-Vente Comptant | 1-Vente Facilité Avance | 2 Vente Commande Avance | 3 traite clt | 4 ChequeClt
if(ObsListCaisseFrsSortie.size()>0){
int indice = 0;
while(indice<ObsListCaisseFrsSortie.size()){
CaisseSortieListe ListCaisseFrsSortie = ObsListCaisseFrsSortie.get(indice);
//Achat
if(CheckAchat && (ListCaisseFrsSortie.getType().equals("Achat")) ){
//Paiement Espace
if(CheckEspace && (ListCaisseFrsSortie.getCodeType().equals("Espèce")) ){
FloatTotalSortie += ListCaisseFrsSortie.getFloatMontant();
TempoObsListCaisseFrsSortie.add(ListCaisseFrsSortie);
}
//Paiement Chèque
if(CheckCheque && (ListCaisseFrsSortie.getCodeType().equals("Chèque")) ){
FloatTotalSortie += ListCaisseFrsSortie.getFloatMontant();
TempoObsListCaisseFrsSortie.add(ListCaisseFrsSortie);
}
//Paiement Carte Bancaire
if(CheckCarteBancaire && (ListCaisseFrsSortie.getCodeType().equals("Carte Bancaire")) ){
FloatTotalSortie += ListCaisseFrsSortie.getFloatMontant();
TempoObsListCaisseFrsSortie.add(ListCaisseFrsSortie);
}
//Traite Frs
if(CheckTraite && (ListCaisseFrsSortie.getCodeType().equals("Traite")) ){
FloatTotalSortie += ListCaisseFrsSortie.getFloatMontant();
TempoObsListCaisseFrsSortie.add(ListCaisseFrsSortie);
}
}
//Frais
if(CheckFrais && (ListCaisseFrsSortie.getType().equals("Frais")) ){
//Paiement Espace
if(CheckEspace && (ListCaisseFrsSortie.getCodeType().equals("Espèce")) ){
FloatTotalSortie += ListCaisseFrsSortie.getFloatMontant();
TempoObsListCaisseFrsSortie.add(ListCaisseFrsSortie);
}
//Paiement Chèque
if(CheckCheque && (ListCaisseFrsSortie.getCodeType().equals("Chèque")) ){
FloatTotalSortie += ListCaisseFrsSortie.getFloatMontant();
TempoObsListCaisseFrsSortie.add(ListCaisseFrsSortie);
}
//Paiement Carte Bancaire
if(CheckCarteBancaire && (ListCaisseFrsSortie.getCodeType().equals("Carte Bancaire")) ){
FloatTotalSortie += ListCaisseFrsSortie.getFloatMontant();
TempoObsListCaisseFrsSortie.add(ListCaisseFrsSortie);
}
}
//Avoir Vente Sans Facture
if(CheckAvoirV && (ListCaisseFrsSortie.getType().equals("Avoir VSF")) ){
//Paiement Espace
if(CheckEspace && (ListCaisseFrsSortie.getCodeType().equals("Espèce")) ){
FloatTotalSortie += ListCaisseFrsSortie.getFloatMontant();
TempoObsListCaisseFrsSortie.add(ListCaisseFrsSortie);
}
//Paiement Chèque
if(CheckCheque && (ListCaisseFrsSortie.getCodeType().equals("Chèque")) ){
FloatTotalSortie += ListCaisseFrsSortie.getFloatMontant();
TempoObsListCaisseFrsSortie.add(ListCaisseFrsSortie);
}
//Paiement Carte Bancaire
if(CheckCarteBancaire && (ListCaisseFrsSortie.getCodeType().equals("Carte Bancaire")) ){
FloatTotalSortie += ListCaisseFrsSortie.getFloatMontant();
TempoObsListCaisseFrsSortie.add(ListCaisseFrsSortie);
}
}
//Traite
if(CheckTraite && (ListCaisseFrsSortie.getType().equals("Traite")) ){
//Paiement Espace
if(CheckEspace && (ListCaisseFrsSortie.getCodeType().equals("Espèce")) ){
FloatTotalSortie += ListCaisseFrsSortie.getFloatMontant();
TempoObsListCaisseFrsSortie.add(ListCaisseFrsSortie);
}
}
indice++;
}
TableViewCaisseFrsSortie.setItems(null);
TableViewCaisseFrsSortie.setItems(TempoObsListCaisseFrsSortie);
TotalSortie.setText(Adaptateur.FloatToStringEspaceCurrency(FloatTotalSortie));
}
}
private void CaisseSortiePrintButton()
{
ButtonPrintCaisseSortie.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
String strPaiment = "";
if(CheckBoxChequeClt.isSelected()){ strPaiment += "Chéque | "; }
if(CheckBoxEspace.isSelected()){ strPaiment += "Espéce | "; }
if(CheckBoxCarteBancaire.isSelected()){ strPaiment += "Carte Bancaire | "; }
strPaiment = strPaiment.substring(0, strPaiment.length() - 3);
String strType = "";
if(CheckBoxAchatFrs.isSelected()){ strType += "Achat | "; }
if(CheckBoxFraisFrs.isSelected()){ strType += "Frais | "; }
if(CheckBoxTraiteFrs.isSelected()){ strType += "Traite | "; }
if(CheckBoxAvoirV.isSelected()){ strType += "Avoir | "; }
strType = strType.substring(0, strType.length() - 3);
int SizelistCaisseCltSortiet = TempoObsListCaisseFrsSortie.size();
int total = SizelistCaisseCltSortiet / 13 + 1 ;
int page = 0;
PrinterJob jobPrint = PrinterJob.createPrinterJob();
jobPrint.getJobSettings().setPageRanges(new PageRange(1, total));
if (jobPrint.showPrintDialog(null))
{
Printer printer = jobPrint.getPrinter();
PageLayout pageLayout = printer.createPageLayout(Paper.A4, PageOrientation.LANDSCAPE, Printer.MarginType.DEFAULT);
for (int i=0; i<SizelistCaisseCltSortiet; i+=13)
{
try {
ObservableList<CaisseSortieListe> listTemp = FXCollections.observableArrayList();
for (int j=i; (j<(i+13)) && (j<SizelistCaisseCltSortiet); j++)
{
CaisseSortieListe ListCaisseClt = TempoObsListCaisseFrsSortie.get(j);
listTemp.add(ListCaisseClt);
}
FXMLLoader fxmlLoaderCaisseSortiePrint = new FXMLLoader(getClass().getResource("/Views/Caisse/CaisseSortiePrint.fxml"));
final Node ParentFxmlCaisseSortiePrint = (Node)fxmlLoaderCaisseSortiePrint.load();
CaisseSortiePrintController caisseSortiePrintController = fxmlLoaderCaisseSortiePrint.getController();
page++;
caisseSortiePrintController.setCaisseSortiePrint(
Adaptateur.NormalDateFormat(DateDebut)+" à "+Adaptateur.NormalDateFormat(DateFin),
ParametreSystem.NomLocalPC,
TotalSortie.getText(),
strPaiment,
page+"/"+total,
strType,
listTemp);
jobPrint.printPage(pageLayout, ParentFxmlCaisseSortiePrint);
} catch (IOException ex) {
Logger.getLogger(CaisseSortieController.class.getName()).log(Level.SEVERE, null, ex);
}
}
jobPrint.endJob();
}
}
});
}
}
@@ -0,0 +1,78 @@
package Controllers.Caisse;
import Models.Caisse.CaisseSortieListe;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.text.Text;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class CaisseSortiePrintController implements Initializable {
@FXML private Text TextDate;
@FXML private Text TextLocal;
@FXML private Text TextMontant;
@FXML private Text TextPaiement;
@FXML private Text TextPage;
@FXML private Text TextType;
@FXML public TableView<CaisseSortieListe> TableViewCaisseCltSortie ;
@FXML private TableColumn<CaisseSortieListe ,String> TabColIdCaisse;
@FXML private TableColumn<CaisseSortieListe ,String> TabColType;
@FXML private TableColumn<CaisseSortieListe ,String> TabColDate;
@FXML private TableColumn<CaisseSortieListe ,String> TabColMontant;
@FXML private TableColumn<CaisseSortieListe ,String> TabColChequeClt;
@FXML private TableColumn<CaisseSortieListe ,String> TabColEspece;
@FXML private TableColumn<CaisseSortieListe ,String> TabColCarteBancaire;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
TabColIdCaisse.setStyle( "-fx-alignment: CENTER;");TabColIdCaisse.getStyleClass().add("Center");
TabColIdCaisse.setCellValueFactory(new PropertyValueFactory<CaisseSortieListe, String>("IdCaisseClt"));
TabColType.setCellValueFactory(new PropertyValueFactory<CaisseSortieListe, String>("Type"));
TabColDate.setCellValueFactory(new PropertyValueFactory<CaisseSortieListe, String>("Date"));
TabColMontant.setStyle( "-fx-alignment: CENTER;");TabColMontant.getStyleClass().add("Center");
TabColMontant.setCellValueFactory(new PropertyValueFactory<CaisseSortieListe, String>("Montant"));
TabColChequeClt.setCellValueFactory(new PropertyValueFactory<CaisseSortieListe, String>("Cheque"));
TabColEspece.setCellValueFactory(new PropertyValueFactory<CaisseSortieListe, String>("Espece"));
TabColCarteBancaire.setCellValueFactory(new PropertyValueFactory<CaisseSortieListe, String>("CarteBancaire"));
}
public void setCaisseSortiePrint(String Date,
String Local,
String Montant,
String Paiement,
String Page,
String Type,
ObservableList<CaisseSortieListe> obsListCaisseCltSortie )
{
TextDate.setText(Date);
TextLocal.setText(Local);
TextMontant.setText(Montant);
TextPaiement.setText(Paiement);
TextPage.setText(Page);
TextType.setText(Type);
TableViewCaisseCltSortie.setItems(obsListCaisseCltSortie);
}
}
@@ -0,0 +1,220 @@
package Controllers.Caisse;
import Controllers.Traitement.contro;
import Models.Caisse.Frais;
import Models.Caisse.FraisDB;
import Models.User.User;
import java.io.IOException;
import java.net.URL;
import java.time.LocalDateTime;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.animation.FadeTransition;
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.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.DatePicker;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.util.Duration;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class FraisAjouterController implements Initializable {
@FXML private AnchorPane PaneAjouterFrais ;
@FXML private AnchorPane AnchorPaneFrais ;
@FXML private StackPane StackPaneSucces;
@FXML private ProgressIndicator ProgrssLoading;
@FXML private Button ButtonAjouterFrais;
@FXML private TextField TextFieldMontant;
@FXML private RadioButton RadioEspace;
@FXML private RadioButton RadioCheque;
@FXML private GridPane GridPaneCheque;
@FXML private TextField TextFieldNumeroCheque;
@FXML private TextField TextFieldBanqueCheque;
@FXML private DatePicker DatePickerDateCheque;
@FXML private RadioButton RadioCarte;
@FXML private GridPane GridPaneCarte;
@FXML private TextField TextFieldNumeroTransation;
@FXML private TextField TextFieldBanqueCarte;
@FXML private TextField TextFieldObject;
@FXML private TextField TextFieldPersonne;
@FXML private TextArea TextAreaContenu;
@FXML private Text ErreurMontant;
@FXML private Text ErreurNumeroCheque;
@FXML private Text ErreurBanqueCheque;
@FXML private Text ErreurDateCheque;
@FXML private Text ErreurTransaction;
@FXML private Text ErreurBanqueCart;
@FXML private Text ErreurObject;
private Service<Void> ThreadFrais;
Frais frais = new Frais();
FraisDB fraisDB = new FraisDB();
contro ctl= new contro() ;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
frais.setPaiement("0");
this.TypePaiement();
}
@FXML
private void AjouterFraisButtonAction(ActionEvent event) throws IOException
{
if(this.ContoleFrais())
{
ButtonAjouterFrais.setDisable(true);
ButtonAjouterFrais.setText("");
ThreadFrais = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
ProgrssLoading.setVisible(true);
frais = fraisDB.setFrais(frais);
return null;
}
};
}
};
ThreadFrais.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
FadeTransition ft = new FadeTransition(Duration.millis(400), AnchorPaneFrais);
ft.setFromValue(1.0);
ft.setToValue(0.0);
ft.play();
ft.setOnFinished(new EventHandler<ActionEvent>() {
//message de succés
@Override
public void handle(ActionEvent event) {
StackPaneSucces.setVisible(true);
}
});
}
});
ThreadFrais.start();
}
}
private Boolean ContoleFrais()
{
Boolean result = false;
if( ctl.ContrReelNotNull(TextFieldMontant,ErreurMontant) &&
ctl.ContrNull(TextFieldObject,ErreurObject) ){
frais.setMontant(TextFieldMontant.getText());
frais.setObject(TextFieldObject.getText());
frais.setPersonne(TextFieldPersonne.getText());
frais.setDateCreation(LocalDateTime.now().toString());
frais.setProfile(User.idprofile+"");
frais.setLocalNom(User.UserLocal);
frais.setContext(TextAreaContenu.getText());
if( frais.getPaiement().equals("1") &&
ctl.ContrNull(TextFieldNumeroCheque, ErreurNumeroCheque) &&
ctl.ContrNull(TextFieldBanqueCheque, ErreurBanqueCheque) &&
ctl.ContrNullDatePicker(DatePickerDateCheque, ErreurDateCheque)){
frais.setNumero(TextFieldNumeroCheque.getText());
frais.setBanque(TextFieldBanqueCheque.getText());
frais.setDateCheque(DatePickerDateCheque.getValue().toString());
result = true;
}else if(frais.getPaiement().equals("2") &&
ctl.ContrNull(TextFieldNumeroTransation, ErreurTransaction) &&
ctl.ContrNull(TextFieldBanqueCarte, ErreurBanqueCart) ){
frais.setBanque(TextFieldBanqueCarte.getText());
frais.setNumero(TextFieldNumeroTransation.getText());
result = true;
}else if(frais.getPaiement().equals("0")){
result = true;
}
}
return result;
}
private void TypePaiement()
{
//0 :espèce 1:Chèque 2 :carte bancaire
RadioEspace.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
GridPaneCheque.setVisible(false);
GridPaneCarte.setVisible(false);
frais.setPaiement("0");
}
});
RadioCheque.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
GridPaneCheque.setVisible(true);
GridPaneCarte.setVisible(false);
frais.setPaiement("1");
}
});
RadioCarte.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
GridPaneCheque.setVisible(false);
GridPaneCarte.setVisible(true);
frais.setPaiement("2");
}
});
}
//ajouter un nouvelle catégorie
@FXML
private void AfficherAjouterFraisButtonAction(ActionEvent event) throws IOException {
FadeTransition ft = new FadeTransition(Duration.millis(400), StackPaneSucces);
ft.setFromValue(1.0);
ft.setToValue(0.0);
ft.setOnFinished(new EventHandler<ActionEvent>() {
//message de succés
@Override
public void handle(ActionEvent event) {
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Caisse/FraisAjouter.fxml"));
Parent NodeDetail = (Parent)fxmlLoader.load();
PaneAjouterFrais.getChildren().add(NodeDetail);
} catch (IOException ex) {
Logger.getLogger(FraisAjouterController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
ft.play();
}
}
@@ -0,0 +1,157 @@
package Controllers.Caisse;
import Controllers.Traitement.Adaptateur;
import Controllers.Traitement.MyWindow;
import Models.Caisse.Frais;
import Models.Caisse.FraisDB;
import Models.Reglement.Reglement;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
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.Node;
import javafx.scene.Scene;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.scene.web.HTMLEditor;
import javafx.stage.Stage;
/**
* FXML Controller class
* @author Maher
*/
public class FraisDetailController {
public Node nodeFxml ;
@FXML public AnchorPane AnchorPrincipal ;
@FXML public AnchorPane PaneDetailFrais;
@FXML private Text TextMontant;
@FXML private Text TextPaiement;
@FXML private Text TextChequeNumero;
@FXML private Text TextChequeBanque;
@FXML private Text TextChequeDate;
@FXML private Text TextCarteTransation;
@FXML private Text TextCarteBanque;
@FXML private Text TextPersonne;
@FXML private Text TextDateCreation;
@FXML private Text TextProfile;
@FXML private Text TextObject;
@FXML private GridPane GridPaneCheque;
@FXML private GridPane GridPaneCarte;
@FXML private HTMLEditor HTMLEditorContext ;
@FXML private ProgressIndicator ProgressFrais;
private Service<Void> ThreadFraisDetail;
Frais frais = new Frais();
public FraisDetailController(){
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Caisse/FraisDetail.fxml"));
fxmlLoader.setController(this);
nodeFxml = (Node) fxmlLoader.load();
} catch (Exception ex) {
System.err.println(ex.getMessage());
}
}
public void setFrais(Frais frais){
TextMontant.setText(frais.getMontant());
TextPaiement.setText(frais.getPaiementString());
if(frais.getPaiement().equals("1")){
GridPaneCheque.setVisible(true);
TextChequeNumero.setText(frais.getNumero());
TextChequeBanque.setText(frais.getBanque());
TextChequeDate.setText(frais.getDateCheque());
}
if(frais.getPaiement().equals("2")){
GridPaneCarte.setVisible(true);
TextCarteTransation.setText(frais.getNumero());
TextCarteBanque.setText(frais.getBanque());
}
TextPersonne.setText(frais.getPersonne());
TextDateCreation.setText(frais.getDateCreation());
TextProfile.setText(frais.getProfile());
TextObject.setText(frais.getObject());
if(frais.getContext() != null){
if(!frais.getContext().equals("")){
HTMLEditorContext.setHtmlText(frais.getContext());
}
}
}
public void LanchShowFrais(final String IdFrais){
ThreadFraisDetail = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
frais = new FraisDB().getFrais(IdFrais);
return null;
}
};
}
};
ThreadFraisDetail.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
setFrais(frais);
ProgressFrais.setVisible(false);
PaneDetailFrais.setVisible(true);
}
});
ThreadFraisDetail.start();
}
@FXML
private void ExitButtonAction(ActionEvent event) throws IOException {
AnchorPrincipal.setVisible(false);
}
public void Show()
{
StackPane Sp = new StackPane();
Scene scene = new Scene(Sp);
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Stage stage = MyWindow.myStage;
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(nodeFxml);
stage.setScene(scene);
stage.show();
}
}
@@ -0,0 +1,424 @@
package Controllers.Caisse;
import Models.Caisse.Frais;
import Models.Caisse.FraisDB;
import Models.Stock.StockDB;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Group;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
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 com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.concurrent.WorkerStateEvent;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
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.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.util.Callback;
/**
* FXML Controller class
* @author Maher
*/
public class FraisGestionController implements Initializable {
@FXML private AnchorPane PaneGestionFrais ;
@FXML private TextField TextFieldCodeFrais;
@FXML private TextField TextFieldObject;
@FXML private TextField TextFieldPresonne;
@FXML private ComboBox ComboBoxLocale ;
@FXML private ComboBox ComboBoxPaiement;
@FXML private DatePicker DatePickerCreate;
@FXML private ProgressBar ProgressBarFraisGestion;
@FXML private Button ButtonSearchFraisGestion;
@FXML private TableView<Frais> TableViewFrais;
@FXML private TableColumn<Frais ,String> TabColIdFrais;
@FXML private TableColumn<Frais ,String> TabColMontant;
@FXML private TableColumn<Frais ,String> TabColObject;
@FXML private TableColumn<Frais ,String> TabColDateCreation;
@FXML private TableColumn<Frais ,String> TabColPaiement;
@FXML private TableColumn<Frais ,String> TabColProfile;
@FXML private TableColumn<Frais ,String> TabColLocalNom;
@FXML private TableColumn<Frais ,Boolean>TabColDetail ;
@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 ;
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;
private Service<Void> ThreadSearchFraisGestion;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
NbrLigne.setItems(cursors);
NbrLigne.getSelectionModel().selectFirst();
ComboBoxLocale.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent t) {
if(ComboBoxLocale.getItems().size() == 0){
ComboBoxLocale.getItems().addAll(new StockDB().getAllListLocal());
}
}
});
//0:Espèce 1:Chèque 2 :carte bancaire
ComboBoxPaiement.setItems(FXCollections.observableArrayList("Espèces","Chèque","Carte Bancaire"));
TabColIdFrais.setStyle( "-fx-alignment: CENTER;");TabColIdFrais.getStyleClass().add("Center");
TabColIdFrais.setCellValueFactory(new PropertyValueFactory<Frais, String>("IdFrais"));
TabColMontant.setStyle( "-fx-alignment: CENTER;");TabColMontant.getStyleClass().add("Center");
TabColMontant.setCellValueFactory(new PropertyValueFactory<Frais, String>("Montant"));
TabColObject.setStyle( "-fx-alignment: CENTER;");TabColObject.getStyleClass().add("Center");
TabColObject.setCellValueFactory(new PropertyValueFactory<Frais, String>("Object"));
TabColDateCreation.setStyle( "-fx-alignment: CENTER;");TabColDateCreation.getStyleClass().add("Center");
TabColDateCreation.setCellValueFactory(new PropertyValueFactory<Frais, String>("DateCreation"));
TabColPaiement.setStyle( "-fx-alignment: CENTER;");TabColPaiement.getStyleClass().add("Center");
TabColPaiement.setCellValueFactory(new PropertyValueFactory<Frais, String>("Paiement"));
TabColPaiement.setCellFactory(new Callback<TableColumn<Frais,String>,TableCell<Frais,String>>(){
@Override
public TableCell<Frais, String> call(TableColumn<Frais, String> param) {
TableCell<Frais, String> cell = new TableCell<Frais, String>(){
@Override
public void updateItem(String item, boolean empty) {
////0 :espace 1:Chèque 2 :carte bancaire
if(item!=null && item.equals("0")){
Text text = new Text("Espèce");
text.setFont(Font.font("Arial", FontWeight.NORMAL, 14));
setGraphic(text);
}else if(item!=null && item.equals("1")){
Text text = new Text("Chèque");
text.setFont(Font.font("Arial", FontWeight.NORMAL, 14));
setGraphic(text);
}else if(item!=null && item.equals("2")){
Text text = new Text("Carte Bancaire");
text.setFont(Font.font("Arial", FontWeight.NORMAL, 14));
setGraphic(text);
}else{
setGraphic(null);
}
}
};
return cell;
}
});
TabColProfile.setStyle( "-fx-alignment: CENTER;");TabColProfile.getStyleClass().add("Center");
TabColProfile.setCellValueFactory(new PropertyValueFactory<Frais, String>("Profile"));
TabColLocalNom.setStyle( "-fx-alignment: CENTER;");TabColLocalNom.getStyleClass().add("Center");
TabColLocalNom.setCellValueFactory(new PropertyValueFactory<Frais, String>("LocalNom"));
TabColDetail.setSortable(true);
TabColDetail.setStyle( "-fx-alignment: CENTER;");TabColDetail.getStyleClass().add("Center");
TabColDetail.setCellFactory(new Callback<TableColumn<Frais, Boolean>, TableCell<Frais, Boolean>>() {
@Override
public TableCell<Frais, Boolean> call(TableColumn<Frais, Boolean> personBooleanTableColumn) {
return new ButtonCell();
}
});
ButtonSearchFraisGestion.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchFraisGestion();
}
});
PaneGestionFrais.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchFraisGestion();
}
}
});
GestionSearchFournisseur();
}
//Define the button cell
private class ButtonCell extends TableCell<Frais, 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) {
Frais frais = ((Frais)getTableRow().getItem());
FraisDetailController FraisDetail = new FraisDetailController();
FraisDetail.LanchShowFrais(frais.getIdFrais());
FraisDetail.Show();
}
});
}
//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 AjouterFraisButtonAction(ActionEvent event) throws IOException {
PaneGestionFrais.getChildren().clear();
PaneGestionFrais.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Caisse/FraisAjouter.fxml")));
}
/****************************************************************************** *
* *
* Methode last Next TableView *
* * *
******************************************************************************/
private void SearchFraisGestion()
{
ProgressBarFraisGestion.setVisible(true);
ButtonSearchFraisGestion.setDisable(true);
ThreadSearchFraisGestion = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
position = 0;
actuellepage = 1;
String DateCreation = "";
if(DatePickerCreate.getValue() != null){
DateCreation = DatePickerCreate.getValue().toString();
}
ObservableList<Frais> ListFraisGestions = new FraisDB().SearchFraisGestion(
position,
nbrligne,
TextFieldCodeFrais.getText(),
TextFieldObject.getText(),
TextFieldPresonne.getText(),
(String) ComboBoxLocale.getValue(),
(String) ComboBoxPaiement.getValue(),
DateCreation);
TableViewFrais.setItems(ListFraisGestions);
totalcount = new FraisDB().nbrFraisGestion(TextFieldCodeFrais.getText(), TextFieldObject.getText(), TextFieldPresonne.getText(), (String) ComboBoxLocale.getValue(), (String) ComboBoxPaiement.getValue(), DateCreation);
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;
}
};
}
};
ThreadSearchFraisGestion.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarFraisGestion.setVisible(false);
ButtonSearchFraisGestion.setDisable(false);
LabelCount.setText(totalcount.toString());
}
});
ThreadSearchFraisGestion.start();
}
private void NextLastSearchFraisGestion(Integer ParmPosition, Integer ParamNbrligne)
{
ProgressBarFraisGestion.setVisible(true);
ButtonSearchFraisGestion.setDisable(true);
ThreadSearchFraisGestion = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
String DateCreation = "";
if(DatePickerCreate.getValue() != null){
DateCreation = DatePickerCreate.getValue().toString();
}
ObservableList<Frais> ListFraisGestions = new FraisDB().SearchFraisGestion(ParmPosition, ParamNbrligne, TextFieldCodeFrais.getText(), TextFieldObject.getText(), TextFieldPresonne.getText(), (String) ComboBoxLocale.getValue(), (String) ComboBoxPaiement.getValue(), DateCreation);
TableViewFrais.setItems(ListFraisGestions);
return null;
}
};
}
};
ThreadSearchFraisGestion.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarFraisGestion.setVisible(false);
ButtonSearchFraisGestion.setDisable(false);
}
});
ThreadSearchFraisGestion.start();
}
private void GestionSearchFournisseur()
{
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;
NextLastSearchFraisGestion(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;
NextLastSearchFraisGestion(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;
NextLastSearchFraisGestion(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;
NextLastSearchFraisGestion(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;
NextLastSearchFraisGestion(position, nbrligne);
actuellepage=actuellepage-3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
}
}
@@ -0,0 +1,123 @@
/*
* 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.Categorie;
import Controllers.Traitement.MyWindow;
import Models.Categorie.Categorie;
import Models.Categorie.CategorieDB;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;
/**
* FXML Controller class
*
* @author PC-Maher
*/
public class AjouterCategorieController implements Initializable {
public Node nodeFxml ;
@FXML public AnchorPane AnchorPrincipal ;
@FXML public TextField NomCategorie ;
@FXML private Text erreurCategorie ;
@FXML public ToggleGroup unite ;
@FXML private RadioButton piece ;
@FXML private RadioButton kilo;
@FXML private RadioButton metre;
@FXML private RadioButton litre;
@FXML public Button ButtonAjouterCategory ;
Categorie categorie = new Categorie();
CategorieDB dbcategorie = new CategorieDB();
@Override
public void initialize(URL url, ResourceBundle rb) {
piece.setUserData("0");
kilo.setUserData("1");
metre.setUserData("2");
litre.setUserData("3");
}
public AjouterCategorieController(){
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Categorie/AjouterCategorie.fxml"));
fxmlLoader.setController(this);
nodeFxml = (Node) fxmlLoader.load();
} catch (IOException ex) {
Logger.getLogger(AjouterCategorieController.class.getName()).log(Level.SEVERE, null, ex);
}
}
public String AjouterCategorieTraitement(){
if(NomCategorie.getText().length()==0){ //catégorie est vide
erreurCategorie.setText("catégorie vide");
NomCategorie.setStyle("-fx-border-color:#f20606;");
}
else if(dbcategorie.verifyCategorie(NomCategorie.getText())){
erreurCategorie.setText("catégorie existe déjà");
NomCategorie.setStyle("-fx-border-color:#f20606;");
}
else{
erreurCategorie.setText("");
NomCategorie.setStyle("-fx-border-color: transparent;");
categorie.setNomcategorie(NomCategorie.getText());
categorie.setUnitemesure(Integer.parseInt(unite.getSelectedToggle().getUserData().toString()));
if(dbcategorie.addCategorie(categorie)){
AnchorPrincipal.setVisible(false);
return NomCategorie.getText();
}
}
return "";
}
@FXML
private void AnnulerCategorieButtonAction(ActionEvent event) throws IOException {
AnchorPrincipal.setVisible(false);
}
public void Show()
{
StackPane Sp = new StackPane();
Scene scene = new Scene(Sp);
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Stage stage = MyWindow.myStage;
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(nodeFxml);
stage.setScene(scene);
stage.show();
}
}
@@ -0,0 +1,327 @@
/*
* 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.ChequeClt;
import Controllers.Traitement.Adaptateur;
import Controllers.Traitement.MyWindow;
import Models.ChequeClt.ChequeClt;
import Models.ChequeClt.ChequeCltDB;
import Models.ChequeClt.ChequeCltHistoriqueListe;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Platform;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.util.Callback;
/**
* FXML Controller class
*
* @author Maher
*/
public class ChequeCltDetailController {
@FXML public AnchorPane AnchorPrincipal ;
@FXML private AnchorPane AnchorSecondaire;
@FXML private ProgressIndicator ProgressCheque;
@FXML private Text TextTypeClt;
@FXML private Text TextCode;
@FXML private Text TextNom;
@FXML private Text TextPrenom;
@FXML private Text TextTele1;
@FXML private Text TextTele2;
@FXML private Text TextAdress;
@FXML private Text TextNumCheque1;
@FXML private Text TextNumCheque2;
@FXML private Text TextBanque;
@FXML private Text TextDateCheque;
@FXML private Text TextMontant;
@FXML private Text TextFacture;
@FXML private Text TextUtilisateur;
@FXML private RadioButton RadioVerser;
@FXML private RadioButton RadioSansProvision;
@FXML private RadioButton RadioContreCheque;
@FXML private Button UpdateEtatButton;
@FXML public Button ButtonExitChequeCltDetail;
@FXML public TableView<ChequeCltHistoriqueListe> TableViewChequeCltHistorique;
@FXML public TableColumn<ChequeCltHistoriqueListe ,String> TabColDate;
@FXML public TableColumn<ChequeCltHistoriqueListe ,String> TabColHeur;
@FXML public TableColumn<ChequeCltHistoriqueListe ,Integer> TabColEtat;
@FXML public TableColumn<ChequeCltHistoriqueListe ,String> TabColUtili;
public Node nodeFxml;
public String IdChequeClt;
public String LastEtat;
public Integer Source;
ChequeClt Cheque = new ChequeClt();
public ChequeCltDetailController(){
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/ChequeClt/ChequeCltDetail.fxml"));
fxmlLoader.setController(this);
nodeFxml = (Node) fxmlLoader.load();
} catch (IOException ex) {
Logger.getLogger(ChequeCltDetailController.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void Show()
{
StackPane Sp = new StackPane();
Scene scene = new Scene(Sp);
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Stage stage = MyWindow.myStage;
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(nodeFxml);
stage.setScene(scene);
stage.show();
}
public void ControleUpdateEtatButton(){
if(Cheque.getLastEtat() != null){
if(Cheque.getLastEtat() == 2){
UpdateEtatButton.setDisable(true);
}else{
RadioVerser.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
if(Cheque.getLastEtat() == 1){
UpdateEtatButton.setDisable(true);
}else if((Cheque.getLastEtat() == 0) || (Cheque.getLastEtat() == 1)){
UpdateEtatButton.setDisable(false);
}
}
});
RadioSansProvision.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
if(Cheque.getLastEtat() == 0){
UpdateEtatButton.setDisable(true);
}else if((Cheque.getLastEtat() == 1) || (Cheque.getLastEtat() == 2)){
UpdateEtatButton.setDisable(false);
}
}
});
}
}
}
public void Initialize(String id_cheque, Integer source) {
IdChequeClt = id_cheque;
Source = source;// 0==>Cheque(table cheque_clt) 1==>Traite(table traite_paiement_cheque_clt)
TabColDate.setStyle( "-fx-alignment: CENTER;");
TabColDate.getStyleClass().add("Center");
TabColDate.setCellValueFactory(new PropertyValueFactory<ChequeCltHistoriqueListe, String>("DateOperation"));
TabColHeur.setStyle( "-fx-alignment: CENTER;");
TabColHeur.getStyleClass().add("Center");
TabColHeur.setCellValueFactory(new PropertyValueFactory<ChequeCltHistoriqueListe, String>("HeurOperation"));
TabColEtat.setStyle( "-fx-alignment: CENTER;");
TabColEtat.getStyleClass().add("Center");
TabColEtat.setCellValueFactory(new PropertyValueFactory("Etat"));
TabColEtat.setCellValueFactory(new PropertyValueFactory<ChequeCltHistoriqueListe, Integer>("Etat"));
TabColEtat.setCellFactory(new Callback<TableColumn<ChequeCltHistoriqueListe,Integer>,TableCell<ChequeCltHistoriqueListe,Integer>>(){
@Override
public TableCell<ChequeCltHistoriqueListe, Integer> call(TableColumn<ChequeCltHistoriqueListe, Integer> param) {
TableCell<ChequeCltHistoriqueListe, Integer> cell = new TableCell<ChequeCltHistoriqueListe, Integer>(){
@Override
public void updateItem(Integer item, boolean empty) {
// 0 cheque sans provision 1 Verser (Valider) 2 Contre chéque(espace)
if(item!= null && item == 0){
Text text = new Text("chèque sans provision");
text.setFill(Color.web("#EA4335"));
text.setFont(Font.font("Arial", FontWeight.BOLD, 14));
setGraphic(text);
}else if(item!= null && item == 1){
Text text = new Text("verser");
text.setFill(Color.web("#428BCA"));
text.setFont(Font.font("Arial", FontWeight.BOLD, 14));
setGraphic(text);
}else if(item!= null && item == 2){
Text text = new Text("contre chèque");
text.setFill(Color.web("#34A853"));
text.setFont(Font.font("Arial", FontWeight.BOLD, 14));
setGraphic(text);
}else{
setGraphic(null);
}
}
};
return cell;
}
});
TabColUtili.setStyle( "-fx-alignment: CENTER;");
TabColUtili.getStyleClass().add("Center");
TabColUtili.setCellValueFactory(new PropertyValueFactory<ChequeCltHistoriqueListe, String>("Utilisateur"));
ButtonUpdateEtatAction();
startTask();
}
public void startTask(){
ProgressCheque.setVisible(true);
AnchorSecondaire.setVisible(false);
// Create a Runnable
Runnable task = new Runnable(){
public void run(){
Platform.runLater(new Runnable(){
@Override
public void run(){
SetIdChequeClt();
ProgressCheque.setVisible(false);
AnchorSecondaire.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
}
public void SetIdChequeClt(){
ChequeCltDB ChequeDB = new ChequeCltDB();
Cheque = ChequeDB.getChequeClt(IdChequeClt, Source);
Integer TypeClt = Cheque.getTypeClient();
if(TypeClt == 0){
TextTypeClt.setText("Ancien");
TextCode.setText(Cheque.getCltPersonne().getCodeclient());
TextNom.setText(Cheque.getCltPersonne().getNom());
TextPrenom.setText(Cheque.getCltPersonne().getPrenom());
TextTele1.setText(Cheque.getCltPersonne().getTelefixString());
TextTele2.setText(Cheque.getCltPersonne().getTelemobileString());
TextAdress.setText(Cheque.getCltPersonne().getAdresse());
}else if(TypeClt == 1){
TextTypeClt.setText("Entreprise");
TextCode.setText(Cheque.getCltEntreprise().getCodeString());
TextNom.setText(Cheque.getCltEntreprise().getNom());
TextPrenom.setText(Cheque.getCltEntreprise().getMatricule());
TextTele1.setText(Cheque.getCltEntreprise().getTele1String());
TextTele2.setText(Cheque.getCltEntreprise().getTele2String());
TextAdress.setText(Cheque.getCltEntreprise().getAdresse());
}else if(TypeClt == 2){
TextTypeClt.setText("Passager");
TextCode.setText(Cheque.getCltPassager().getCodeclient());
TextNom.setText(Cheque.getCltPassager().getNom());
TextPrenom.setText(Cheque.getCltPassager().getPrenom());
TextTele1.setText(Cheque.getCltPassager().getTelefixString());
TextTele2.setText(Cheque.getCltPassager().getTelemobileString());
TextAdress.setText(Cheque.getCltPassager().getAdresse());
}
TextNumCheque1.setText(Cheque.getNumeroChequeClt());
TextNumCheque2.setText(Cheque.getNumeroChequeClt());
TextBanque.setText(Cheque.getBanqueChequeClt());
TextDateCheque.setText(Cheque.getDatePaiement());
TextMontant.setText(Adaptateur.FloatToStringEspaceCurrency(Cheque.getMontantFloatChequeClt()));
TextFacture.setText(Cheque.getCodeFactureClt());
TextUtilisateur.setText(Cheque.getProfile().getNom()+" "+Cheque.getProfile().getPrenom());
//Etat 0 cheque sans provision 1 Verser (Valider) 2 Contre chéque(espace)
if(Cheque.getLastEtat() != null){
if(Cheque.getLastEtat() == 1){
RadioVerser.setSelected(true);
UpdateEtatButton.setDisable(true);
}else if(Cheque.getLastEtat() == 0){
RadioSansProvision.setSelected(true);
UpdateEtatButton.setDisable(true);
}else if(Cheque.getLastEtat() == 2){
RadioContreCheque.setSelected(true);
UpdateEtatButton.setDisable(true);
}
}
ObservableList<ChequeCltHistoriqueListe> ObservableListHistChequeClt = Cheque.getHistoriqueListe();
Integer LastListHistCheque = ObservableListHistChequeClt.size()-1;
if(LastListHistCheque>=0){
LastEtat = ObservableListHistChequeClt.get(LastListHistCheque).getEtat().toString();
}
TableViewChequeCltHistorique.setItems(ObservableListHistChequeClt);
ControleUpdateEtatButton();
}
public void ButtonUpdateEtatAction(){
UpdateEtatButton.setOnAction(new EventHandler<ActionEvent>() { //supprimer le message du suucés et reaficher les formulaires
@Override
public void handle(ActionEvent event) {
boolean isSelectedVerser = RadioVerser.isSelected();
boolean isSelectedProvision = RadioSansProvision.isSelected();
boolean isSelectedContre = RadioContreCheque.isSelected();
ChequeCltDB ChequeDB = new ChequeCltDB();
//Etat 0 cheque sans provision 1 Verser (Valider) 2 Contre chéque(espace)
//Source 0==>Cheque(table cheque_clt) 1==>Traite(table traite_paiement_cheque_clt)
if(isSelectedVerser == true){
ChequeDB.setHistoriqueCheque(1, Source, Cheque);
}else if(isSelectedProvision == true){
ChequeDB.setHistoriqueCheque(0, Source, Cheque);
}else if(isSelectedContre == true){
ChequeDB.setHistoriqueCheque(2, Source, Cheque);
}
startTask();
}
});
}
}
@@ -0,0 +1,482 @@
package Controllers.ChequeClt;
import Models.ChequeClt.ChequeCltDB;
import Models.ChequeClt.ChequeCltGestionListe;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
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.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.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.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.util.Callback;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class ChequeCltGestionController implements Initializable {
@FXML private AnchorPane PaneChequeCltGestion;
@FXML private ProgressBar ProgressBarChequeCltGestion;
@FXML private Button ButtonSearchChequeCltGestion;
@FXML public TableView<ChequeCltGestionListe> TableViewChequeCltGestion ;
@FXML private TableColumn TabColChequeClt;
@FXML private TableColumn TabColClient;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColNumeroCheque;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColBanque;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColDateCheque;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColMontant;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColCodeClt;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColTypeClt;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColNomClt;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColPrenomClt;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColIdFacture;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColEtat;
@FXML private TableColumn<ChequeCltGestionListe ,Boolean> TabColDetail;
@FXML private TextField TextFieldNumeroCheque ;
@FXML private TextField TextFieldBanque ;
@FXML private TextField TextFieldCodeClt ;
@FXML private TextField TextFieldCINClt ;
@FXML private TextField TextFieldNomClt ;
@FXML private TextField TextFieldPrenomClt;
@FXML private TextField TextFieldIdFacture ;
@FXML private DatePicker DatePickerCheque ;
@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> ThreadSearchChequeCltGestion;
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;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
NbrLigne.setItems(cursors);
NbrLigne.getSelectionModel().selectFirst();
TabColChequeClt.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt; -fx-border-color: #4DAE4D;");
TabColChequeClt.getStyleClass().add("Center");
TabColClient.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt; -fx-border-color:#428BCA;");
TabColClient.getStyleClass().add("Center");
TabColNumeroCheque.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("NumeroCheque"));
TabColNumeroCheque.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColNumeroCheque.getStyleClass().add("Center");
TabColBanque.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("Banque"));
TabColBanque.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColBanque.getStyleClass().add("Center");
TabColDateCheque.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("DateCheque"));
TabColDateCheque.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDateCheque.getStyleClass().add("Center");
TabColMontant.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("Montant"));
TabColMontant.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColMontant.getStyleClass().add("Center");
TabColCodeClt.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("CodeClt"));
TabColCodeClt.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt; ");
TabColCodeClt.getStyleClass().add("Center");
TabColTypeClt.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("TypeClt"));
TabColTypeClt.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColTypeClt.getStyleClass().add("Center");
TabColNomClt.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("NomClt"));
TabColNomClt.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColNomClt.getStyleClass().add("Center");
TabColPrenomClt.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("PrenomClt"));
TabColPrenomClt.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColPrenomClt.getStyleClass().add("Center");
TabColIdFacture.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("IdFacture"));
TabColIdFacture.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColIdFacture.getStyleClass().add("Center");
TabColEtat.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("Etat"));
TabColEtat.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColEtat.getStyleClass().add("Center");
TabColEtat.setCellFactory(new Callback<TableColumn<ChequeCltGestionListe,String>,TableCell<ChequeCltGestionListe,String>>(){
@Override
public TableCell<ChequeCltGestionListe, String> call(TableColumn<ChequeCltGestionListe, String> param) {
TableCell<ChequeCltGestionListe, String> cell = new TableCell<ChequeCltGestionListe, String>(){
@Override
public void updateItem(String item, boolean empty) {
if(item!=null && item.equals("0")){
Text text = new Text("sans provision");
text.setFill(Color.web("#ff0000"));
text.setFont(Font.font("Arial", FontWeight.BOLD, 14));
setGraphic(text);
}else if(item!=null && item.equals("1")){
Text text = new Text("verser");
text.setFont(Font.font("Arial", FontWeight.BOLD, 14));
setGraphic(text);
}else if(item!=null && item.equals("2")){
Text text = new Text("contre chèque");
text.setFont(Font.font("Arial", FontWeight.BOLD, 14));
setGraphic(text);
}else{
setGraphic(null);
}
}
};
return cell;
}
});
TabColDetail.setStyle( "-fx-alignment: CENTER;");TabColDetail.getStyleClass().add("Center");
TabColDetail.setCellFactory(new Callback<TableColumn<ChequeCltGestionListe, Boolean>, TableCell<ChequeCltGestionListe, Boolean>>() {
@Override
public TableCell<ChequeCltGestionListe, Boolean> call(TableColumn<ChequeCltGestionListe, Boolean> personBooleanTableColumn) {
return new ButtonCell();
}
});
ButtonSearchChequeCltGestion.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchChequeCltGestion();
}
});
PaneChequeCltGestion.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchChequeCltGestion();
}
}
});
GestionSearchChequeClt();
}
@FXML
private void ChequeCltVerserButtonAction(ActionEvent event) throws IOException {
PaneChequeCltGestion.getChildren().clear();
PaneChequeCltGestion.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/ChequeClt/ChequeCltVercer.fxml")));
}
@FXML
private void ChequeCltProvisionButtonAction(ActionEvent event) throws IOException {
PaneChequeCltGestion.getChildren().clear();
PaneChequeCltGestion.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/ChequeClt/ChequeCltProvision.fxml")));
}
private class ButtonCell extends TableCell<ChequeCltGestionListe, 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) {
final ChequeCltGestionListe current = (ChequeCltGestionListe) ButtonCell.this.getTableView().getItems().get(ButtonCell.this.getIndex());
String IdChequeClt = current.getIdCheque();
Integer Source = current.getSource();
final ChequeCltDetailController ChequeCltDetail = new ChequeCltDetailController();
ChequeCltDetail.Show();
ChequeCltDetail.Initialize(IdChequeClt, Source);
ChequeCltDetail.ButtonExitChequeCltDetail.setOnAction(new EventHandler<ActionEvent>() { //supprimer le message du suucés et reaficher les formulaires
@Override
public void handle(ActionEvent event) {
ChequeCltDetail.AnchorPrincipal.setVisible(false);
if(ChequeCltDetail.LastEtat != null){
ObservableList<ChequeCltGestionListe> DataListChequeClt = ButtonCell.this.getTableView().getItems();
DataListChequeClt.get(ButtonCell.this.getIndex()).setEtat(ChequeCltDetail.LastEtat);
TableViewChequeCltGestion.setItems(DataListChequeClt);
//actualiser la ligne
TabColEtat.setVisible(false);
TabColEtat.setVisible(true);
}
}
});
}
});
}
//Display button if the row is not empty
@Override
protected void updateItem(Boolean t, boolean empty) {
if(!empty){
setGraphic(cellButton);
} else {
setGraphic(null);
}
}
}
/****************************************************************************** *
* *
* Methode last Next TableView *
* * *
******************************************************************************/
private void SearchChequeCltGestion()
{
ProgressBarChequeCltGestion.setVisible(true);
ButtonSearchChequeCltGestion.setDisable(true);
ThreadSearchChequeCltGestion = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
position = 0;
actuellepage = 1;
String DateCheque = "";
if(DatePickerCheque.getValue() != null){
DateCheque = DatePickerCheque.getValue().toString();
}
ObservableList<ChequeCltGestionListe> ListChequeCltGestions = new ChequeCltDB().SearchChequeCltGestion(
position,
nbrligne,
TextFieldNumeroCheque.getText(),
TextFieldBanque.getText(),
DateCheque,
TextFieldCodeClt.getText(),
TextFieldCINClt.getText(),
TextFieldIdFacture.getText(),
TextFieldNomClt.getText(),
TextFieldPrenomClt.getText());
TableViewChequeCltGestion.setItems(ListChequeCltGestions);
totalcount = new ChequeCltDB().nbrChequeCltGestion(TextFieldNumeroCheque.getText(),
TextFieldBanque.getText(),
DateCheque,
TextFieldCodeClt.getText(),
TextFieldCINClt.getText(),
TextFieldIdFacture.getText(),
TextFieldNomClt.getText(),
TextFieldPrenomClt.getText());
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;
}
};
}
};
ThreadSearchChequeCltGestion.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarChequeCltGestion.setVisible(false);
ButtonSearchChequeCltGestion.setDisable(false);
LabelCount.setText(totalcount.toString());
}
});
ThreadSearchChequeCltGestion.start();
}
private void NextLastSearchChequeCltGestion(Integer ParmPosition, Integer ParamNbrligne)
{
ProgressBarChequeCltGestion.setVisible(true);
ButtonSearchChequeCltGestion.setDisable(true);
ThreadSearchChequeCltGestion = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
String DateCheque = "";
if(DatePickerCheque.getValue() != null){
DateCheque = DatePickerCheque.getValue().toString();
}
ObservableList<ChequeCltGestionListe> ListChequeCltGestions = new ChequeCltDB().SearchChequeCltGestion(ParmPosition, ParamNbrligne, TextFieldNumeroCheque.getText(), TextFieldBanque.getText(), DateCheque, TextFieldCodeClt.getText(), TextFieldCINClt.getText(), TextFieldIdFacture.getText(), TextFieldNomClt.getText(), TextFieldPrenomClt.getText());
TableViewChequeCltGestion.setItems(ListChequeCltGestions);
return null;
}
};
}
};
ThreadSearchChequeCltGestion.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarChequeCltGestion.setVisible(false);
ButtonSearchChequeCltGestion.setDisable(false);
}
});
ThreadSearchChequeCltGestion.start();
}
private void GestionSearchChequeClt()
{
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;
NextLastSearchChequeCltGestion(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;
NextLastSearchChequeCltGestion(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;
NextLastSearchChequeCltGestion(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;
NextLastSearchChequeCltGestion(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;
NextLastSearchChequeCltGestion(position, nbrligne);
actuellepage=actuellepage-3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
}
}
@@ -0,0 +1,466 @@
package Controllers.ChequeClt;
import Controllers.TraiteClt.TraiteCltPrintRetardController;
import Controllers.Traitement.Adaptateur;
import Controllers.Traitement.ParametreSystem;
import Models.ChequeClt.ChequeCltDB;
import Models.ChequeClt.ChequeCltGestionListe;
import Models.Stock.StockDB;
import Models.TraiteClt.TraiteCltDB;
import Models.TraiteClt.TraiteCltGestionListe;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.ResourceBundle;
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.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.print.PageLayout;
import javafx.print.PageOrientation;
import javafx.print.PageRange;
import javafx.print.Paper;
import javafx.print.Printer;
import javafx.print.PrinterJob;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
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;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class ChequeCltProvisionController implements Initializable {
@FXML private AnchorPane AnchorPaneChequeCltProvision;
@FXML private ProgressBar ProgressBarChequeCltProvision;
@FXML private Button ButtonSearchChequeCltProvision;
@FXML private Button ButtonPrintChequeCltProvision;
@FXML private TableView<ChequeCltGestionListe> TableViewChequeCltAvercer ;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColNumeroCheque;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColBanque;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColDateCheque;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColMontant;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColTypeClt;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColNomClt;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColPrenomClt;
@FXML private DatePicker DatePickerCheque ;
@FXML private ChoiceBox ChoiceBoxLocal ;
@FXML private TextField TextFieldBanque ;
@FXML private TextField TextFieldCodeClt ;
@FXML private TextField TextFieldCINClt ;
@FXML private TextField TextFieldNomPrenomClt ;
@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 ;
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;
ObservableList<ChequeCltGestionListe> ListPrintChequeCltProvision;
private Service<Void> ThreadSearchChequeCltProvision;
private Service<Void> ThreadPrintChequeCltProvision;
@Override
public void initialize(URL url, ResourceBundle rb) {
NbrLigne.setItems(cursors);
NbrLigne.getSelectionModel().selectFirst();
TabColNumeroCheque.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("NumeroCheque"));
TabColNumeroCheque.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColNumeroCheque.getStyleClass().add("Center");
TabColBanque.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("Banque"));
TabColBanque.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColBanque.getStyleClass().add("Center");
TabColDateCheque.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("DateCheque"));
TabColDateCheque.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDateCheque.getStyleClass().add("Center");
TabColMontant.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("Montant"));
TabColMontant.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColMontant.getStyleClass().add("Center");
TabColTypeClt.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("TypeClt"));
TabColTypeClt.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColTypeClt.getStyleClass().add("Center");
TabColNomClt.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("NomClt"));
TabColNomClt.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColNomClt.getStyleClass().add("Center");
TabColPrenomClt.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("PrenomClt"));
TabColPrenomClt.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColPrenomClt.getStyleClass().add("Center");
ArrayList<String> ListLocale = new StockDB().getAllListLocal();
ChoiceBoxLocal.getItems().addAll(ListLocale);
ButtonSearchChequeCltProvision.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchChequeCltProvision();
}
});
AnchorPaneChequeCltProvision.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchChequeCltProvision();
}
}
});
GestionSearchChequeCltProvision();
ButtonPrintChequeCltProvision.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
ImprimerChequeCltProvision();
}
});
}
private void ImprimerChequeCltProvision()
{
ProgressBarChequeCltProvision.setVisible(true);
ButtonPrintChequeCltProvision.setDisable(true);
ThreadPrintChequeCltProvision = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
String DateDebut = "";
if(DatePickerCheque.getValue() != null){
DateDebut = DatePickerCheque.getValue().toString();
}
ListPrintChequeCltProvision = new ChequeCltDB().SearchChequeCltProvision(
0,
0,
DateDebut,
(String) ChoiceBoxLocal.getValue(),
TextFieldBanque.getText(),
TextFieldCodeClt.getText(),
TextFieldCINClt.getText(),
TextFieldNomPrenomClt.getText(),
true);
return null;
}
};
}
};
ThreadPrintChequeCltProvision.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
int SizeListeChequeCltProvision = ListPrintChequeCltProvision.size();
System.out.println(SizeListeChequeCltProvision);
int total = SizeListeChequeCltProvision / 15 + 1 ;
int page = 0;
PrinterJob jobPrint = PrinterJob.createPrinterJob();
jobPrint.getJobSettings().setPageRanges(new PageRange(1, total));
if (jobPrint.showPrintDialog(null))
{
Printer printer = jobPrint.getPrinter();
PageLayout pageLayout = printer.createPageLayout(Paper.A4, PageOrientation.LANDSCAPE, Printer.MarginType.DEFAULT);
for (int i=0; i<SizeListeChequeCltProvision; i+=15)
{
try {
ObservableList<ChequeCltGestionListe> listTemp = FXCollections.observableArrayList();
for (int j=i; (j<(i+15)) && (j<SizeListeChequeCltProvision); j++)
{
ChequeCltGestionListe ListChequeClt = ListPrintChequeCltProvision.get(j);
listTemp.add(new ChequeCltGestionListe(
ListChequeClt.getIdCheque(),
ListChequeClt.getNumeroCheque(),
ListChequeClt.getBanque(),
ListChequeClt.getDateCheque(),
ListChequeClt.getMontant(),
ListChequeClt.getCodeClt(),
ListChequeClt.getTypeClt(),
ListChequeClt.getNomClt(),
ListChequeClt.getPrenomClt(),
ListChequeClt.getIdFacture(),
ListChequeClt.getEtat(),
ListChequeClt.getSource(),
ListChequeClt.getSelected()
));
}
FXMLLoader fxmlLoaderChequeCltProvisionPrint = new FXMLLoader(getClass().getResource("/Views/ChequeClt/ChequeCltProvisionPrint.fxml"));
final Node ParentFxmlChequeCltProvisionPrint = (Node)fxmlLoaderChequeCltProvisionPrint.load();
ChequeCltProvisionPrintController chequeCltProvisionPrintController = fxmlLoaderChequeCltProvisionPrint.getController();
page++;
chequeCltProvisionPrintController.setChequeCltProvision(Integer.toString(SizeListeChequeCltProvision), page+"/"+total, listTemp);
jobPrint.printPage(pageLayout, ParentFxmlChequeCltProvisionPrint);
} catch (IOException ex) {
System.out.println(ex.getMessage());
}
}
jobPrint.endJob();
}
ProgressBarChequeCltProvision.setVisible(false);
ButtonPrintChequeCltProvision.setDisable(false);
}
});
ThreadPrintChequeCltProvision.start();
}
/****************************************************************************** *
* *
* Methode last Next TableView *
* * *
******************************************************************************/
private void SearchChequeCltProvision()
{
ProgressBarChequeCltProvision.setVisible(true);
ButtonSearchChequeCltProvision.setDisable(true);
ThreadSearchChequeCltProvision = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
position = 0;
actuellepage = 1;
String DateDebut = "";
if(DatePickerCheque.getValue() != null){
DateDebut = DatePickerCheque.getValue().toString();
}
ObservableList<ChequeCltGestionListe> ListChequeCltProvisions = new ChequeCltDB().SearchChequeCltProvision(
position,
nbrligne,
DateDebut,
(String) ChoiceBoxLocal.getValue(),
TextFieldBanque.getText(),
TextFieldCodeClt.getText(),
TextFieldCINClt.getText(),
TextFieldNomPrenomClt.getText(),
false);
TableViewChequeCltAvercer.setItems(ListChequeCltProvisions);
totalcount = new ChequeCltDB().nbrChequeCltProvision(DateDebut,
(String) ChoiceBoxLocal.getValue(),
TextFieldBanque.getText(),
TextFieldCodeClt.getText(),
TextFieldCINClt.getText(),
TextFieldNomPrenomClt.getText());
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;
}
};
}
};
ThreadSearchChequeCltProvision.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarChequeCltProvision.setVisible(false);
ButtonSearchChequeCltProvision.setDisable(false);
LabelCount.setText(totalcount.toString());
}
});
ThreadSearchChequeCltProvision.start();
}
private void NextLastSearchChequeCltProvision(Integer ParmPosition, Integer ParamNbrligne)
{
ProgressBarChequeCltProvision.setVisible(true);
ButtonSearchChequeCltProvision.setDisable(true);
ThreadSearchChequeCltProvision = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
String DateDebut = "";
if(DatePickerCheque.getValue() != null){
DateDebut = DatePickerCheque.getValue().toString();
}
ObservableList<ChequeCltGestionListe> ListChequeCltProvisions = new ChequeCltDB().SearchChequeCltProvision(ParmPosition, ParamNbrligne, DateDebut, (String) ChoiceBoxLocal.getValue(), TextFieldBanque.getText(), TextFieldCodeClt.getText(), TextFieldCINClt.getText(), TextFieldNomPrenomClt.getText(), false);
TableViewChequeCltAvercer.setItems(ListChequeCltProvisions);
return null;
}
};
}
};
ThreadSearchChequeCltProvision.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarChequeCltProvision.setVisible(false);
ButtonSearchChequeCltProvision.setDisable(false);
}
});
ThreadSearchChequeCltProvision.start();
}
private void GestionSearchChequeCltProvision()
{
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;
NextLastSearchChequeCltProvision(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;
NextLastSearchChequeCltProvision(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;
NextLastSearchChequeCltProvision(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;
NextLastSearchChequeCltProvision(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;
NextLastSearchChequeCltProvision(position, nbrligne);
actuellepage=actuellepage-3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
}
}
@@ -0,0 +1,77 @@
package Controllers.ChequeClt;
import Models.ChequeClt.ChequeCltGestionListe;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.text.Text;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class ChequeCltProvisionPrintController implements Initializable {
@FXML private Text TextNbr ;
@FXML private Text TextPage ;
@FXML private TableView<ChequeCltGestionListe> TableViewChequeCltProvision ;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColNumeroCheque;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColBanque;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColDateCheque;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColMontant;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColNomClt;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColPrenomClt;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColLocal;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
TabColNumeroCheque.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("NumeroCheque"));
TabColNumeroCheque.setStyle( "-fx-alignment: CENTER; -fx-font-size: 10pt;");
TabColNumeroCheque.getStyleClass().add("Center");
TabColBanque.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("Banque"));
TabColBanque.setStyle( "-fx-alignment: CENTER; -fx-font-size: 10pt;");
TabColBanque.getStyleClass().add("Center");
TabColDateCheque.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("DateCheque"));
TabColDateCheque.setStyle( "-fx-alignment: CENTER; -fx-font-size: 10pt;");
TabColDateCheque.getStyleClass().add("Center");
TabColMontant.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("Montant"));
TabColMontant.setStyle( "-fx-alignment: CENTER; -fx-font-size: 10pt;");
TabColMontant.getStyleClass().add("Center");
TabColNomClt.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("NomClt"));
TabColNomClt.setStyle( "-fx-alignment: CENTER; -fx-font-size: 10pt;");
TabColNomClt.getStyleClass().add("Center");
TabColPrenomClt.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("PrenomClt"));
TabColPrenomClt.setStyle( "-fx-alignment: CENTER; -fx-font-size: 10pt;");
TabColPrenomClt.getStyleClass().add("Center");
TabColLocal.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("etat"));
TabColLocal.setStyle( "-fx-alignment: CENTER; -fx-font-size: 10pt;");
TabColLocal.getStyleClass().add("Center");
}
public void setChequeCltProvision(
String Nbr,
String Page,
ObservableList<ChequeCltGestionListe> obsListChequeCltListe)
{
TextNbr.setText(Nbr);
TextPage.setText(Page);
TableViewChequeCltProvision.setItems(obsListChequeCltListe);
}
}
@@ -0,0 +1,274 @@
/*
* 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.ChequeClt;
import Models.ChequeClt.ChequeCltDB;
import Models.ChequeClt.ChequeCltGestionListe;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.CheckBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import javafx.application.Platform;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.Button;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.KeyEvent;
import javafx.util.Callback;
/**
* FXML Controller class
* @author Maher
*/
public class ChequeCltVercerController implements Initializable {
@FXML private ProgressBar ProgressBarVerser;
@FXML private CheckBox CheckboxSelectionner;
@FXML private Button ButtonVerserSelection;
@FXML private Label LabelNbrSelectionner ;
@FXML private DatePicker DatePickerDateDebut;
@FXML private DatePicker DatePickerDateFin;
@FXML private TableView<ChequeCltGestionListe> TableViewChequeCltVerser ;
@FXML private TableColumn<ChequeCltGestionListe ,Boolean> TabColSelectionner;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColNumeroCheque;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColBanque;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColDateCheque;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColMontant;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColTypeClt;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColNomClt;
@FXML private TableColumn<ChequeCltGestionListe ,String> TabColPrenomClt;
ChequeCltDB ChequeDB= new ChequeCltDB();
ObservableList<ChequeCltGestionListe> DataListChequeClt;
private String StrDateDebut;
private String StrDateFin;
private Integer NbrSelect;
private Integer NbrCount;
@Override
public void initialize(URL url, ResourceBundle rb) {
DatePickerDateDebut.setValue(LocalDate.now());
DatePickerDateFin.setValue(LocalDate.now());
StrDateDebut = DatePickerDateDebut.getValue().toString();
StrDateFin = DatePickerDateFin.getValue().toString();
GetChequeCltAvercer();
CheckboxSelectionner.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
NbrSelect = 0;
ButtonVerserSelection.setDisable(true);
ButtonVerserSelection.setOpacity(0.82);
if(CheckboxSelectionner.isSelected()){
for(ChequeCltGestionListe ListChequeClt : DataListChequeClt){
ListChequeClt.setSelected(true);
NbrSelect++;
}
} else {
for(ChequeCltGestionListe ListChequeClt : DataListChequeClt){
ListChequeClt.setSelected(false);
}
}
if(NbrSelect>0){
ButtonVerserSelection.setDisable(false);
ButtonVerserSelection.setOpacity(1);
}
TableViewChequeCltVerser.setItems(DataListChequeClt);
LabelNbrSelectionner.setText(NbrSelect+"/"+NbrCount);
TabColSelectionner.setVisible(false);
TabColSelectionner.setVisible(true);
}
});
TabColNumeroCheque.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("NumeroCheque"));
TabColNumeroCheque.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColNumeroCheque.getStyleClass().add("Center");
TabColBanque.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("Banque"));
TabColBanque.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColBanque.getStyleClass().add("Center");
TabColDateCheque.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("DateCheque"));
TabColDateCheque.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDateCheque.getStyleClass().add("Center");
TabColMontant.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("Montant"));
TabColMontant.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColMontant.getStyleClass().add("Center");
TabColTypeClt.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("TypeClt"));
TabColTypeClt.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColTypeClt.getStyleClass().add("Center");
TabColNomClt.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("NomClt"));
TabColNomClt.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColNomClt.getStyleClass().add("Center");
TabColPrenomClt.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, String>("PrenomClt"));
TabColPrenomClt.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColPrenomClt.getStyleClass().add("Center");
TabColSelectionner.setCellValueFactory(new PropertyValueFactory<ChequeCltGestionListe, Boolean>("Selected"));
TabColSelectionner.setStyle("-fx-alignment: CENTER;");
TabColSelectionner.getStyleClass().add("Center");
TabColSelectionner.setCellFactory(new Callback<TableColumn<ChequeCltGestionListe,Boolean>,TableCell<ChequeCltGestionListe,Boolean>>(){
@Override
public TableCell<ChequeCltGestionListe, Boolean> call(TableColumn<ChequeCltGestionListe, Boolean> param) {
TableCell<ChequeCltGestionListe, Boolean> cell = new TableCell<ChequeCltGestionListe, Boolean>(){
@Override
public void updateItem(Boolean item, boolean empty) {
if(item!=null){
final CheckBox Check= new CheckBox();
Check.setSelected(item);
Check.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
ChequeCltGestionListe DataListChequeClt = ((ChequeCltGestionListe)getTableRow().getItem());
if(Check.isSelected()){
DataListChequeClt.setSelected(true);
NbrSelect++;
} else {
DataListChequeClt.setSelected(true);
NbrSelect--;
}
LabelNbrSelectionner.setText(NbrSelect+"/"+NbrCount);
if(NbrSelect>0){
ButtonVerserSelection.setDisable(false);
ButtonVerserSelection.setOpacity(1);
}else{
ButtonVerserSelection.setDisable(true);
ButtonVerserSelection.setOpacity(0.82);
}
}
});
setGraphic(Check);
}else{
setGraphic(null);
}
}
};
return cell;
}
});
DatePickerDateDebut.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
try{
StrDateDebut = DatePickerDateDebut.getConverter().fromString(DatePickerDateDebut.getEditor().getText()).toString();
GetChequeCltAvercer();
}catch(Exception ex){}
}
});
DatePickerDateDebut.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
try{
StrDateDebut = DatePickerDateDebut.getConverter().fromString(DatePickerDateDebut.getEditor().getText()).toString();
GetChequeCltAvercer();
}catch(Exception ex){}
}
});
DatePickerDateFin.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent actionEvent){
try{
StrDateFin = DatePickerDateFin.getConverter().fromString(DatePickerDateFin.getEditor().getText()).toString();
GetChequeCltAvercer();
}catch(Exception ex){}
}
});
DatePickerDateFin.setOnKeyReleased(new EventHandler<KeyEvent>(){
@Override
public void handle(KeyEvent ke){
try{
StrDateFin = DatePickerDateFin.getConverter().fromString(DatePickerDateFin.getEditor().getText()).toString();
GetChequeCltAvercer();
}catch(Exception ex){}
}
});
ButtonVerserSelection.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
List<String> ArrayChequeClt = new ArrayList<>();
List<String> ArrayChequePaiementTraite = new ArrayList<>(); //traite_paiement_cheque_clt
for(ChequeCltGestionListe ListChequeClt : DataListChequeClt){
if( (ListChequeClt.getSelected()) && (ListChequeClt.getSource() == 0) ){
ArrayChequeClt.add(ListChequeClt.getIdCheque());
}
if( (ListChequeClt.getSelected()) && (ListChequeClt.getSource() == 1) ){
ArrayChequePaiementTraite.add(ListChequeClt.getIdCheque());
}
}
Integer NbrUpdateChequeClt = ChequeDB.UpdateChequeCltVerser(ArrayChequeClt, ArrayChequePaiementTraite);
if(NbrUpdateChequeClt>0){
GetChequeCltAvercer();
}
}
});
}
public void GetChequeCltAvercer(){
ProgressBarVerser.setVisible(true);
// Create a Runnable
Runnable task = new Runnable(){
public void run(){
Platform.runLater(new Runnable(){
@Override
public void run(){
DataListChequeClt = ChequeDB.GetDataChequeAverser(StrDateDebut, StrDateFin);
TableViewChequeCltVerser.setItems(DataListChequeClt);
NbrCount = DataListChequeClt.size();
NbrSelect = 0;
LabelNbrSelectionner.setText(NbrSelect+"/"+NbrCount);
ProgressBarVerser.setVisible(false);
}
});
}
};
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
}
}
@@ -0,0 +1,54 @@
/*
* 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.Client;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
public class AjouterClientController implements Initializable {
@FXML private AnchorPane AnchorPaneCltBody ;
@FXML public StackPane typecompte ;
@Override
public void initialize(URL url, ResourceBundle rb) {
try {
//AnchorPaneCltBody.getChildren().clear();
AnchorPaneCltBody.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Client/AjouterClientPersonne.fxml")));
} catch (IOException ex) {
Logger.getLogger(AjouterClientController.class.getName()).log(Level.SEVERE, null, ex);
}
}
@FXML
public void AjouterClientEntrepriseRadioAction(ActionEvent event) throws IOException {
AnchorPaneCltBody.getChildren().clear();
AnchorPaneCltBody.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Client/AjouterClientEntreprise.fxml")));
}
@FXML
public void AjouterClientPersonneRadioAction(ActionEvent event) throws IOException {
AnchorPaneCltBody.getChildren().clear();
AnchorPaneCltBody.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Client/AjouterClientPersonne.fxml")));
}
public void delete(){
typecompte.getChildren().clear();
// System.out.println("dfgsdf");
}
}
@@ -0,0 +1,448 @@
/*
* 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.Client;
import Controllers.Dialog.Notification;
import Controllers.Traitement.contro;
import Models.Client.ClientEntreprise;
import Models.Client.ClientEntrepriseContact;
import Models.Client.ClientEntrepriseContactDB;
import Models.Client.ClientEntrepriseDB;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.animation.FadeTransition;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.util.Duration;
/**
* FXML Controller class
*
* @author Maher
*/
public class AjouterClientEntrepriseController implements Initializable {
@FXML private AnchorPane AnchorPaneAjouterClientEntreprise ;
@FXML private AnchorPane AnchorPaneAjouterCltEntreprise ;
@FXML private Text ErreurClientEntrepriseCode ;
@FXML private Text ErreurClientEntrepriseNom ;
@FXML private Text ErreurClientEntrepriseGerant ;
@FXML private Text ErreurClientEntrepriseMatricule ;
@FXML private Text ErreurClientEntrepriseAdresse ;
@FXML private Text ErreurClientEntreprisePostale ;
@FXML private Text ErreurClientEntrepriseTele1 ;
@FXML private Text ErreurClientEntrepriseTele2 ;
@FXML private Text ErreurClientEntrepriseMail ;
@FXML private Text ErreurClientEntrepriseFax ;
@FXML private Text ErreurClientEntrepriseContactNom ;
@FXML private Text ErreurClientEntrepriseContactPrenom ;
@FXML private Text ErreurClientEntrepriseContactCIN ;
@FXML private Text ErreurClientEntrepriseContactMail ;
@FXML private Text ErreurClientEntrepriseContactTele1 ;
@FXML private Text ErreurClientEntrepriseContactTele2 ;
@FXML private TextField ChampClientEntrepriseCode;
@FXML private TextField ChampClientEntrepriseNom;
@FXML private TextField ChampClientEntrepriseGerant ;
@FXML private TextField ChampClientEntrepriseMatricule;
@FXML private TextField ChampClientEntrepriseAdresse;
@FXML private TextField ChampClientEntreprisePostale;
@FXML private TextField ChampClientEntrepriseTele1;
@FXML private TextField ChampClientEntrepriseTele2;
@FXML private TextField ChampClientEntrepriseMail;
@FXML private TextField ChampClientEntrepriseFax;
@FXML private TextField ChampClientEntrepriseContactNom;
@FXML private TextField ChampClientEntrepriseContactPrenom;
@FXML private TextField ChampClientEntrepriseContactCIN;
@FXML private TextField ChampClientEntrepriseContactMail;
@FXML private TextField ChampClientEntrepriseContactTele1;
@FXML private TextField ChampClientEntrepriseContactTele2;
contro ctl= new contro() ;
ClientEntreprise MyClientEntreprise = new ClientEntreprise();
ClientEntrepriseContact MyClientEntrepriseContact = new ClientEntrepriseContact();
ClientEntrepriseDB MyCltEtrDB = new ClientEntrepriseDB();
ClientEntrepriseContactDB MyCltEtrCta = new ClientEntrepriseContactDB();
@Override
public void initialize(URL url, ResourceBundle rb) {
//lors de clique sur le textfilde Code de l'entreprise
ChampClientEntrepriseCode.setOnKeyReleased(new EventHandler<KeyEvent>() {
public void handle(KeyEvent ke) {
try {// if is number
Integer.parseInt(ChampClientEntrepriseCode.getText());
int cin =Integer.parseInt(ChampClientEntrepriseCode.getText());
if(MyCltEtrDB.verifyCodeEntreprise(cin)){
ErreurClientEntrepriseCode.setText("Code entreprise existe déja");
ChampClientEntrepriseCode.setStyle("-fx-border-color:#f20606;");
}
else{
ErreurClientEntrepriseCode.setText("");
ChampClientEntrepriseCode.setStyle("-fx-border-color: transparent;");
}
}
catch (NumberFormatException e) {
ErreurClientEntrepriseCode.setText("Code doit être un numéro");
ChampClientEntrepriseCode.setStyle("-fx-border-color:#f20606;");
}
}
});
}
@FXML
public void AjouterClientEntrepriseButtonAction(ActionEvent event) throws IOException {
if(!ControlesEtr()){
if(!ControlesEtrContact()){
//recupération des données dont l'objet
this.getClientEntreprise();
//l'insertion des données dont la Base des données et afficher le message du succés
if(MyCltEtrDB.addEntreprise(MyClientEntreprise)){
this.getClientEntrepriseContact();
if(MyCltEtrCta.addClientEntrepriseContact(MyClientEntrepriseContact)){
FadeTransition ft = new FadeTransition(Duration.millis(400), AnchorPaneAjouterCltEntreprise);
ft.setFromValue(1.0);
ft.setToValue(0.0);
ft.play();
ft.setOnFinished(new EventHandler<ActionEvent>() {
//message de succés
@Override
public void handle(ActionEvent event) {
Image success = new Image(getClass().getResourceAsStream("/Public/icon/successfully.png"));
ImageView iv1 = new ImageView();
iv1.setImage(success);
Text text= new Text();
text.setText("l'ajouter a été effectuée avec succès");
text.setFont(Font.loadFont(getClass().getResourceAsStream("/Public/Fonts/Raleway-SemiBold.ttf"), 20));
Button AddClient = new Button("OK");
AddClient.getStyleClass().add("btn-primary");
AddClient.setPrefSize(100, 30);
final StackPane stackpane = new StackPane();
stackpane.setLayoutX(140);
stackpane.setLayoutY(100);
stackpane.setPrefHeight(200);
stackpane.setPrefWidth(200);
stackpane.getChildren().add(iv1);
stackpane.getChildren().add(text);
stackpane.getChildren().add(AddClient);
StackPane.setAlignment(iv1, Pos.BASELINE_CENTER);
StackPane.setAlignment(text, Pos.TOP_CENTER);
StackPane.setAlignment(AddClient, Pos.CENTER);
AnchorPaneAjouterClientEntreprise.setLeftAnchor(stackpane, 83.0);
AnchorPaneAjouterClientEntreprise.setRightAnchor(stackpane, 83.0);
AnchorPaneAjouterClientEntreprise.setTopAnchor(stackpane,200.0);
AnchorPaneAjouterClientEntreprise.setBottomAnchor(stackpane,200.0);
AnchorPaneAjouterClientEntreprise.getChildren().add(stackpane);
AddClient.setOnAction(new EventHandler<ActionEvent>() { //supprimer le message du suucés et reaficher les formulaires
@Override
public void handle(ActionEvent event) {
stackpane.setVisible(false);
FadeTransition ft = new FadeTransition(Duration.millis(400), AnchorPaneAjouterCltEntreprise);
ft.setFromValue(0.0);
ft.setToValue(1.0);
ft.play();
restechamp();
}
});
}
});
}
}
}
}
}
private void restechamp(){
ChampClientEntrepriseCode.setText("");
ChampClientEntrepriseNom.setText("");
ChampClientEntrepriseGerant.setText("");
ChampClientEntrepriseMatricule.setText("");
ChampClientEntrepriseAdresse.setText("");
ChampClientEntreprisePostale.setText("");
ChampClientEntrepriseTele1.setText("");
ChampClientEntrepriseTele2.setText("");
ChampClientEntrepriseMail.setText("");
ChampClientEntrepriseFax.setText("");
ChampClientEntrepriseContactNom.setText("");
ChampClientEntrepriseContactPrenom.setText("");
ChampClientEntrepriseContactCIN.setText("");
ChampClientEntrepriseContactMail.setText("");
ChampClientEntrepriseContactTele1.setText("");
ChampClientEntrepriseContactTele2.setText("");
}
private void getClientEntreprise(){
MyClientEntreprise.setCodeString(ChampClientEntrepriseCode.getText());
MyClientEntreprise.setNom(ChampClientEntrepriseNom.getText());
MyClientEntreprise.setGerant(ChampClientEntrepriseGerant.getText());
MyClientEntreprise.setMatricule(ChampClientEntrepriseMatricule.getText());
MyClientEntreprise.setAdresse(ChampClientEntrepriseAdresse.getText());
MyClientEntreprise.setPostaleString(ChampClientEntreprisePostale.getText());
MyClientEntreprise.setTele1String(ChampClientEntrepriseTele1.getText());
MyClientEntreprise.setTele2String(ChampClientEntrepriseTele2.getText());
MyClientEntreprise.setMail(ChampClientEntrepriseMail.getText());
MyClientEntreprise.setFaxString(ChampClientEntrepriseFax.getText());
}
private void getClientEntrepriseContact(){
MyClientEntrepriseContact.setNom(ChampClientEntrepriseContactNom.getText());
MyClientEntrepriseContact.setPrenom(ChampClientEntrepriseContactPrenom.getText());
MyClientEntrepriseContact.setCINString(ChampClientEntrepriseContactCIN.getText());
MyClientEntrepriseContact.setTele1String(ChampClientEntrepriseContactTele1.getText());
MyClientEntrepriseContact.setTele2String(ChampClientEntrepriseContactTele2.getText());
MyClientEntrepriseContact.setMail(ChampClientEntrepriseContactMail.getText());
MyClientEntrepriseContact.setIdcltentreprise(MyClientEntreprise.getCode());
}
//methode qui afficher une fenêtre de notification "code client Etreprise générer par le systeme
private void getidcltEtr(){
if(MyCltEtrDB.getidClientEtr()>=0){
final Notification notification = new Notification();
notification.DetailMSG.getChildren().clear();
final String ch = String.valueOf(MyCltEtrDB.getidClientEtr()+1) ;
Text text1 = new Text();
text1.setText("Code Entreprise vide \n \n");
text1.setFont(Font.font("Arial", FontWeight.BOLD, 15));
text1.setFill(Color.web("#363a38"));
notification.DetailMSG.getChildren().add(text1);
Text text2 = new Text();
text2.setText("Voulez vous que system génére le code d'entreprise par le numéro suivant:");
text2.setFont(Font.font("Arial", FontWeight.NORMAL, 15));
text2.setFill(Color.web("#363a38"));
notification.DetailMSG.getChildren().add(text2);
Text text3 = new Text();
text3.setText(ch);
text3.setFont(Font.font("Arial", FontWeight.BOLD, 14));
text3.setFill(Color.web("#363a38"));
notification.DetailMSG.getChildren().add(text3);
notification.bouttonOK.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
notification.stackpane.setVisible(false);
ChampClientEntrepriseCode.setText(ch);
}
});
notification.ShowNotification();
}
}
private boolean ControlesEtr(){
boolean result=false ;
if(ChampClientEntrepriseCode.getText().length()==0){
this.getidcltEtr();
result= true ;
}
else if(ctl.isNumericNotnull(ChampClientEntrepriseCode.getText())){
ChampClientEntrepriseCode.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseCode.setText("Code doit être un numéro");
result= true ;
}
else{
if(ChampClientEntrepriseNom.getText().length()<3){
ChampClientEntrepriseNom.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseNom.setText("Nom doit dépasser 3 caractère");
result= true ;
}
else{
ChampClientEntrepriseNom.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseNom.setText("");
if(ChampClientEntrepriseGerant.getText().length()<3){
ChampClientEntrepriseGerant.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseGerant.setText("Gérant doit dépasser 3 caractère");
result= true ;
}
else{
ChampClientEntrepriseGerant.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseGerant.setText("");
if(ctl.isNumeric(ChampClientEntrepriseMatricule.getText())){
ChampClientEntrepriseMatricule.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseMatricule.setText("Matricule doit être numéro");
result= true ;
}
else{
ChampClientEntrepriseMatricule.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseMatricule.setText("");
if(ChampClientEntrepriseAdresse.getText().length()<3){
ChampClientEntrepriseAdresse.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseAdresse.setText("L'adresse doit dépasser 3 caractère");
result= true ;
}
else{
ChampClientEntrepriseAdresse.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseAdresse.setText("");
if(ctl.isNumeric(ChampClientEntreprisePostale.getText())){
ChampClientEntreprisePostale.setStyle("-fx-border-color:#f20606;");
ErreurClientEntreprisePostale.setText("code doit être numéro");
result= true ;
}
else{
ChampClientEntreprisePostale.setStyle("-fx-border-color:transparent;");
ErreurClientEntreprisePostale.setText("");
if(ctl.isNumericNotnull(ChampClientEntrepriseTele1.getText())){
ChampClientEntrepriseTele1.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseTele1.setText("Tele doit être numéro");
result= true ;
}
else{
ChampClientEntrepriseTele1.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseTele1.setText("");
if(ctl.isNumeric(ChampClientEntrepriseTele2.getText())){
ChampClientEntrepriseTele2.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseTele2.setText("Tele2 doit être numéro");
result= true ;
}
else{
ChampClientEntrepriseTele2.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseTele2.setText("");
if(ctl.isNumeric(ChampClientEntrepriseFax.getText())){
ChampClientEntrepriseFax.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseFax.setText("Fax doit être numéro");
result= true ;
}
else{
ChampClientEntrepriseFax.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseFax.setText("");
if(ChampClientEntrepriseMail.getText().length()>0 && ChampClientEntrepriseMail.getText().indexOf("@")< 0){
ChampClientEntrepriseMail.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseMail.setText("invalide mail");
result= true ;
}
else{
ChampClientEntrepriseMail.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseMail.setText("");
}
}
}
}
}
}
}
}
}
}
return result ;
}
private boolean ControlesEtrContact(){
boolean result=false ;
if(ChampClientEntrepriseContactNom.getText().length()<4){
ChampClientEntrepriseContactNom.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseContactNom.setText("Nom doit dépasser 4 caractère");
result= true ;
}
else{
ChampClientEntrepriseContactNom.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseContactNom.setText("");
if(ChampClientEntrepriseContactPrenom.getText().length()<4){
ChampClientEntrepriseContactPrenom.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseContactPrenom.setText("Prénom doit dépasser 4 caractère");
result= true ;
}
else{
ChampClientEntrepriseContactPrenom.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseContactPrenom.setText("");
if(ctl.isNumeric(ChampClientEntrepriseContactCIN.getText())){
ChampClientEntrepriseContactCIN.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseContactCIN.setText("CIN doit être un numéro");
result= true ;
}
else{
ChampClientEntrepriseContactCIN.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseContactCIN.setText("");
if(ChampClientEntrepriseContactMail.getText().length()>0){
if(ChampClientEntrepriseContactMail.getText().indexOf("@")< 0){
ChampClientEntrepriseContactMail.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseContactMail.setText("invalide mail");
result= true ;
}
else{
ChampClientEntrepriseContactMail.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseContactMail.setText("");
}
}
if(ctl.isNumericNotnull(ChampClientEntrepriseContactTele1.getText())){
ChampClientEntrepriseContactTele1.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseContactTele1.setText("Tele doit être un numéro");
result= true ;
}
else{
ChampClientEntrepriseContactTele1.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseContactTele1.setText("");
if(ctl.isNumeric(ChampClientEntrepriseContactTele2.getText())){
ChampClientEntrepriseContactTele2.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseContactTele2.setText("Tele doit être un numéro");
result= true ;
}
else{
ChampClientEntrepriseContactTele2.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseContactTele2.setText("");
}
}
}
}
}
return result ;
}
}
@@ -0,0 +1,398 @@
/*
* 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.Client;
import Controllers.Dialog.Notification;
import Controllers.Dialog.ShowDialog;
import Controllers.Traitement.contro;
import Models.Client.Client;
import Models.Client.ClientDB;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.animation.FadeTransition;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.DatePicker;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.util.Duration;
/**
* FXML Controller class
*
* @author Maher
*/
public class AjouterClientPersonneController implements Initializable {
@FXML private AnchorPane AnchorPaneAjouterClientPersonne ;
@FXML private AnchorPane AnchorPaneAjouterCltPersonne ;
@FXML private TextField AjouterClientCode;
@FXML private TextField AjouterClientCIN;
@FXML private TextField AjouterClientNomComplet;
@FXML private TextField AjouterClientNom;
@FXML private TextField AjouterClientPrenom;
@FXML private DatePicker AjouterClientNaissance;
@FXML private TextField AjouterClientTeleFixe;
@FXML private TextField AjouterClientTeleMobile;
@FXML private TextField AjouterClientAdresse;
@FXML private TextField AjouterClientCodePostal;
@FXML private TextField AjouterClientMail;
@FXML public ToggleGroup groupesexe;
@FXML private RadioButton AjouterClientSexeHomme;
@FXML private RadioButton AjouterClientSexeFemme;
@FXML private Text ErreurCode ;
@FXML private Text ErreurCIN ;
@FXML private Text ErreurNomComplet ;
@FXML private Text ErreurNom ;
@FXML private Text ErreurPrenom ;
@FXML private Text ErreurNaissance ;
@FXML private Text ErreurTeleFixe ;
@FXML private Text ErreurTeleMobile ;
@FXML private Text ErreurAdresse ;
@FXML private Text ErreurCodePostal ;
@FXML private Text ErreurMail ;
@FXML private Text ErreurSexe ;
contro ctl= new contro() ;
Client Myclient = new Client();
ClientDB dbclient = new ClientDB();
@FXML
public void AjouterClientPersonneButtonAction(ActionEvent event) throws IOException {
if(!this.Controles()){
this.getclient(); //recupératiion des données dont l'objet Myclient
if(dbclient.addClient(Myclient)){ //l'insertion des données dont la Base des données et afficher le message du succés
FadeTransition ft = new FadeTransition(Duration.millis(400), AnchorPaneAjouterCltPersonne);
ft.setFromValue(1.0);
ft.setToValue(0.0);
ft.play();
ft.setOnFinished(new EventHandler<ActionEvent>() {
//message de succés
@Override
public void handle(ActionEvent event) {
//Image success = new Image(file.toURI().toString()+"successfully.png");
Image success = new Image(getClass().getResourceAsStream("/Public/icon/successfully.png"));
ImageView iv1 = new ImageView();
iv1.setImage(success);
Text text= new Text();
text.setText("l'ajouter a été effectuée avec succès");
text.setFont(Font.loadFont(getClass().getResourceAsStream("/Public/Fonts/Raleway-SemiBold.ttf"), 20));
Button AddClient = new Button("OK");
AddClient.getStyleClass().add("btn-success");
AddClient.setPrefSize(100, 30);
final StackPane stackpane = new StackPane();
stackpane.setLayoutX(140);
stackpane.setLayoutY(100);
stackpane.setPrefHeight(200);
stackpane.setPrefWidth(200);
stackpane.getChildren().add(iv1);
stackpane.getChildren().add(text);
stackpane.getChildren().add(AddClient);
StackPane.setAlignment(iv1, Pos.BASELINE_CENTER);
StackPane.setAlignment(text, Pos.TOP_CENTER);
StackPane.setAlignment(AddClient, Pos.CENTER);
AnchorPaneAjouterClientPersonne.setLeftAnchor(stackpane, 83.0);
AnchorPaneAjouterClientPersonne.setRightAnchor(stackpane, 83.0);
AnchorPaneAjouterClientPersonne.setTopAnchor(stackpane,220.0);
AnchorPaneAjouterClientPersonne.setBottomAnchor(stackpane,220.0);
AnchorPaneAjouterClientPersonne.getChildren().add(stackpane);
AddClient.setOnAction(new EventHandler<ActionEvent>() { //supprimer le message du suucés et reaficher les formulaires
@Override
public void handle(ActionEvent event) {
stackpane.setVisible(false);
FadeTransition ft = new FadeTransition(Duration.millis(400), AnchorPaneAjouterCltPersonne);
ft.setFromValue(0.0);
ft.setToValue(1.0);
ft.play();
restechamp();
}
});
}
});
}
else{
ShowDialog SD = new ShowDialog();
SD.ShowAletDialog();
}
}
}
private void getclient(){
Myclient.setCinString(AjouterClientCIN.getText());
Myclient.setCodeclientString(AjouterClientCode.getText());
Myclient.setNomcomplet(AjouterClientNomComplet.getText());
Myclient.setNom(AjouterClientNom.getText());
Myclient.setPrenom(AjouterClientPrenom.getText());
Myclient.setNaissanceDatePicker(AjouterClientNaissance.getValue());
Myclient.setTelefixString(AjouterClientTeleFixe.getText());
Myclient.setTelemobileString(AjouterClientTeleMobile.getText());
Myclient.setSexeString(groupesexe.getSelectedToggle().getUserData().toString());
Myclient.setAdresse(AjouterClientAdresse.getText());
Myclient.setCodepostal(AjouterClientCodePostal.getText());
Myclient.setMail(AjouterClientMail.getText());
}
//methode qui afficher une fenêtre de notification "code client générer par le systeme
private void getidclt(){
final Notification notification = new Notification();
notification.DetailMSG.getChildren().clear();
final String ch = String.valueOf(dbclient.getidClient()+1) ;
Text text1 = new Text();
text1.setText("Code client vide \n \n");
text1.setFont(Font.font("Arial", FontWeight.BOLD, 15));
text1.setFill(Color.web("#363a38"));
notification.DetailMSG.getChildren().add(text1);
Text text2 = new Text();
text2.setText("Voulez vous que system génére le code client par le numéro suivant:");
text2.setFont(Font.font("Arial", FontWeight.NORMAL, 15));
text2.setFill(Color.web("#363a38"));
notification.DetailMSG.getChildren().add(text2);
Text text3 = new Text();
text3.setText(ch);
text3.setFont(Font.font("Arial", FontWeight.BOLD, 14));
text3.setFill(Color.web("#363a38"));
notification.DetailMSG.getChildren().add(text3);
notification.bouttonOK.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
notification.stackpane.setVisible(false);
AjouterClientCode.setText(ch);
}
});
notification.ShowNotification();
}
//fider tous les champs du formulaires
private void restechamp(){
AjouterClientCIN.setText("");
AjouterClientCode.setText("");
AjouterClientNomComplet.setText("");
AjouterClientNom.setText("");
AjouterClientPrenom.setText("");
AjouterClientNaissance.setValue(null);
AjouterClientTeleFixe.setText("");
AjouterClientTeleMobile.setText("");
AjouterClientCodePostal.setText("");
AjouterClientAdresse.setText("");
AjouterClientMail.setText("");
AjouterClientSexeHomme.setSelected(false);
AjouterClientSexeFemme.setSelected(false);
}
@Override
public void initialize(URL url, ResourceBundle rb) {
AjouterClientSexeHomme.setUserData("Homme");
AjouterClientSexeFemme.setUserData("Femme");
//lors de clique sur le textfilde CIN
AjouterClientCIN.setOnKeyReleased(new EventHandler<KeyEvent>() {
public void handle(KeyEvent ke) {
try {// if is number
Integer.parseInt(AjouterClientCIN.getText());
int cin =Integer.parseInt(AjouterClientCIN.getText());
if(dbclient.verifyCinClient(cin)){
ErreurCIN.setText("CIN existe déja");
AjouterClientCIN.setStyle("-fx-border-color:#f20606;");
}
else{
ErreurCIN.setText("");
AjouterClientCIN.setStyle("-fx-border-color: transparent;");
}
}
catch (NumberFormatException e) {
ErreurCIN.setText("CIN doit être 8 numéro");
AjouterClientCIN.setStyle("-fx-border-color:#f20606;");
}
}
});
}
private boolean Controles(){
boolean result ;
if(AjouterClientCode.getText().length()== 0){ //code client vide
this.getidclt();
result= true ;
}
else if(ctl.isNumeric(AjouterClientCode.getText())){ //code client n'est pas un numero
AjouterClientCode.setStyle("-fx-border-color:#f20606;");
ErreurCode.setText("code client doit être numéro");
result= true ;
}
else if(dbclient.verifyIdClient(Integer.parseInt(AjouterClientCode.getText()))){ //code client existe déja
AjouterClientCode.setStyle("-fx-border-color:#f20606;");
ErreurCode.setText("code client existe déja");
result= true ;
}
else{
AjouterClientCode.setStyle("-fx-border-color:transparent;");
ErreurCode.setText("");
if((AjouterClientCIN.getText().length()!= 8) || (ctl.isNumericNotnull(AjouterClientCIN.getText()))){
ErreurCIN.setText("CIN doit être 8 numéro");
AjouterClientCIN.setStyle("-fx-border-color:#f20606;");
result= true ;
}
else{
ErreurCIN.setText("");
AjouterClientCIN.setStyle("-fx-border-color: transparent;");
if(dbclient.verifyCinClient(Integer.parseInt(AjouterClientCIN.getText()))){
ErreurCIN.setText("CIN existe déja");
AjouterClientCIN.setStyle("-fx-border-color:#f20606;");
result= true ;
}
else{
ErreurCIN.setText("");
AjouterClientCIN.setStyle("-fx-border-color: transparent;");
if(AjouterClientNomComplet.getText().length()<10){
ErreurNomComplet.setText("Client doit dépasser 10 catactaire");
AjouterClientNomComplet.setStyle("-fx-border-color:#f20606;");
result= true ;
}
else{
ErreurNomComplet.setText("");
AjouterClientNomComplet.setStyle("-fx-border-color: transparent;");
if(AjouterClientPrenom.getText().length()<3){
AjouterClientPrenom.setStyle("-fx-border-color:#f20606;");
ErreurPrenom.setText("le prénom doit dépasser 3 caractaire");
result= true ;
}
else{
ErreurPrenom.setText("");
AjouterClientPrenom.setStyle("-fx-border-color: transparent;");
if(AjouterClientNom.getText().length()<3){
AjouterClientNom.setStyle("-fx-border-color:#f20606;");
ErreurNom.setText("Prénom doit dépasser 3 caractaire");
result= true ;
}
else{
AjouterClientNom.setStyle("-fx-border-color: transparent;");
ErreurNom.setText("");
if(AjouterClientNaissance.getValue()==null){
AjouterClientNaissance.setStyle("-fx-border-color:#f20606;");
ErreurNaissance.setText("Date de naissance vide");
result= true ;
}
else{
AjouterClientNaissance.setStyle("-fx-border-color: transparent;");
ErreurNaissance.setText("");
if(ctl.isNumericNotnull(AjouterClientTeleFixe.getText())){
AjouterClientTeleFixe.setStyle("-fx-border-color:#f20606;");
ErreurTeleFixe.setText("tele doit être numéro");
result= true ;
}
else{
AjouterClientTeleFixe.setStyle("-fx-border-color: transparent;");
ErreurTeleFixe.setText("");
if(AjouterClientTeleMobile.getText().length()>0){
if(ctl.isNumeric(AjouterClientTeleMobile.getText())){
AjouterClientTeleMobile.setStyle("-fx-border-color:#f20606;");
ErreurTeleMobile.setText("tele doit être numéro");
result= true ;
}
else{
AjouterClientTeleMobile.setStyle("-fx-border-color: transparent;");
ErreurTeleMobile.setText("");
}
}
if(groupesexe.getSelectedToggle()== null){
ErreurSexe.setText("Veuillez sélectionner le sexe");
result= true ;
}
else{
ErreurSexe.setText("");
if(AjouterClientAdresse.getText().length()<4){
AjouterClientAdresse.setStyle("-fx-border-color: #f20606;");
ErreurAdresse.setText("Adresse doit dépasser 4 caractaire");
result= true ;
}
else{
AjouterClientAdresse.setStyle("-fx-border-color: transparent;");
ErreurAdresse.setText("");
if(ctl.isNumeric(AjouterClientCodePostal.getText())){
AjouterClientCodePostal.setStyle("-fx-border-color: #f20606;");
ErreurCodePostal.setText("code doit être numéro");
result= true ;
}
else{
AjouterClientCodePostal.setStyle("-fx-border-color: transparent;");
ErreurCodePostal.setText("");
if(AjouterClientMail.getText().length()> 0){
if(AjouterClientMail.getText().indexOf("@")< 0){
AjouterClientMail.setStyle("-fx-border-color: #f20606;");
ErreurMail.setText("invalide mail");
result= true ;
}
else{
AjouterClientMail.setStyle("-fx-border-color: transparent;");
ErreurMail.setText("");
result= false ;
}
}
else{
result= false ;
}
}
}
}
}
}
}
}
}
}
}
}
return result ;
}
}
@@ -0,0 +1,552 @@
/*
* 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.Client;
import Controllers.Traitement.Adaptateur;
import Controllers.Traitement.contro;
import Models.Client.Client;
import Models.Client.ClientDB;
import Models.Client.ClientEntreprise;
import Models.Client.ClientEntrepriseContact;
import Models.Client.ClientEntrepriseDB;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.animation.FadeTransition;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.DatePicker;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.util.Duration;
/**
* FXML Controller class
* @author PC-Maher
*/
public class DetailClientController implements Initializable {
@FXML private StackPane StackPaneSucessCltPersonne;
@FXML private AnchorPane AnchorPaneModifierCltPersonne;
@FXML private AnchorPane AnchorPaneModifierCltEntreprise;
@FXML public Text Nomclt ;
@FXML public Text Codeclt ;
@FXML private TextField AjouterClientCode;
@FXML private TextField AjouterClientCIN;
@FXML private TextField AjouterClientNomComplet;
@FXML private TextField AjouterClientNom;
@FXML private TextField AjouterClientPrenom;
@FXML private DatePicker AjouterClientNaissance;
@FXML private TextField AjouterClientTeleFixe;
@FXML private TextField AjouterClientTeleMobile;
@FXML private TextField AjouterClientAdresse;
@FXML private TextField AjouterClientCodePostal;
@FXML private TextField AjouterClientMail;
@FXML public ToggleGroup groupesexe;
@FXML private RadioButton RadioButtonSexeHomme;
@FXML private RadioButton RadioButtonSexeFemme;
@FXML private Text ErreurCode ;
@FXML private Text ErreurCIN ;
@FXML private Text ErreurNomComplet ;
@FXML private Text ErreurNom ;
@FXML private Text ErreurPrenom ;
@FXML private Text ErreurNaissance ;
@FXML private Text ErreurTeleFixe ;
@FXML private Text ErreurTeleMobile ;
@FXML private Text ErreurAdresse ;
@FXML private Text ErreurCodePostal ;
@FXML private Text ErreurMail ;
@FXML private Text ErreurSexe ;
@FXML private Text ErreurClientEntrepriseNom ;
@FXML private Text ErreurClientEntrepriseGerant ;
@FXML private Text ErreurClientEntrepriseMatricule ;
@FXML private Text ErreurClientEntrepriseAdresse ;
@FXML private Text ErreurClientEntreprisePostale ;
@FXML private Text ErreurClientEntrepriseTele1 ;
@FXML private Text ErreurClientEntrepriseTele2 ;
@FXML private Text ErreurClientEntrepriseMail ;
@FXML private Text ErreurClientEntrepriseFax ;
@FXML private Text ErreurClientEntrepriseContactNom ;
@FXML private Text ErreurClientEntrepriseContactPrenom ;
@FXML private Text ErreurClientEntrepriseContactCIN ;
@FXML private Text ErreurClientEntrepriseContactMail ;
@FXML private Text ErreurClientEntrepriseContactTele1 ;
@FXML private Text ErreurClientEntrepriseContactTele2 ;
@FXML private TextField ChampClientEntrepriseNom;
@FXML private TextField ChampClientEntrepriseGerant ;
@FXML private TextField ChampClientEntrepriseMatricule;
@FXML private TextField ChampClientEntrepriseAdresse;
@FXML private TextField ChampClientEntreprisePostale;
@FXML private TextField ChampClientEntrepriseTele1;
@FXML private TextField ChampClientEntrepriseTele2;
@FXML private TextField ChampClientEntrepriseMail;
@FXML private TextField ChampClientEntrepriseFax;
@FXML private TextField ChampClientEntrepriseContactNom;
@FXML private TextField ChampClientEntrepriseContactPrenom;
@FXML private TextField ChampClientEntrepriseContactCIN;
@FXML private TextField ChampClientEntrepriseContactMail;
@FXML private TextField ChampClientEntrepriseContactTele1;
@FXML private TextField ChampClientEntrepriseContactTele2;
ClientDB clientDB = new ClientDB();
ClientEntrepriseDB EntrepriseCltDB = new ClientEntrepriseDB();
ClientEntreprise entreprise = new ClientEntreprise();
ClientEntrepriseContact contactEtr = new ClientEntrepriseContact();
contro ctl= new contro() ;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
RadioButtonSexeFemme.setUserData("0");
RadioButtonSexeHomme.setUserData("1");
}
public void setDataClient(String codeclt)
{
AnchorPaneModifierCltEntreprise.setVisible(false);
AnchorPaneModifierCltPersonne.setVisible(true);
Client client = clientDB.getClient(codeclt);
Codeclt.setText(codeclt);
Nomclt.setText(client.getNom()+" "+client.getPrenom());
AjouterClientCode.setText(client.getCodeclient());
AjouterClientCIN.setText(client.getCinString());
AjouterClientNomComplet.setText(client.getNomcomplet());
AjouterClientNom.setText(client.getNom());
AjouterClientPrenom.setText(client.getPrenom());
AjouterClientNaissance.setValue(Adaptateur.StringToLocalDate(client.getNaissance().toString()));
AjouterClientTeleFixe.setText(client.getTelefixString());
AjouterClientTeleMobile.setText(client.getTelemobileString());
AjouterClientAdresse.setText(client.getAdresse());
AjouterClientCodePostal.setText(client.getCodepostal());
AjouterClientMail.setText(client.getMail());
if(client.getSexe() == 1){ RadioButtonSexeHomme.setSelected(true); }
if(client.getSexe() == 0){ RadioButtonSexeFemme.setSelected(true); }
}
@FXML
private void UpdateClientButtonAction(ActionEvent event) throws IOException
{
Client client = new Client();
if(!this.ControlesClient())
{
client.setCinString(AjouterClientCIN.getText());
client.setCodeclientString(AjouterClientCode.getText());
client.setNomcomplet(AjouterClientNomComplet.getText());
client.setNom(AjouterClientNom.getText());
client.setPrenom(AjouterClientPrenom.getText());
client.setNaissanceDatePicker(AjouterClientNaissance.getValue());
client.setTelefixString(AjouterClientTeleFixe.getText());
client.setTelemobileString(AjouterClientTeleMobile.getText());
client.setSexeString(groupesexe.getSelectedToggle().getUserData().toString());
client.setAdresse(AjouterClientAdresse.getText());
client.setCodepostal(AjouterClientCodePostal.getText());
client.setMail(AjouterClientMail.getText());
if(clientDB.updateClient(client))
{
FadeTransition ft = new FadeTransition(Duration.millis(400), AnchorPaneModifierCltPersonne);
ft.setFromValue(1.0);
ft.setToValue(0.0);
ft.play();
ft.setOnFinished(new EventHandler<ActionEvent>() {
//message de succés
@Override
public void handle(ActionEvent event) {
StackPaneSucessCltPersonne.setVisible(true);
}
});
}
}
}
private boolean ControlesClient()
{
boolean result ;
AjouterClientCode.setStyle("-fx-border-color:transparent;");
ErreurCode.setText("");
if((AjouterClientCIN.getText().length()!= 8) || (ctl.isNumericNotnull(AjouterClientCIN.getText()))){
ErreurCIN.setText("CIN doit être 8 numéro");
AjouterClientCIN.setStyle("-fx-border-color:#f20606;");
result= true ;
}
else{
ErreurCIN.setText("");
AjouterClientCIN.setStyle("-fx-border-color: transparent;");
if(AjouterClientNomComplet.getText().length()<10){
ErreurNomComplet.setText("Client doit dépasser 10 catactaire");
AjouterClientNomComplet.setStyle("-fx-border-color:#f20606;");
result= true ;
}
else{
ErreurNomComplet.setText("");
AjouterClientNomComplet.setStyle("-fx-border-color: transparent;");
if(AjouterClientPrenom.getText().length()<3){
AjouterClientPrenom.setStyle("-fx-border-color:#f20606;");
ErreurPrenom.setText("le prénom doit dépasser 3 caractaire");
result= true ;
}
else{
ErreurPrenom.setText("");
AjouterClientPrenom.setStyle("-fx-border-color: transparent;");
if(AjouterClientNom.getText().length()<3){
AjouterClientNom.setStyle("-fx-border-color:#f20606;");
ErreurNom.setText("Prénom doit dépasser 3 caractaire");
result= true ;
}
else{
AjouterClientNom.setStyle("-fx-border-color: transparent;");
ErreurNom.setText("");
if(AjouterClientNaissance.getValue()==null){
AjouterClientNaissance.setStyle("-fx-border-color:#f20606;");
ErreurNaissance.setText("Date de naissance vide");
result= true ;
}
else{
AjouterClientNaissance.setStyle("-fx-border-color: transparent;");
ErreurNaissance.setText("");
if(ctl.isNumericNotnull(AjouterClientTeleFixe.getText())){
AjouterClientTeleFixe.setStyle("-fx-border-color:#f20606;");
ErreurTeleFixe.setText("tele doit être numéro");
result= true ;
}
else{
AjouterClientTeleFixe.setStyle("-fx-border-color: transparent;");
ErreurTeleFixe.setText("");
if(AjouterClientTeleMobile.getText() != ""){
if(ctl.isNumeric(AjouterClientTeleMobile.getText())){
AjouterClientTeleMobile.setStyle("-fx-border-color:#f20606;");
ErreurTeleMobile.setText("tele doit être numéro");
result= true ;
}
else{
AjouterClientTeleMobile.setStyle("-fx-border-color: transparent;");
ErreurTeleMobile.setText("");
}
}
if(groupesexe.getSelectedToggle()== null){
ErreurSexe.setText("Veuillez sélectionner le sexe");
result= true ;
}
else{
ErreurSexe.setText("");
if(AjouterClientAdresse.getText().length()<4){
AjouterClientAdresse.setStyle("-fx-border-color: #f20606;");
ErreurAdresse.setText("Adresse doit dépasser 4 caractaire");
result= true ;
}
else{
AjouterClientAdresse.setStyle("-fx-border-color: transparent;");
ErreurAdresse.setText("");
if(ctl.isNumeric(AjouterClientCodePostal.getText())){
AjouterClientCodePostal.setStyle("-fx-border-color: #f20606;");
ErreurCodePostal.setText("code doit être numéro");
result= true ;
}
else{
AjouterClientCodePostal.setStyle("-fx-border-color: transparent;");
ErreurCodePostal.setText("");
if(AjouterClientMail.getText().length()> 0){
if(AjouterClientMail.getText().indexOf("@")< 0){
AjouterClientMail.setStyle("-fx-border-color: #f20606;");
ErreurMail.setText("invalide mail");
result= true ;
}
else{
AjouterClientMail.setStyle("-fx-border-color: transparent;");
ErreurMail.setText("");
result= false ;
}
}
else{
result= false ;
}
}
}
}
}
}
}
}
}
}
return result ;
}
/**********************Clt Entreprise******************************/
public void setDataEntreprise(String codeEtr)
{
AnchorPaneModifierCltPersonne.setVisible(false);
AnchorPaneModifierCltEntreprise.setVisible(true);
entreprise = EntrepriseCltDB.GetClientEtr(codeEtr);
Codeclt.setText(codeEtr);
Nomclt.setText(entreprise.getNom());
ChampClientEntrepriseNom.setText(entreprise.getNom());
ChampClientEntrepriseGerant.setText(entreprise.getGerant()) ;
ChampClientEntrepriseMatricule.setText(entreprise.getMatricule());
ChampClientEntrepriseAdresse.setText(entreprise.getAdresse());
ChampClientEntreprisePostale.setText(entreprise.getPostalString());
ChampClientEntrepriseTele1.setText(entreprise.getTele1String());
ChampClientEntrepriseTele2.setText(entreprise.getTele2String());
ChampClientEntrepriseMail.setText(entreprise.getMail());
ChampClientEntrepriseFax.setText(entreprise.getFaxString());
contactEtr = entreprise.getContact();
ChampClientEntrepriseContactNom.setText(contactEtr.getNom());
ChampClientEntrepriseContactPrenom.setText(contactEtr.getPrenom());
ChampClientEntrepriseContactCIN.setText(contactEtr.getCINString());
ChampClientEntrepriseContactMail.setText(contactEtr.getMail());
ChampClientEntrepriseContactTele1.setText(contactEtr.getTele1String());
ChampClientEntrepriseContactTele2.setText(contactEtr.getTele2String());
}
@FXML
private void UpdateClientEntrepriseButtonAction(ActionEvent event) throws IOException
{
if(!ControlesEtr()){
if(!ControlesEtrContact()){
entreprise.setNom(ChampClientEntrepriseNom.getText());
entreprise.setGerant(ChampClientEntrepriseGerant.getText());
entreprise.setMatricule(ChampClientEntrepriseMatricule.getText());
entreprise.setAdresse(ChampClientEntrepriseAdresse.getText());
entreprise.setPostaleString(ChampClientEntreprisePostale.getText());
entreprise.setTele1String(ChampClientEntrepriseTele1.getText());
entreprise.setTele2String(ChampClientEntrepriseTele2.getText());
entreprise.setMail(ChampClientEntrepriseMail.getText());
entreprise.setFaxString(ChampClientEntrepriseFax.getText());
contactEtr.setNom(ChampClientEntrepriseContactNom.getText());
contactEtr.setPrenom(ChampClientEntrepriseContactPrenom.getText());
contactEtr.setCINString(ChampClientEntrepriseContactCIN.getText());
contactEtr.setTele1String(ChampClientEntrepriseContactTele1.getText());
contactEtr.setTele2String(ChampClientEntrepriseContactTele2.getText());
contactEtr.setMail(ChampClientEntrepriseContactMail.getText());
entreprise.setContact(contactEtr);
if(EntrepriseCltDB.updateEntreprise(entreprise))
{
FadeTransition ft = new FadeTransition(Duration.millis(400), AnchorPaneModifierCltEntreprise);
ft.setFromValue(1.0);
ft.setToValue(0.0);
ft.play();
ft.setOnFinished(new EventHandler<ActionEvent>() {
//message de succés
@Override
public void handle(ActionEvent event) {
StackPaneSucessCltPersonne.setVisible(true);
}
});
}
}
}
}
private boolean ControlesEtr()
{
boolean result=false ;
if(ChampClientEntrepriseNom.getText().length()<3){
ChampClientEntrepriseNom.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseNom.setText("Nom doit dépasser 3 caractère");
result= true ;
}
else{
ChampClientEntrepriseNom.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseNom.setText("");
if(ChampClientEntrepriseGerant.getText().length()<3){
ChampClientEntrepriseGerant.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseGerant.setText("Gérant doit dépasser 3 caractère");
result= true ;
}
else{
ChampClientEntrepriseGerant.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseGerant.setText("");
if(ctl.isNumeric(ChampClientEntrepriseMatricule.getText())){
ChampClientEntrepriseMatricule.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseMatricule.setText("Matricule doit être numéro");
result= true ;
}
else{
ChampClientEntrepriseMatricule.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseMatricule.setText("");
if(ChampClientEntrepriseAdresse.getText().length()<3){
ChampClientEntrepriseAdresse.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseAdresse.setText("L'adresse doit dépasser 3 caractère");
result= true ;
}
else{
ChampClientEntrepriseAdresse.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseAdresse.setText("");
if(ctl.isNumeric(ChampClientEntreprisePostale.getText())){
ChampClientEntreprisePostale.setStyle("-fx-border-color:#f20606;");
ErreurClientEntreprisePostale.setText("code doit être numéro");
result= true ;
}
else{
ChampClientEntreprisePostale.setStyle("-fx-border-color:transparent;");
ErreurClientEntreprisePostale.setText("");
if(ctl.isNumericNotnull(ChampClientEntrepriseTele1.getText())){
ChampClientEntrepriseTele1.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseTele1.setText("Tele doit être numéro");
result= true ;
}
else{
ChampClientEntrepriseTele1.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseTele1.setText("");
if(ctl.isNumeric(ChampClientEntrepriseTele2.getText())){
ChampClientEntrepriseTele2.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseTele2.setText("Tele2 doit être numéro");
result= true ;
}
else{
ChampClientEntrepriseTele2.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseTele2.setText("");
if(ctl.isNumeric(ChampClientEntrepriseFax.getText())){
ChampClientEntrepriseFax.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseFax.setText("Fax doit être numéro");
result= true ;
}
else{
ChampClientEntrepriseFax.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseFax.setText("");
if(ChampClientEntrepriseMail.getText().length()>0 && ChampClientEntrepriseMail.getText().indexOf("@")< 0){
ChampClientEntrepriseMail.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseMail.setText("invalide mail");
result= true ;
}
else{
ChampClientEntrepriseMail.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseMail.setText("");
}
}
}
}
}
}
}
}
}
return result ;
}
private boolean ControlesEtrContact(){
boolean result=false ;
if(ChampClientEntrepriseContactNom.getText().length()<4){
ChampClientEntrepriseContactNom.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseContactNom.setText("Nom doit dépasser 4 caractère");
result= true ;
}
else{
ChampClientEntrepriseContactNom.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseContactNom.setText("");
if(ChampClientEntrepriseContactPrenom.getText().length()<4){
ChampClientEntrepriseContactPrenom.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseContactPrenom.setText("Prénom doit dépasser 4 caractère");
result= true ;
}
else{
ChampClientEntrepriseContactPrenom.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseContactPrenom.setText("");
if(ctl.isNumeric(ChampClientEntrepriseContactCIN.getText())){
ChampClientEntrepriseContactCIN.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseContactCIN.setText("CIN doit être un numéro");
result= true ;
}
else{
ChampClientEntrepriseContactCIN.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseContactCIN.setText("");
if(ChampClientEntrepriseContactMail.getText().length()>0){
if(ChampClientEntrepriseContactMail.getText().indexOf("@")< 0){
ChampClientEntrepriseContactMail.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseContactMail.setText("invalide mail");
result= true ;
}
else{
ChampClientEntrepriseContactMail.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseContactMail.setText("");
}
}
if(ctl.isNumericNotnull(ChampClientEntrepriseContactTele1.getText())){
ChampClientEntrepriseContactTele1.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseContactTele1.setText("Tele doit être un numéro");
result= true ;
}
else{
ChampClientEntrepriseContactTele1.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseContactTele1.setText("");
if(ctl.isNumeric(ChampClientEntrepriseContactTele2.getText())){
ChampClientEntrepriseContactTele2.setStyle("-fx-border-color:#f20606;");
ErreurClientEntrepriseContactTele2.setText("Tele doit être un numéro");
result= true ;
}
else{
ChampClientEntrepriseContactTele2.setStyle("-fx-border-color:transparent;");
ErreurClientEntrepriseContactTele2.setText("");
}
}
}
}
}
return result ;
}
}
@@ -0,0 +1,417 @@
package Controllers.Client;
import Models.Client.ClientEntrepriseDB;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
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.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.Label;
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.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;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class GestionClientEntrepriseController implements Initializable {
@FXML private AnchorPane AnchorPaneGestionClt;
@FXML private ProgressBar ProgressBarClientEntreprise;
@FXML private Button ButtonSearchClientEntreprise;
@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 ;
@FXML private TextField GestionClientCodeEtr;
@FXML private TextField GestionClientNomEtr;
@FXML private TextField GestionClientGerantEtr;
@FXML private TextField GestionClientMatriculeEtr;
@FXML private TextField GestionClientAdresseEtr;
@FXML private TextField GestionClientTelephoneEtr;
@FXML private TableView<ListeClientEntreprise> TableViewListeClientEntreprise ;
@FXML private TableColumn<ListeClientEntreprise ,String> CodeClientEtr;
@FXML private TableColumn<ListeClientEntreprise ,String> NomEntreprise;
@FXML private TableColumn<ListeClientEntreprise ,String> Gerant ;
@FXML private TableColumn<ListeClientEntreprise ,String> matricule;
@FXML private TableColumn<ListeClientEntreprise ,String> Adresse;
@FXML private TableColumn<ListeClientEntreprise ,Integer> Telephone;
@FXML private TableColumn<ListeClientEntreprise, Boolean> Action ;
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;
private Service<Void> ThreadSearchClientEntreprise;
@Override
public void initialize(URL url, ResourceBundle rb) {
NbrLigne.setItems(cursors);
NbrLigne.getSelectionModel().selectFirst();
CodeClientEtr.setCellValueFactory(new PropertyValueFactory<ListeClientEntreprise, String>("code"));
NomEntreprise.setCellValueFactory(new PropertyValueFactory<ListeClientEntreprise, String>("NomEntreprise"));
Gerant.setCellValueFactory(new PropertyValueFactory<ListeClientEntreprise, String>("Gerant"));
matricule.setCellValueFactory(new PropertyValueFactory<ListeClientEntreprise, String>("matricule"));
Adresse.setCellValueFactory(new PropertyValueFactory<ListeClientEntreprise, String>("Adresse"));
Telephone.setCellValueFactory(new PropertyValueFactory<ListeClientEntreprise, Integer>("Telephone"));
Action.setSortable(true);
Action.setStyle( "-fx-alignment: CENTER;");Action.getStyleClass().add("Center");
Action.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<ListeClientEntreprise, Boolean>,ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(TableColumn.CellDataFeatures<ListeClientEntreprise, Boolean> p) {
return new SimpleBooleanProperty(p.getValue() != null);
}
});
// create a cell value factory with an add button for each row in the table.
Action.setCellFactory(new Callback<TableColumn<ListeClientEntreprise, Boolean>, TableCell<ListeClientEntreprise, Boolean>>() {
@Override
public TableCell<ListeClientEntreprise, Boolean> call(TableColumn<ListeClientEntreprise, Boolean> personBooleanTableColumn) {
return new ButtonCell();
}
});
//DOUBLE CLIQUE SUR UN CLIENT
TableViewListeClientEntreprise.setOnMouseClicked(new EventHandler<javafx.scene.input.MouseEvent>(){
public void handle(MouseEvent event){
if(event.getClickCount()>1){
if(TableViewListeClientEntreprise.getSelectionModel().getSelectedIndex()>=0){
try {
AnchorPaneGestionClt.getChildren().clear();
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Client/DetailClient.fxml"));
Parent root = (Parent)fxmlLoader.load();
DetailClientController DcltCtl = fxmlLoader.<DetailClientController>getController();
DcltCtl.setDataEntreprise(TableViewListeClientEntreprise.getSelectionModel().getSelectedItem().getCode());
AnchorPaneGestionClt.getChildren().add(root);
//
//DcltCtl.setUser("sqdfqsdf");
} catch (IOException ex) {
Logger.getLogger(GestionClientEntrepriseController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
});
ButtonSearchClientEntreprise.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchClientEntreprise();
}
});
AnchorPaneGestionClt.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchClientEntreprise();
}
}
});
GestionSearchClientEntreprise();
}
@FXML
public void AjouterClientPersonneRadioAction(ActionEvent event) throws IOException {
AnchorPaneGestionClt.getChildren().clear();
AnchorPaneGestionClt.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Client/GestionClientPersonne.fxml")));
}
//Define the button cell
private class ButtonCell extends TableCell<ListeClientEntreprise, 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);
//Action when the button is pressed
cellButton.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
// get Selected Item
ListeClientEntreprise currentEntreprise = (ListeClientEntreprise) ButtonCell.this.getTableView().getItems().get(ButtonCell.this.getIndex());
try {
AnchorPaneGestionClt.getChildren().clear();
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Client/DetailClient.fxml"));
Parent root = (Parent)fxmlLoader.load();
DetailClientController DcltCtl = fxmlLoader.<DetailClientController>getController();
DcltCtl.setDataEntreprise(currentEntreprise.getCode());
AnchorPaneGestionClt.getChildren().add(root);
} catch (IOException ex) {
Logger.getLogger(GestionClientEntrepriseController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
//Display button if the row is not empty
@Override
protected void updateItem(Boolean t, boolean empty) {
if(!empty){
setGraphic(cellButton);
} else {
setGraphic(null);
}
}
}
/****************************************************************************** *
* *
* Methode last Next TableView *
* * *
******************************************************************************/
private void SearchClientEntreprise()
{
ProgressBarClientEntreprise.setVisible(true);
ButtonSearchClientEntreprise.setDisable(true);
ThreadSearchClientEntreprise = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
position = 0;
actuellepage = 1;
ObservableList<ListeClientEntreprise> ListeCltEntreprise = new ClientEntrepriseDB().SearchCltEntrepriseGestion(
position,
nbrligne,
GestionClientCodeEtr.getText(),
GestionClientNomEtr.getText(),
GestionClientGerantEtr.getText(),
GestionClientMatriculeEtr.getText(),
GestionClientAdresseEtr.getText(),
GestionClientTelephoneEtr.getText());
TableViewListeClientEntreprise.setItems(ListeCltEntreprise);
totalcount = new ClientEntrepriseDB().nbrCltEntrepriseGestion(GestionClientCodeEtr.getText(), GestionClientNomEtr.getText(), GestionClientGerantEtr.getText(), GestionClientMatriculeEtr.getText(), GestionClientAdresseEtr.getText(), GestionClientTelephoneEtr.getText());
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;
}
};
}
};
ThreadSearchClientEntreprise.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarClientEntreprise.setVisible(false);
ButtonSearchClientEntreprise.setDisable(false);
LabelCount.setText(totalcount.toString());
}
});
ThreadSearchClientEntreprise.start();
}
private void NextLastSearchClientEntreprise(Integer ParmPosition, Integer ParamNbrligne)
{
ProgressBarClientEntreprise.setVisible(true);
ButtonSearchClientEntreprise.setDisable(true);
ThreadSearchClientEntreprise = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
ObservableList<ListeClientEntreprise> ListeCltEntreprise = new ClientEntrepriseDB().SearchCltEntrepriseGestion(
ParmPosition,
ParamNbrligne,
GestionClientCodeEtr.getText(),
GestionClientNomEtr.getText(),
GestionClientGerantEtr.getText(),
GestionClientMatriculeEtr.getText(),
GestionClientAdresseEtr.getText(),
GestionClientTelephoneEtr.getText());
TableViewListeClientEntreprise.setItems(ListeCltEntreprise);
return null;
}
};
}
};
ThreadSearchClientEntreprise.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarClientEntreprise.setVisible(false);
ButtonSearchClientEntreprise.setDisable(false);
}
});
ThreadSearchClientEntreprise.start();
}
private void GestionSearchClientEntreprise()
{
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;
NextLastSearchClientEntreprise(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;
NextLastSearchClientEntreprise(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;
NextLastSearchClientEntreprise(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;
NextLastSearchClientEntreprise(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;
NextLastSearchClientEntreprise(position, nbrligne);
actuellepage=actuellepage-3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
}
}
@@ -0,0 +1,413 @@
package Controllers.Client;
import Models.Client.ClientDB;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
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.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.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;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class GestionClientPersonneController implements Initializable {
@FXML private AnchorPane AnchorPaneGestionClt;
@FXML private AnchorPane AnchorPaneCltBody ;
@FXML private ProgressBar ProgressBarClientPersonne;
@FXML private Button ButtonSearchClientPersonne;
@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 ;
@FXML private TextField GestionClientcode;
@FXML private TextField GestionClientcin;
@FXML private TextField GestionClientnomcomplet;
@FXML private TextField GestionClientnom;
@FXML private TextField GestionClientprenom;
@FXML private DatePicker DatePickerNaissance;
@FXML private TableView<ListeClient> TableViewListeClient ;
@FXML private TableColumn<ListeClient ,Integer> codeclient;
@FXML private TableColumn<ListeClient ,Integer> cin;
@FXML private TableColumn<ListeClient ,String> nomcomplet;
@FXML private TableColumn<ListeClient ,String> nom;
@FXML private TableColumn<ListeClient ,String> prenom;
@FXML private TableColumn<ListeClient ,Integer> tele;
@FXML private TableColumn<ListeClient, Boolean> Action ;
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;
private Service<Void> ThreadSearchClientPersonne;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
NbrLigne.setItems(cursors);
NbrLigne.getSelectionModel().selectFirst();
codeclient.setCellValueFactory(new PropertyValueFactory<ListeClient, Integer>("code"));
cin.setCellValueFactory(new PropertyValueFactory<ListeClient, Integer>("cin"));
nomcomplet.setCellValueFactory(new PropertyValueFactory<ListeClient, String>("nomcomplet"));
nom.setCellValueFactory(new PropertyValueFactory<ListeClient, String>("nom"));
prenom.setCellValueFactory(new PropertyValueFactory<ListeClient, String>("prenom"));
tele.setCellValueFactory(new PropertyValueFactory<ListeClient, Integer>("tele"));
Action.setSortable(true);
Action.setStyle( "-fx-alignment: CENTER;");Action.getStyleClass().add("Center");
Action.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<ListeClient, Boolean>, ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(TableColumn.CellDataFeatures<ListeClient, Boolean> p) {
return new SimpleBooleanProperty(p.getValue() != null);
}
});
// create a cell value factory with an add button for each row in the table.
Action.setCellFactory(new Callback<TableColumn<ListeClient, Boolean>, TableCell<ListeClient, Boolean>>() {
@Override
public TableCell<ListeClient, Boolean> call(TableColumn<ListeClient, Boolean> personBooleanTableColumn) {
return new GestionClientPersonneController.ButtonCell();
}
});
ButtonSearchClientPersonne.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchClientPersonne();
}
});
AnchorPaneGestionClt.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchClientPersonne();
}
}
});
GestionSearchClientPersonne();
}
//Define the button cell
private class ButtonCell extends TableCell<ListeClient, 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);
//Action when the button is pressed
cellButton.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
// get Selected Item
ListeClient currentPerson = (ListeClient) ButtonCell.this.getTableView().getItems().get(ButtonCell.this.getIndex());
try {
AnchorPaneGestionClt.getChildren().clear();
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Client/DetailClient.fxml"));
Parent root = (Parent)fxmlLoader.load();
DetailClientController DcltCtl = fxmlLoader.<DetailClientController>getController();
DcltCtl.setDataClient(currentPerson.getCode().toString());
AnchorPaneGestionClt.getChildren().add(root);
} catch (IOException ex) {
Logger.getLogger(GestionClientEntrepriseController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
//Display button if the row is not empty
@Override
protected void updateItem(Boolean t, boolean empty) {
if(!empty){
setGraphic(cellButton);
} else {
setGraphic(null);
}
}
}
// modifer pour client entreprise
@FXML
public void AjouterClientEntrepriseRadioAction(ActionEvent event) throws IOException {
AnchorPaneGestionClt.getChildren().clear();
AnchorPaneGestionClt.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Client/GestionClientEntreprise.fxml")));
}
/****************************************************************************** *
* *
* Methode last Next TableView *
* * *
******************************************************************************/
private void SearchClientPersonne()
{
ProgressBarClientPersonne.setVisible(true);
ButtonSearchClientPersonne.setDisable(true);
ThreadSearchClientPersonne = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
position = 0;
actuellepage = 1;
String DateNaissance = "";
if(DatePickerNaissance.getValue() != null){
DateNaissance = DatePickerNaissance.getValue().toString();
}
ObservableList<ListeClient> ListeCltPersonne = new ClientDB().SearchCltPersonneGestion(
position,
nbrligne,
GestionClientcode.getText(),
GestionClientcin.getText(),
GestionClientnomcomplet.getText(),
GestionClientnom.getText(),
GestionClientprenom.getText(),
DateNaissance);
TableViewListeClient.setItems(ListeCltPersonne);
totalcount = new ClientDB().nbrCltPersonneGestion(GestionClientcode.getText(), GestionClientcin.getText(), GestionClientnomcomplet.getText(), GestionClientnom.getText(), GestionClientprenom.getText(), DateNaissance);
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;
}
};
}
};
ThreadSearchClientPersonne.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarClientPersonne.setVisible(false);
ButtonSearchClientPersonne.setDisable(false);
LabelCount.setText(totalcount.toString());
}
});
ThreadSearchClientPersonne.start();
}
private void NextLastSearchClientPersonne(Integer ParmPosition, Integer ParamNbrligne)
{
ProgressBarClientPersonne.setVisible(true);
ButtonSearchClientPersonne.setDisable(true);
ThreadSearchClientPersonne = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
String DateNaissance = "";
if(DatePickerNaissance.getValue() != null){
DateNaissance = DatePickerNaissance.getValue().toString();
}
ObservableList<ListeClient> ListeCltPersonne = new ClientDB().SearchCltPersonneGestion(
ParmPosition,
ParamNbrligne,
GestionClientcode.getText(),
GestionClientcin.getText(),
GestionClientnomcomplet.getText(),
GestionClientnom.getText(),
GestionClientprenom.getText(),
DateNaissance);
TableViewListeClient.setItems(ListeCltPersonne);
return null;
}
};
}
};
ThreadSearchClientPersonne.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarClientPersonne.setVisible(false);
ButtonSearchClientPersonne.setDisable(false);
}
});
ThreadSearchClientPersonne.start();
}
private void GestionSearchClientPersonne()
{
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;
NextLastSearchClientPersonne(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;
NextLastSearchClientPersonne(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;
NextLastSearchClientPersonne(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;
NextLastSearchClientPersonne(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;
NextLastSearchClientPersonne(position, nbrligne);
actuellepage=actuellepage-3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
}
}
@@ -0,0 +1,82 @@
/*
* 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.Client;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleLongProperty;
import javafx.beans.property.SimpleStringProperty;
/**
*
* @author PC-Maher
*/
public class ListeClient {
private final SimpleStringProperty code;
private final SimpleStringProperty cin;
private final SimpleStringProperty nomcomplet;
private final SimpleStringProperty nom;
private final SimpleStringProperty prenom;
private final SimpleStringProperty naissance_str;
private final SimpleStringProperty adresse;
private final SimpleStringProperty tele;
private final SimpleStringProperty tele2;
private final SimpleIntegerProperty sexe;
public ListeClient(String code, String cin, String nomcomplet, String nom, String prenom, String naissance_str, String adresse, String tele, String tele2, Integer sexe) {
this.code = new SimpleStringProperty(code);
this.cin = new SimpleStringProperty(cin);
this.nomcomplet = new SimpleStringProperty(nomcomplet);
this.nom = new SimpleStringProperty(nom);
this.prenom = new SimpleStringProperty(prenom);
this.naissance_str = new SimpleStringProperty(naissance_str);
this.adresse = new SimpleStringProperty(adresse);
this.tele = new SimpleStringProperty(tele);
this.tele2 = new SimpleStringProperty(tele2);
this.sexe = new SimpleIntegerProperty(sexe);
}
public String getCode() {
return code.get();
}
public String getCin() {
return cin.get();
}
public String getNomcomplet() {
return nomcomplet.get();
}
public String getNom() {
return nom.get();
}
public String getPrenom() {
return prenom.get();
}
public String getNaissanceString() {
return naissance_str.get();
}
public String getAdresse() {
return adresse.get();
}
public String getTele() {
return tele.get();
}
public String getTele2() {
return tele2.get();
}
public Integer getSexe() {
return sexe.get();
}
}
@@ -0,0 +1,66 @@
/*
* 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.Client;
import javafx.beans.property.SimpleLongProperty;
import javafx.beans.property.SimpleStringProperty;
/**
*
* @author Maher
*/
public class ListeClientEntreprise {
private final SimpleStringProperty code;
private final SimpleStringProperty NomEntreprise;
private final SimpleStringProperty gerant;
private final SimpleStringProperty matricule;
private final SimpleStringProperty adresse;
private final SimpleStringProperty Telephone;
private final SimpleStringProperty Telephone2;
public ListeClientEntreprise(String code, String nomEtr, String gerant, String matricule, String adresse, String Telephone, String Telephone2) {
this.code = new SimpleStringProperty(code);
this.NomEntreprise = new SimpleStringProperty(nomEtr);
this.gerant = new SimpleStringProperty(gerant);
this.matricule = new SimpleStringProperty(matricule);
this.adresse = new SimpleStringProperty(adresse);
this.Telephone = new SimpleStringProperty(Telephone);
this.Telephone2 = new SimpleStringProperty(Telephone2);
}
public String getCode() {
return code.get();
}
public String getNomEntreprise() {
return NomEntreprise.get();
}
public String getGerant() {
return gerant.get();
}
public String getMatricule() {
return matricule.get();
}
public String getAdresse() {
return adresse.get();
}
public String getTelephone() {
return Telephone.get();
}
public String getTelephone2() {
return Telephone2.get();
}
}
@@ -0,0 +1,47 @@
/*
* 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.Client;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.layout.AnchorPane;
/**
* FXML Controller class
*
* @author Maher
*/
public class MenuClientController implements Initializable {
/**
* Initializes the controller class.
*/
@FXML private AnchorPane AnchorPaneAjouterClient ;
@FXML
private void AjouterClientButtonAction(ActionEvent event) throws IOException {
AnchorPaneAjouterClient.getChildren().clear();
AnchorPaneAjouterClient.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Client/AjouterClient.fxml")));
}
@FXML
private void detailClientButtonAction(ActionEvent event) throws IOException {
AnchorPaneAjouterClient.getChildren().clear();
AnchorPaneAjouterClient.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Client/GestionClientPersonne.fxml")));
}
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
}
@@ -0,0 +1,364 @@
package Controllers.Client;
import Controllers.Traitement.MyWindow;
import Models.Client.ClientEntrepriseDB;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
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.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class RechercherClientEntrepriseController implements Initializable {
@FXML public AnchorPane AnchoreClientEntre ;
public Node nodeFxmlEtr ;
@FXML private ProgressBar ProgressBarClientEntreprise;
@FXML public RadioButton cltPer ;
@FXML public RadioButton cltEtr ;
@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 ;
@FXML private Button ButtonSearchClientEntreprise;
@FXML private TextField RerchercheCodeEtr;
@FXML private TextField RerchercheNomEtr;
@FXML private TextField RerchercheGerantEtr;
@FXML private TextField RerchercheMatriculeEtr;
@FXML private TextField RerchercheAdresseEtr;
@FXML private TextField RerchercheTelephoneEtr;
@FXML private TableView<ListeClientEntreprise> TableViewListeClientEntreprise ;
@FXML private TableColumn<ListeClientEntreprise ,String> TableColumnCodeClientEtr;
@FXML private TableColumn<ListeClientEntreprise ,String> TableColumnNomEntreprise;
@FXML private TableColumn<ListeClientEntreprise ,String> TableColumnGerant ;
@FXML private TableColumn<ListeClientEntreprise ,String> TableColumnMatricule;
@FXML private TableColumn<ListeClientEntreprise ,String> TableColumnAdresse;
@FXML private TableColumn<ListeClientEntreprise ,Integer> TableColumnTelephone;
@FXML public TableColumn<ListeClientEntreprise, String> TableColumnActionEtre ;
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;
private Service<Void> ThreadSearchRechercheClientEntreprise;
public RechercherClientEntrepriseController(){
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Client/RechercherClientEntreprise.fxml"));
fxmlLoader.setController(this);
nodeFxmlEtr = (Node) fxmlLoader.load();
} catch (IOException ex) {
Logger.getLogger(RechercherClientEntrepriseController.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Override
public void initialize(URL url, ResourceBundle rb) {
TableColumnCodeClientEtr.setCellValueFactory(new PropertyValueFactory<ListeClientEntreprise, String>("code"));
TableColumnNomEntreprise.setCellValueFactory(new PropertyValueFactory<ListeClientEntreprise, String>("NomEntreprise"));
TableColumnGerant.setCellValueFactory(new PropertyValueFactory<ListeClientEntreprise, String>("Gerant"));
TableColumnMatricule.setCellValueFactory(new PropertyValueFactory<ListeClientEntreprise, String>("matricule"));
TableColumnAdresse.setCellValueFactory(new PropertyValueFactory<ListeClientEntreprise, String>("Adresse"));
TableColumnTelephone.setCellValueFactory(new PropertyValueFactory<ListeClientEntreprise, Integer>("Telephone"));
TableColumnActionEtre.setStyle( "-fx-alignment: CENTER;");
TableColumnActionEtre.getStyleClass().add("Center");
//comboboxnombre des lignes tableview
NbrLigne.setItems(cursors);
NbrLigne.getSelectionModel().selectFirst();
ButtonSearchClientEntreprise.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchClientEntreprise();
}
});
AnchoreClientEntre.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchClientEntreprise();
}
}
});
GestionSearchClientEntreprise();
}
@FXML
private void QuiterButtonAction(ActionEvent event) throws IOException {
AnchoreClientEntre.setVisible(false);
}
public void Show()
{
StackPane Sp = new StackPane();
Scene scene = new Scene(Sp);
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Stage stage = MyWindow.myStage;
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(nodeFxmlEtr);
stage.setScene(scene);
stage.show();
cltEtr.setSelected(true);
}
/****************************************************************************** *
* *
* Methode last Next TableView *
* * *
******************************************************************************/
private void SearchClientEntreprise()
{
ProgressBarClientEntreprise.setVisible(true);
ButtonSearchClientEntreprise.setDisable(true);
ThreadSearchRechercheClientEntreprise = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
position = 0;
actuellepage = 1;
ObservableList<ListeClientEntreprise> ListeCltEntreprise = new ClientEntrepriseDB().SearchCltEntrepriseGestion(
position,
nbrligne,
RerchercheCodeEtr.getText(),
RerchercheNomEtr.getText(),
RerchercheGerantEtr.getText(),
RerchercheMatriculeEtr.getText(),
RerchercheAdresseEtr.getText(),
RerchercheTelephoneEtr.getText());
TableViewListeClientEntreprise.setItems(ListeCltEntreprise);
totalcount = new ClientEntrepriseDB().nbrCltEntrepriseGestion(RerchercheCodeEtr.getText(), RerchercheNomEtr.getText(), RerchercheGerantEtr.getText(), RerchercheMatriculeEtr.getText(), RerchercheAdresseEtr.getText(), RerchercheTelephoneEtr.getText());
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;
}
};
}
};
ThreadSearchRechercheClientEntreprise.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarClientEntreprise.setVisible(false);
ButtonSearchClientEntreprise.setDisable(false);
LabelCount.setText(totalcount.toString());
}
});
ThreadSearchRechercheClientEntreprise.start();
}
private void NextLastSearchClientEntreprise(Integer ParmPosition, Integer ParamNbrligne)
{
ProgressBarClientEntreprise.setVisible(true);
ButtonSearchClientEntreprise.setDisable(true);
ThreadSearchRechercheClientEntreprise = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
ObservableList<ListeClientEntreprise> ListeCltEntreprise = new ClientEntrepriseDB().SearchCltEntrepriseGestion(
ParmPosition,
ParamNbrligne,
RerchercheCodeEtr.getText(),
RerchercheNomEtr.getText(),
RerchercheGerantEtr.getText(),
RerchercheMatriculeEtr.getText(),
RerchercheAdresseEtr.getText(),
RerchercheTelephoneEtr.getText());
TableViewListeClientEntreprise.setItems(ListeCltEntreprise);
return null;
}
};
}
};
ThreadSearchRechercheClientEntreprise.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarClientEntreprise.setVisible(false);
ButtonSearchClientEntreprise.setDisable(false);
}
});
ThreadSearchRechercheClientEntreprise.start();
}
private void GestionSearchClientEntreprise()
{
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;
NextLastSearchClientEntreprise(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;
NextLastSearchClientEntreprise(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;
NextLastSearchClientEntreprise(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;
NextLastSearchClientEntreprise(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;
NextLastSearchClientEntreprise(position, nbrligne);
actuellepage=actuellepage-3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
}
}
@@ -0,0 +1,396 @@
package Controllers.Client;
import Controllers.Traitement.MyWindow;
import Models.Client.Client;
import Models.Client.ClientDB;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
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.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class RechercherClientPersonneController implements Initializable {
@FXML public AnchorPane AnchoreClientPerson ;
@FXML public StackPane StackpaneClient ;
@FXML private ProgressBar ProgressBarClientPersonne;
@FXML private Button ButtonSearchClientPersonne;
@FXML public RadioButton cltEntreprise ;
@FXML public RadioButton cltPersonne ;
@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 ;
@FXML private TableView<ListeClient> TableViewListeClient ;
@FXML private TableColumn<ListeClient ,String> codeclient;
@FXML private TableColumn<ListeClient ,Integer> cin;
@FXML private TableColumn<ListeClient ,String> nomcomplet;
@FXML private TableColumn<ListeClient ,String> nom;
@FXML private TableColumn<ListeClient ,String> prenom;
@FXML private TableColumn<ListeClient ,String> tele;
@FXML public TableColumn<ListeClient, String> Action ;
@FXML private TextField GestionClientcode;
@FXML private TextField GestionClientcin;
@FXML private TextField GestionClientnomcomplet;
@FXML private TextField GestionClientnom;
@FXML private TextField GestionClientprenom;
@FXML private DatePicker DatePickerNaissance;
public Node nodeFxml ;
Client client = new Client();
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;
public Object[] ArrayObjectDataSave = new Object[10];
private Service<Void> ThreadSearchRerchecheClientPersonne;
public RechercherClientPersonneController() {
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Client/RechercherClientPersonne.fxml"));
fxmlLoader.setController(this);
nodeFxml = (Node) fxmlLoader.load();
} catch (IOException ex) {
Logger.getLogger(RechercherClientPersonneController.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Override
public void initialize(URL url, ResourceBundle rb) {
NbrLigne.setItems(cursors);
NbrLigne.getSelectionModel().selectFirst();
codeclient.setCellValueFactory(new PropertyValueFactory<ListeClient, String>("code"));
cin.setCellValueFactory(new PropertyValueFactory<ListeClient, Integer>("cin"));
nomcomplet.setCellValueFactory(new PropertyValueFactory<ListeClient, String>("nomcomplet"));
nom.setCellValueFactory(new PropertyValueFactory<ListeClient, String>("nom"));
prenom.setCellValueFactory(new PropertyValueFactory<ListeClient, String>("prenom"));
tele.setCellValueFactory(new PropertyValueFactory<ListeClient, String>("tele"));
Action.setStyle( "-fx-alignment: CENTER;");
Action.getStyleClass().add("Center");
ButtonSearchClientPersonne.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchClientPersonne();
}
});
AnchoreClientPerson.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchClientPersonne();
}
}
});
GestionSearchClientPersonne();
}
@FXML
private void QuiterButtonAction(ActionEvent event) throws IOException {
AnchoreClientPerson.setVisible(false);
}
public void ShowDialg()
{
StackPane Sp = new StackPane();
Scene scene = new Scene(Sp);
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(nodeFxml);
Stage stage = MyWindow.myStage;
stage.setScene(scene);
stage.show();
cltPersonne.setSelected(true);
}
/****************************************************************************** *
* *
* Methode last Next TableView *
* * *
******************************************************************************/
private void SearchClientPersonne()
{
ProgressBarClientPersonne.setVisible(true);
ButtonSearchClientPersonne.setDisable(true);
ThreadSearchRerchecheClientPersonne = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
position = 0;
actuellepage = 1;
String DateNaissance = "";
if(DatePickerNaissance.getValue() != null){
DateNaissance = DatePickerNaissance.getValue().toString();
}
ObservableList<ListeClient> ListeCltPersonne = new ClientDB().SearchCltPersonneGestion(
position,
nbrligne,
GestionClientcode.getText(),
GestionClientcin.getText(),
GestionClientnomcomplet.getText(),
GestionClientnom.getText(),
GestionClientprenom.getText(),
DateNaissance);
TableViewListeClient.setItems(ListeCltPersonne);
totalcount = new ClientDB().nbrCltPersonneGestion(GestionClientcode.getText(), GestionClientcin.getText(), GestionClientnomcomplet.getText(), GestionClientnom.getText(), GestionClientprenom.getText(), DateNaissance);
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;
}
};
}
};
ThreadSearchRerchecheClientPersonne.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarClientPersonne.setVisible(false);
ButtonSearchClientPersonne.setDisable(false);
LabelCount.setText(totalcount.toString());
}
});
ThreadSearchRerchecheClientPersonne.start();
}
private void NextLastSearchClientPersonne(Integer ParmPosition, Integer ParamNbrligne)
{
ProgressBarClientPersonne.setVisible(true);
ButtonSearchClientPersonne.setDisable(true);
ThreadSearchRerchecheClientPersonne = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
String DateNaissance = "";
if(DatePickerNaissance.getValue() != null){
DateNaissance = DatePickerNaissance.getValue().toString();
}
ObservableList<ListeClient> ListeCltPersonne = new ClientDB().SearchCltPersonneGestion(
ParmPosition,
ParamNbrligne,
GestionClientcode.getText(),
GestionClientcin.getText(),
GestionClientnomcomplet.getText(),
GestionClientnom.getText(),
GestionClientprenom.getText(),
DateNaissance);
TableViewListeClient.setItems(ListeCltPersonne);
return null;
}
};
}
};
ThreadSearchRerchecheClientPersonne.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarClientPersonne.setVisible(false);
ButtonSearchClientPersonne.setDisable(false);
}
});
ThreadSearchRerchecheClientPersonne.start();
}
private void GestionSearchClientPersonne()
{
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;
NextLastSearchClientPersonne(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;
NextLastSearchClientPersonne(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;
NextLastSearchClientPersonne(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;
NextLastSearchClientPersonne(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;
NextLastSearchClientPersonne(position, nbrligne);
actuellepage=actuellepage-3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
}
}
@@ -0,0 +1,196 @@
package Controllers.CommandeClt;
import Controllers.BonLivraisonClt.BonLivraisonCltAjouterEtape2Controller;
import Models.Produit.ListeProduit;
import Controllers.Traitement.Adaptateur;
import Models.CommandeClt.CommandeClt;
import Models.CommandeClt.CommandeCltDB;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
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.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Text;
/**
* @author Maher Ben Tili
*/
public class CommandeCltDetail implements Initializable {
@FXML private AnchorPane PaneAjouter ;
@FXML private AnchorPane AnchorPaneCommandeCltDetail ;
@FXML private AnchorPane AnchorPaneLoadingCommandeDetail ;
@FXML public AnchorPane AnchorPaneSucces ;
@FXML public AnchorPane AnchorPaneInfoCommandeClt;
@FXML private Text CodeCommande;
@FXML private Text DateCreation;
@FXML private Text Reglement;
@FXML private Text NetAPayer;
@FXML private Text TotalTVA;
@FXML private Text CodeDevis;
@FXML private Text TypeClt;
@FXML private Text Nom;
@FXML private Text Prenom;
@FXML private Text Adresse;
@FXML private Text TELE1;
@FXML private Text TELE2;
@FXML private Text TextPrenom ;
@FXML private Text TextMatricule ;
@FXML private TableView<ListeProduit> TableViewListeProduit ;
@FXML private TableColumn<ListeProduit ,String> TabColReference;
@FXML private TableColumn<ListeProduit ,String> TabColDesignation;
@FXML private TableColumn<ListeProduit ,String> TabColQuantite ;
@FXML private TableColumn<ListeProduit ,String> TabColPrixHT;
@FXML private TableColumn<ListeProduit ,String> TabColRemise;
@FXML private TableColumn<ListeProduit ,String> TabColTotalHT;
@FXML private TableColumn<ListeProduit ,String> TabColTVA;
@FXML private TableColumn<ListeProduit ,String> TabColTotalTTC;
@FXML private Button ButtonCreationBonLivraison;
private Service<Void> ThreadCommandeCltDetail;
CommandeClt commandeClt;
String idCommandeClt;
@Override
public void initialize(URL url, ResourceBundle rb) {
TableViewListeProduit.setEditable(false);
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");
ButtonCreationBonLivraison.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/BonLivraisonClt/BonLivraisonCltAjouterEtape2.fxml"));
Parent NodeBonLivraisonCltAjouterEtape2 = (Parent)fxmlLoader.load();
BonLivraisonCltAjouterEtape2Controller BonLivraisonCltAjouterEtape2= fxmlLoader.getController();
PaneAjouter.getChildren().clear();
PaneAjouter.getChildren().add(NodeBonLivraisonCltAjouterEtape2);
BonLivraisonCltAjouterEtape2.SetDataCommandeClt(idCommandeClt);
} catch (IOException ex) {
Logger.getLogger(CommandeCltDetail.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
public void SowDetailCommandeClt(String codeCommande){
idCommandeClt = codeCommande;
ThreadCommandeCltDetail = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
commandeClt = new CommandeCltDB().getCommandeClt(codeCommande);
return null;
}
};
}
};
ThreadCommandeCltDetail.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
CodeCommande.setText(commandeClt.getCodecommandeclt());
DateCreation.setText(Adaptateur.NormalDateFormat(commandeClt.getDate()));
Reglement.setText(commandeClt.getTypeRegementString());
TotalTVA.setText(commandeClt.getTotalTVA());
TypeClt.setText(commandeClt.getTypeClientString());
CodeDevis.setText(commandeClt.getCodeDevis());
if(commandeClt.getTypeClient()==0){
TextPrenom.setVisible(true);
TextMatricule.setVisible(false);
Nom.setText(commandeClt.CltPersonne.getNom());
Prenom.setText(commandeClt.CltPersonne.getPrenom());
Adresse.setText(commandeClt.CltPersonne.getAdresse());
TELE1.setText(commandeClt.CltPersonne.getTelefixString());
TELE2.setText(commandeClt.CltPersonne.getTelemobileString());
}
if(commandeClt.getTypeClient()==1){
TextPrenom.setVisible(false);
TextMatricule.setVisible(true);
Nom.setText(commandeClt.CltEntreprise.getNom());
Prenom.setText(commandeClt.CltEntreprise.getMatricule());
Adresse.setText(commandeClt.CltEntreprise.getAdresse());
TELE1.setText(commandeClt.CltEntreprise.getTele1String());
TELE2.setText(commandeClt.CltEntreprise.getTele2String());
}
if(commandeClt.getTypeClient()==2){
TextPrenom.setVisible(true);
TextMatricule.setVisible(false);
Nom.setText(commandeClt.CltPassager.getNom());
Prenom.setText(commandeClt.CltPassager.getPrenom());
Adresse.setText(commandeClt.CltPassager.getAdresse());
TELE1.setText(commandeClt.CltPassager.getTelefixString());
TELE2.setText(commandeClt.CltPassager.getTelemobileString());
}
if(commandeClt.getCodeBonLivraison() == null){
ButtonCreationBonLivraison.setVisible(true);
}else{
ButtonCreationBonLivraison.setVisible(false);
}
NetAPayer.setText(commandeClt.getNetAPayer());
TableViewListeProduit.setItems(commandeClt.getListeproduit());
AnchorPaneLoadingCommandeDetail.setVisible(false);
AnchorPaneCommandeCltDetail.setVisible(true);
}
});
ThreadCommandeCltDetail.start();
}
}
@@ -0,0 +1,203 @@
/*
* 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.CommandeClt;
import Models.Produit.ListeProduit;
import Controllers.Traitement.Adaptateur;
import Controllers.Traitement.MyWindow;
import Models.CommandeClt.CommandeClt;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;
/**
*
* @author PC-Maher
*/
public class CommandeCltDialogConfirmationController implements Initializable {
/**
* Initializes the controller class.
*/
public Node nodeFxml ;
@FXML public AnchorPane AnchorPrincipal ;
@FXML public Button Enregister ;
@FXML private Text DateCreation;
@FXML private Text Reglement;
@FXML private Text NetAPayer;
@FXML private Text TotalHorsTaxNet;
@FXML private Text TotalTVA;
@FXML private Text CodeDevis;
@FXML private Text TypeClt;
@FXML private Text Nom;
@FXML private Text Prenom;
@FXML private Text Adresse;
@FXML private Text TELE1;
@FXML private Text TELE2;
@FXML private Text TextPrenom ;
@FXML private Text TextMatricule ;
@FXML private Text TextCodeDevis;
@FXML public TableView<ListeProduit> TableViewListeProduitPassCommClt ;
@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;
@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");
Image coffeeImage = new Image(getClass().getResourceAsStream("/Public/icon/iconsave.png"));
ImageView buttonGraphic = new ImageView();
buttonGraphic.setImage(coffeeImage);
Enregister.setGraphic(buttonGraphic);
}
public void GetCommandeClt(CommandeClt commandeclt){
DateCreation.setText(Adaptateur.NormalDateFormat(commandeclt.getDate()));
if(commandeclt.getTypeRegement().equals("0")){
Reglement.setText("comptant");
}else if(commandeclt.getTypeRegement().equals("1")){
Reglement.setText("facilité");
}
NetAPayer.setText(commandeclt.getNetAPayer());
TotalHorsTaxNet.setText(commandeclt.getTotalHorsTaxNet());
TotalTVA.setText(commandeclt.getTotalTVA());
if(commandeclt.getCodeDevis()!=null){
CodeDevis.setVisible(true);
TextCodeDevis.setVisible(true);
CodeDevis.setText(commandeclt.getCodeDevis());
}
TypeClt.setText(commandeclt.getTypeClientString());
if(commandeclt.getTypeClient()==0){
TextPrenom.setVisible(true);
TextMatricule.setVisible(false);
Nom.setText(commandeclt.CltPersonne.getNom());
Prenom.setText(commandeclt.CltPersonne.getPrenom());
Adresse.setText(commandeclt.CltPersonne.getAdresse());
TELE1.setText(commandeclt.CltPersonne.getTelefixString());
TELE2.setText(commandeclt.CltPersonne.getTelemobileString());
}
if(commandeclt.getTypeClient()==1){
TextPrenom.setVisible(false);
TextMatricule.setVisible(true);
Nom.setText(commandeclt.CltEntreprise.getNom());
Prenom.setText(commandeclt.CltEntreprise.getMatricule());
Adresse.setText(commandeclt.CltEntreprise.getAdresse());
TELE1.setText(commandeclt.CltEntreprise.getTele1String());
TELE2.setText(commandeclt.CltEntreprise.getTele2String());
}
if(commandeclt.getTypeClient()==2){
TextPrenom.setVisible(true);
TextMatricule.setVisible(false);
Nom.setText(commandeclt.CltPassager.getNom());
Prenom.setText(commandeclt.CltPassager.getPrenom());
Adresse.setText(commandeclt.CltPassager.getAdresse());
TELE1.setText(commandeclt.CltPassager.getTelefixString());
TELE2.setText(commandeclt.CltPassager.getTelemobileString());
}
TableViewListeProduitPassCommClt.setItems(commandeclt.getListeproduit());
}
public CommandeCltDialogConfirmationController(){
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/CommandeClt/CommandeCltDialogConfirmation.fxml"));
fxmlLoader.setController(this);
nodeFxml = (Node) fxmlLoader.load();
} catch (IOException ex) {
Logger.getLogger(CommandeCltDialogConfirmationController.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void Show()
{
StackPane Sp = new StackPane();
Scene scene = new Scene(Sp);
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(nodeFxml);
Stage stage = MyWindow.myStage;
stage.setScene(scene);
stage.show();
}
@FXML
private void ExitButtonAction(ActionEvent event) throws IOException {
AnchorPrincipal.setVisible(false);
}
}
@@ -0,0 +1,466 @@
package Controllers.CommandeClt;
import Controllers.DevisClt.DevisCltGestionController;
import Controllers.Traitement.Adaptateur;
import Models.CommandeClt.CommandeClt;
import Models.CommandeClt.CommandeCltDB;
import Models.CommandeClt.CommandeCltListe;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
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.RadioButton;
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.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.util.Callback;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class CommandeCltGestionController implements Initializable {
@FXML private AnchorPane PaneGestion ;
@FXML private ProgressBar ProgressBarCommande;
@FXML private Button ButtonSearchCommande ;
@FXML private AnchorPane ListerPages;
@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 ;
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;
private Service<Void> ThreadSearchCommande;
@FXML public TableView<CommandeCltListe> TableViewGestionCommande;
@FXML public TableColumn<CommandeCltListe ,String> TabColCodeCommande;
@FXML public TableColumn<CommandeCltListe ,String> TabColModePaiement;
@FXML public TableColumn<CommandeCltListe ,String> TabColTypeClient;
@FXML public TableColumn<CommandeCltListe ,String> TabColCodeClient;
@FXML public TableColumn<CommandeCltListe ,String> TabColTotalCommande;
@FXML public TableColumn<CommandeCltListe ,String> TabColDateCreation ;
@FXML public TableColumn<CommandeCltListe ,String> TabColCodeDevis;
@FXML public TableColumn<CommandeCltListe ,String> TabColFacture;
@FXML public TableColumn<CommandeCltListe ,String> TabColBonLivraison;
@FXML public TableColumn<CommandeCltListe ,Boolean>TabColAction ;
@FXML public TextField TextFieldCodeCommande;
@FXML public TextField TextFieldCodeClient;
@FXML public TextField TextFieldNameClient;
@FXML public TextField TextFieldCodeDevis;
@FXML public DatePicker DatePickerCreation;
@FXML public RadioButton RadioComptant;
@FXML public RadioButton RadioFacilite;
@Override
public void initialize(URL url, ResourceBundle rb) {
//comboboxnombre des lignes tableview
NbrLigne.setItems(cursors);
NbrLigne.getSelectionModel().selectFirst();
TableViewGestionCommande.setEditable(true);
TabColCodeCommande.setStyle( "-fx-alignment: CENTER;");TabColCodeCommande.getStyleClass().add("Center");
TabColCodeCommande.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("CodeCommande"));
TabColTypeClient.setStyle( "-fx-alignment: CENTER;");TabColTypeClient.getStyleClass().add("Center");
TabColTypeClient.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("TypeClient"));
TabColCodeClient.setStyle( "-fx-alignment: CENTER;");TabColCodeClient.getStyleClass().add("Center");
TabColCodeClient.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("CodeClient"));
TabColModePaiement.setStyle( "-fx-alignment: CENTER;");TabColModePaiement.getStyleClass().add("Center");
TabColModePaiement.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("ModePaiement"));
TabColTotalCommande.setStyle( "-fx-alignment: CENTER;");
TabColTotalCommande.getStyleClass().add("Center");
TabColTotalCommande.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("TotalCommande"));
TabColTotalCommande.setCellFactory(new Callback<TableColumn<CommandeCltListe,String>,TableCell<CommandeCltListe,String>>(){
@Override
public TableCell<CommandeCltListe, String> call(TableColumn<CommandeCltListe, String> param) {
TableCell<CommandeCltListe, String> cell = new TableCell<CommandeCltListe, String>(){
@Override
public void updateItem(String item, boolean empty) {
if(item!= null){
Text text = new Text(Adaptateur.StringToStringEspace(item));
setGraphic(text);
}else{
setGraphic(null);
}
}
};
return cell;
}
});
TabColDateCreation.setStyle( "-fx-alignment: CENTER;");TabColDateCreation.getStyleClass().add("Center");
TabColDateCreation.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("DateCreation"));
TabColCodeDevis.setStyle( "-fx-alignment: CENTER;");TabColCodeDevis.getStyleClass().add("Center");
TabColCodeDevis.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("CodeDevis"));
TabColFacture.setStyle( "-fx-alignment: CENTER;");TabColFacture.getStyleClass().add("Center");
TabColFacture.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("CodeFacture"));
TabColBonLivraison.setStyle( "-fx-alignment: CENTER;");TabColBonLivraison.getStyleClass().add("Center");
TabColBonLivraison.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("CodeBonLivraison"));
TabColAction.setSortable(true);
TabColAction.setStyle( "-fx-alignment: CENTER;");TabColAction.getStyleClass().add("Center");
TabColAction.setCellFactory(new Callback<TableColumn<CommandeCltListe, Boolean>, TableCell<CommandeCltListe, Boolean>>() {
@Override
public TableCell<CommandeCltListe, Boolean> call(TableColumn<CommandeCltListe, Boolean> personBooleanTableColumn) {
return new ButtonCell();
}
});
ButtonSearchCommande.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchCommande();
}
});
PaneGestion.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchCommande();
}
}
});
RadioComptant.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchCommande();
}
});
RadioFacilite.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchCommande();
}
});
GestionSearchCommande();
}
@FXML
private void PasserCommandeCltButtonAction(ActionEvent event) throws IOException {
//inisialiser les données de Sauvgarde des opération
CommandeCltPasserController.TypeClient = 2 ;
CommandeCltPasserController.codeclient = null ;
CommandeCltPasserController.codecliententre = null ;
CommandeCltPasserController.Mode = null ;
CommandeCltPasserController.CodeDevis = null;
CommandeCltPasserController.data.clear();
PaneGestion.getChildren().clear();
PaneGestion.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/CommandeClt/CommandeCltPasser.fxml")));
}
//Define the button cell
private class ButtonCell extends TableCell<CommandeCltListe, Boolean> {
final Button cellButton = new Button();
ButtonCell(){
cellButton.getStyleClass().add("btn-icon-primary");
Image coffeeImage = new Image(getClass().getResourceAsStream("/Public/icon/iconedit.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) {
// get Selected Item
CommandeCltListe current = (CommandeCltListe) ButtonCell.this.getTableView().getItems().get(ButtonCell.this.getIndex());
String codeCommande = current.getCodeCommande();
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/CommandeClt/CommandeCltDetail.fxml"));
Parent NodeDetail = (Parent)fxmlLoader.load();
CommandeCltDetail CommandeCltdetail = fxmlLoader.getController();
CommandeCltdetail.AnchorPaneSucces.setVisible(false);
CommandeCltdetail.AnchorPaneInfoCommandeClt.setPrefHeight(574);
AnchorPane.setTopAnchor(CommandeCltdetail.AnchorPaneInfoCommandeClt, 5.0);
CommandeCltdetail.SowDetailCommandeClt(codeCommande);
PaneGestion.getChildren().add(NodeDetail);
} catch (IOException ex) {
Logger.getLogger(DevisCltGestionController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
//Display button if the row is not empty
@Override
protected void updateItem(Boolean t, boolean empty) {
if(!empty){
setGraphic(cellButton);
} else {
setGraphic(null);
}
}
}
/****************************************************************************** *
* *
* Methode last Next TableView client Entreprise *
* * *
******************************************************************************/
private void SearchCommande()
{
ProgressBarCommande.setVisible(true);
ButtonSearchCommande.setDisable(true);
ThreadSearchCommande = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
position = 0;
actuellepage = 1;
String DateCreation = "";
if(DatePickerCreation.getValue() != null){
DateCreation = DatePickerCreation.getValue().toString();
}
// 0comptant 1facilité
String TypeRegement = "";
if(RadioComptant.isSelected()){
TypeRegement = "0";
}else if(RadioFacilite.isSelected()){
TypeRegement = "1";
}
ObservableList<CommandeCltListe> ListCommandes = new CommandeCltDB().SearchCommande(
position,
nbrligne,
TypeRegement,
TextFieldCodeCommande.getText(),
TextFieldCodeClient.getText(),
TextFieldNameClient.getText(),
TextFieldCodeDevis.getText(),
DateCreation);
TableViewGestionCommande.setItems(ListCommandes);
totalcount = new CommandeCltDB().nbrSearchCommande(TypeRegement, TextFieldCodeCommande.getText(), TextFieldCodeClient.getText(), TextFieldNameClient.getText(), TextFieldCodeDevis.getText(), DateCreation);
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;
}
};
}
};
ThreadSearchCommande.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarCommande.setVisible(false);
ButtonSearchCommande.setDisable(false);
LabelCount.setText(totalcount.toString());
}
});
ThreadSearchCommande.start();
}
private void NextLastSearchCommande(Integer ParmPosition, Integer ParamNbrligne)
{
ProgressBarCommande.setVisible(true);
ButtonSearchCommande.setDisable(true);
ThreadSearchCommande = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
String DateCreation = "";
if(DatePickerCreation.getValue() != null){
DateCreation = DatePickerCreation.getValue().toString();
}
// 0comptant 1facilité
String TypeRegement = "";
if(RadioComptant.isSelected()){
TypeRegement = "0";
}else if(RadioFacilite.isSelected()){
TypeRegement = "1";
}
ObservableList<CommandeCltListe> ListCommandes = new CommandeCltDB().SearchCommande(ParmPosition, ParamNbrligne, TypeRegement, TextFieldCodeCommande.getText(), TextFieldCodeClient.getText(), TextFieldNameClient.getText(), TextFieldCodeDevis.getText(), DateCreation);
TableViewGestionCommande.setItems(ListCommandes);
return null;
}
};
}
};
ThreadSearchCommande.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarCommande.setVisible(false);
ButtonSearchCommande.setDisable(false);
}
});
ThreadSearchCommande.start();
}
private void GestionSearchCommande()
{
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;
NextLastSearchCommande(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;
NextLastSearchCommande(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;
NextLastSearchCommande(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;
NextLastSearchCommande(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;
NextLastSearchCommande(position, nbrligne);
actuellepage=actuellepage-3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,911 @@
/*
* 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.DevisClt;
import Controllers.Client.ListeClient;
import Controllers.Client.ListeClientEntreprise;
import Controllers.Client.RechercherClientEntrepriseController;
import Controllers.Client.RechercherClientPersonneController;
import Controllers.Dialog.MessageControle;
import Models.Produit.ListeProduit;
import Controllers.Produit.RechercherProduitController;
import Controllers.Traitement.Adaptateur;
import Controllers.Traitement.MyWindow;
import Controllers.Traitement.ParametreSystem;
import Controllers.Traitement.contro;
import Models.Client.Client;
import Models.Client.ClientDB;
import Models.Client.ClientEntreprise;
import Models.Client.ClientEntrepriseDB;
import Models.DevisClt.Devis;
import Models.DevisClt.DevisDB;
import Models.Produit.Produit;
import Models.Produit.ProduitDB;
import java.io.IOException;
import java.net.URL;
import java.time.LocalDate;
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.ComboBox;
import javafx.scene.control.DatePicker;
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;
/**
* FXML Controller class
*
* @author PC-Maher
*/
public class DevisAjouterController implements Initializable {
@FXML private AnchorPane PaneDevisAjouter ;
@FXML private Text DevisTotalTVA ;
@FXML private Text DevisRemise ;
@FXML private Text DevisNetAPayer ;
@FXML private Text DevisTimbre ;
@FXML private Text DevisTotalHTNet ;
@FXML public Button EnregisterDevis ;
@FXML public Button ClientExisteDejat ;
@FXML public Button ClientDefault ;
@FXML public Button RechercheProduit ;
@FXML public TextField DevisNom ;
@FXML public TextField DevisPrenom ;
@FXML public TextField DevisAdresse ;
@FXML public TextField DevisTELE1 ;
@FXML public TextField DevisTELE2 ;
@FXML public Text TextMatricule ;
@FXML public Text TextPrenom;
@FXML public Text TextCltExistCode;
@FXML public Text CltExistCode;
@FXML public Text CltExistNom;
@FXML public Text CltExistPrenom;
@FXML public Text CltExistAdresse;
@FXML public Text CltExistTELE1;
@FXML public Text CltExistTELE2;
@FXML public DatePicker DateCreation ;
@FXML public DatePicker DateFinValidite ;
@FXML public ComboBox ModeReglement ;
@FXML public TableView<ListeProduit> TableViewListeProduitDevis ;
@FXML public TableColumn<ListeProduit ,String> TabColDevisReference;
@FXML public TableColumn<ListeProduit ,String> TabColDevisDesignaton;
@FXML public TableColumn<ListeProduit ,String> TabColDevisQuantite ;
@FXML public TableColumn<ListeProduit ,String> TabColDevisPrixHT;
@FXML public TableColumn<ListeProduit ,String> TabColDevisRemise;
@FXML public TableColumn<ListeProduit ,String> TabColDevisTotalHT;
@FXML public TableColumn<ListeProduit ,String> TabColDevisTVA;
@FXML public TableColumn<ListeProduit ,String> TabColDevisTotalTTC;
@FXML public TableColumn<ListeProduit ,Boolean> TabColDevisAddAction ;
public static Integer TypeClient ; // 0Personne 1Entreprise 2Passeger
public static String codeclient ;
public static String codecliententre;
public static Object Mode;
public static LocalDate FinValidite;
public static ObservableList<ListeProduit> data=FXCollections.observableArrayList();
Devis devis = new Devis();
Produit produit= new Produit();
ProduitDB produitDB= new ProduitDB();
public void SauvgardeTraitement(){
if(TypeClient != null){
if(TypeClient == 0){
this.SetClient(codeclient);
}
if(TypeClient == 1){
this.SetClientEntre(codecliententre);
}
}
}
@Override
public void initialize(URL url, ResourceBundle rb) {
this.SauvgardeTraitement();
DateCreation.setValue(LocalDate.now());
TableViewListeProduitDevis.setEditable(true);
TabColDevisReference.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("reference"));
TabColDevisDesignaton.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("designation"));
TabColDevisQuantite.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("quantite"));
TabColDevisQuantite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDevisQuantite.getStyleClass().add("Center");
TabColDevisPrixHT.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("PrixHT"));
TabColDevisPrixHT.setStyle( "-fx-alignment: CENTER;");
TabColDevisPrixHT.getStyleClass().add("Center");
TabColDevisRemise.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("Remise"));
TabColDevisRemise.setStyle( "-fx-alignment: CENTER;");
TabColDevisRemise.getStyleClass().add("Center");
TabColDevisTotalHT.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("TotalHT"));
TabColDevisTotalHT.setStyle( "-fx-alignment: CENTER;");
TabColDevisTotalHT.getStyleClass().add("Center");
TabColDevisTVA.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("TVA"));
TabColDevisTVA.setStyle( "-fx-alignment: CENTER;");
TabColDevisTVA.getStyleClass().add("Center");
TabColDevisTotalTTC.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("TotalTTC"));
TabColDevisTotalTTC.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDevisTotalTTC.getStyleClass().add("Center");
TabColDevisReference.setCellFactory(TextFieldTableCell.<ListeProduit>forTableColumn());
TabColDevisQuantite.setCellFactory(TextFieldTableCell.<ListeProduit>forTableColumn());
TabColDevisRemise.setCellFactory(TextFieldTableCell.<ListeProduit>forTableColumn());
this.ReferenceMouseClick();
this.QantiteMouseClick();
this.RemiseMouseClick();
TabColDevisAddAction.setSortable(true);
TabColDevisAddAction.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.
TabColDevisAddAction.setCellFactory(new Callback<TableColumn<ListeProduit, Boolean>, TableCell<ListeProduit, Boolean>>() {
@Override
public TableCell<ListeProduit, Boolean> call(TableColumn<ListeProduit, Boolean> personBooleanTableColumn) {
return new DevisAjouterController.ButtonCell();
}
});
TableViewListeProduitDevis.setItems(data);
CalculeListeProduit();
//Ajouter une ligne vide lorce ce que en click sur la tableview
TableViewListeProduitDevis.setOnMouseClicked(new EventHandler<javafx.scene.input.MouseEvent>(){
public void handle(MouseEvent event){
int nbrligne = TableViewListeProduitDevis.getItems().size() ;
if(nbrligne == 0){
data.add(new ListeProduit("","","","","","","",""));
TableViewListeProduitDevis.setItems(data);
}
else{
ListeProduit Liste = TableViewListeProduitDevis.getItems().get(nbrligne - 1);
if(!Liste.getTotalTTC().isEmpty()){
data.add(new ListeProduit("","","","","","","",""));
TableViewListeProduitDevis.setItems(data);
TableViewListeProduitDevis.getSelectionModel().select(nbrligne);
}
}
}
});
}
@FXML
private void SaveDevisButtonAction(ActionEvent event) throws IOException {
final DevisDialogConfirmationController DevisDialogConfirmation = new DevisDialogConfirmationController();
if(ControleDevis()){
this.SetDevis();
DevisDialogConfirmation.Getdevis(devis);
DevisDialogConfirmation.DevisEnregister.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
DevisDialogConfirmation.AnchorPrincipal.setVisible(false);
DevisDB devisdb = new DevisDB();
String codedevis = devisdb.AddDevis(devis);
if(!codedevis.isEmpty()){
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Devis/DevisDetail.fxml"));
Parent NodeDetail = (Parent)fxmlLoader.load();
DevisDetailController devisdetail = fxmlLoader.getController();
devisdetail.SowDetailDevis(codedevis);
PaneDevisAjouter.getChildren().add(NodeDetail);
} catch (IOException ex) {
Logger.getLogger(DevisAjouterController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
});
DevisDialogConfirmation.Show();
}
}
//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();
data.remove(selectdIndex);
CalculeListeProduit();
TableViewListeProduitDevis.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 = TableViewListeProduitDevis.getItems().size() ;
if(nbrligne == 0){
data.add(new ListeProduit("","","","","","","",""));
TableViewListeProduitDevis.setItems(data);
}
else{
ListeProduit Liste = TableViewListeProduitDevis.getItems().get(nbrligne - 1);
if(!Liste.getTotalTTC().isEmpty()){
data.add(new ListeProduit("","","","","","","",""));
TableViewListeProduitDevis.setItems(data);
TableViewListeProduitDevis.getSelectionModel().select(nbrligne);
}
}
}
private boolean ControleDevis(){
boolean resulta = false ;
if(data.size()<1){
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();
}
//DateFinValidite ModeReglement
else if(DateFinValidite.getValue()==null){
DateFinValidite.setStyle("-fx-border-color:#f20606;");
}
else if(ModeReglement.getValue()==null){
DateFinValidite.setStyle("-fx-border-color:#b5b5b5;");
ModeReglement.setStyle("-fx-border-color:#f20606;");
}
else if(TypeClient == 2){ // 0Personne 1Entreprise 2Passeger
ModeReglement.setStyle("-fx-border-color:transparent;");
contro clt =new contro();
if(DevisNom.getText().isEmpty()){
DevisNom.setStyle("-fx-border-color:#f20606;");
}
else if(DevisPrenom.getText().isEmpty()){
DevisNom.setStyle("-fx-border-color:transparent;");
DevisPrenom.setStyle("-fx-border-color:#f20606;");
}
else if(DevisAdresse.getText().isEmpty()){
DevisPrenom.setStyle("-fx-border-color:transparent;");
DevisAdresse.setStyle("-fx-border-color:#f20606;");
}
else if(clt.isNumericNotnull(DevisTELE1.getText())){
DevisAdresse.setStyle("-fx-border-color:transparent;");
DevisTELE1.setStyle("-fx-border-color:#f20606;");
}
else if(clt.isNumeric(DevisTELE2.getText())){
DevisTELE1.setStyle("-fx-border-color:transparent;");
DevisTELE2.setStyle("-fx-border-color:#f20606;");
}
else{
DevisTELE2.setStyle("-fx-border-color:transparent;");
DateFinValidite.setStyle("-fx-border-color:#b5b5b5;");
ModeReglement.setStyle("-fx-border-color:#b5b5b5;");
resulta = true ;
}
}
else{
DateFinValidite.setStyle("-fx-border-color:#b5b5b5;");
ModeReglement.setStyle("-fx-border-color:#b5b5b5;");
resulta = true ;
}
return resulta ;
}
private void SetDevis(){
devis.setDate(Adaptateur.NormalDateFormat(DateCreation.getValue()));
devis.setTypeClient(TypeClient);
devis.setTypeRegement(ModeReglement.getValue().toString());
devis.setValidite(Adaptateur.NormalDateFormat(DateFinValidite.getValue()));
devis.setNetAPayer(DevisNetAPayer.getText());
devis.setTotalTVA(DevisTotalTVA.getText());
devis.setTotalHorsTaxNet(DevisTotalHTNet.getText());
if(TypeClient == 0){
devis.setCodeClient(CltExistCode.getText());
devis.setNom(CltExistNom.getText());
devis.setPrenom(CltExistPrenom.getText());
devis.setAdresse(CltExistAdresse.getText());
devis.setTele1(CltExistTELE1.getText());
devis.setTele2(CltExistTELE2.getText());
}
else if(TypeClient == 1){
//TextCltExistCode CltExistCode CltExistNom CltExistPrenom
devis.setCodeClient(CltExistCode.getText());
devis.setNom(CltExistNom.getText());
devis.setMatricule(CltExistPrenom.getText());
devis.setAdresse(CltExistAdresse.getText());
devis.setTele1(CltExistTELE1.getText());
devis.setTele2(CltExistTELE2.getText());
}
else if(TypeClient == 2){
devis.setNom(DevisNom.getText());
devis.setPrenom(DevisPrenom.getText());
devis.setAdresse(DevisAdresse.getText());
devis.setTele1(DevisTELE1.getText());
devis.setTele2(DevisTELE2.getText());
}
//controle le cas ou on a une ligne vide a la fin de la liste
if(data.get(data.size()-1).getTotalTTC().isEmpty()){
data.remove(data.size()-1);
}
devis.setListeproduit(data);
}
//Methode qui pérmet de traite les recherche du client Personne
@FXML
private void ClientExisteDejatButtonAction(ActionEvent event) throws IOException {
final RechercherClientPersonneController RechercheClient = new RechercherClientPersonneController();
RechercheClient.Action.setCellFactory(new Callback<TableColumn<ListeClient, String>, TableCell<ListeClient, String>>() {
@Override
public TableCell<ListeClient, String> call(TableColumn<ListeClient, String> paramP) {
return new TableCell<ListeClient, 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 Item
ListeClient ClientPerson = ((ListeClient)getTableRow().getItem());
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Devis/DevisAjouter.fxml"));
Parent devis = (Parent) fxmlLoader.load();
//Traitement de Sauvgarde
DevisAjouterController.TypeClient = 0 ;
DevisAjouterController.codeclient = ClientPerson.getCode();
DevisAjouterController.FinValidite = DateFinValidite.getValue();
DevisAjouterController.Mode = ModeReglement.getValue();
DevisAjouterController devisajouter = fxmlLoader.getController();
devisajouter.SetClient(ClientPerson.getCode());
devisajouter.ModeReglement.setValue(DevisAjouterController.Mode);
devisajouter.DateFinValidite.setValue(DevisAjouterController.FinValidite);
//Refrechir le Panel
MyWindow mywindows = new MyWindow();
mywindows.Refresh(devis, 3);
} catch (IOException ex) {
Logger.getLogger(RechercherClientPersonneController.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);
}
}
};
}
});
//afficher la fenaitre
RechercheClient.ShowDialg();
final RechercherClientEntrepriseController RechercheClientEntre = new RechercherClientEntrepriseController();
RechercheClient.cltEntreprise.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
RechercheClient.AnchoreClientPerson.setVisible(false);
RechercheClientEntre.AnchoreClientEntre.setVisible(true);
RechercheClientEntre.Show();
}
});
//Action when the button is pressed
RechercheClientEntre.cltPer.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
RechercheClientEntre.AnchoreClientEntre.setVisible(false);
RechercheClient.AnchoreClientPerson.setVisible(true);
RechercheClient.ShowDialg();
}
});
RechercheClientEntre.TableColumnActionEtre.setCellFactory(new Callback<TableColumn<ListeClientEntreprise, String>, TableCell<ListeClientEntreprise, String>>() {
@Override
public TableCell<ListeClientEntreprise, String> call(TableColumn<ListeClientEntreprise, String> paramP) {
return new TableCell<ListeClientEntreprise, 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 Item
ListeClientEntreprise currentPerson = ((ListeClientEntreprise)getTableRow().getItem());
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Devis/DevisAjouter.fxml"));
Parent devis = (Parent) fxmlLoader.load();
//Traitement de Sauvgarde
DevisAjouterController.TypeClient = 1 ;
DevisAjouterController.codecliententre = currentPerson.getCode();
DevisAjouterController.FinValidite = DateFinValidite.getValue();
DevisAjouterController.Mode = ModeReglement.getValue();
DevisAjouterController devisajouter = fxmlLoader.getController();
devisajouter.SetClientEntre(currentPerson.getCode());
devisajouter.ModeReglement.setValue(DevisAjouterController.Mode);
devisajouter.DateFinValidite.setValue(DevisAjouterController.FinValidite);
//Refrechir le Panel
MyWindow mywindows = new MyWindow();
mywindows.Refresh(devis, 3);
} catch (IOException ex) {
Logger.getLogger(RechercherClientEntrepriseController.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);
}
}
};
}
});
}
private void QantiteMouseClick(){
TabColDevisQuantite.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
TableViewListeProduitDevis.getColumns().get(t.getTablePosition().getRow()).setVisible(false);
TableViewListeProduitDevis.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(){
TabColDevisRemise.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
TableViewListeProduitDevis.getColumns().get(t.getTablePosition().getRow()).setVisible(false);
TableViewListeProduitDevis.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 ReferenceMouseClick(){
TabColDevisReference.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.getPrixventeht(),"0","",produit.getTvavente(),"0");
AffectationTableView(Liste,t.getTablePosition().getRow()) ;
}
else{
AffectationTableView(new ListeProduit("","","","","","","",""),t.getTablePosition().getRow()) ;
}
}
});
}
@FXML
private void RechercheProduitButtonAction(ActionEvent event) throws IOException {
double PrefWidthPaneDevis = PaneDevisAjouter.getPrefWidth();
double PrefHeightPaneDevis = PaneDevisAjouter.getPrefHeight();
System.out.println(PaneDevisAjouter.getPrefWidth());
System.out.println(PaneDevisAjouter.getPrefHeight());
final RechercherProduitController rechercheproduit = new RechercherProduitController(true);
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 {
DevisAjouterController.FinValidite = DateFinValidite.getValue();
DevisAjouterController.Mode = ModeReglement.getValue();
// get Selected ItemButtonCell
Produit currentPerson = ((Produit)getTableRow().getItem());
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Devis/DevisAjouter.fxml"));
Parent devis = (Parent) fxmlLoader.load();
DevisAjouterController devisajouter = fxmlLoader.getController();
devisajouter.SetProduit(currentPerson.getReference());
devisajouter.ModeReglement.setValue(DevisAjouterController.Mode);
devisajouter.DateFinValidite.setValue(DevisAjouterController.FinValidite);
devisajouter.PaneDevisAjouter.setPrefSize(PrefWidthPaneDevis, PrefHeightPaneDevis);
MyWindow mywindows = new MyWindow();
mywindows.Refresh(devis, 3);
} catch (IOException ex) {
Logger.getLogger(DevisAjouterController.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);
}
}
};
}
});
}
private void AffectationTableView(ListeProduit ListeProd, int EmplacementLigne){
boolean result = false ;
int indise=0;
int Position = 0;
if(data.size()>0){
do{ //Vérifier si le produit exsiste deja
if(data.get(indise).getReference().equals(ListeProd.getReference())){
result = true ;
Position = indise ;
//System.out.println("existe Position:"+indise);
}
indise++;
}while(data.size()>indise && !result);
if(result){ //si la ligne exsite déja
if(EmplacementLigne!= -1){
if(Position == EmplacementLigne){
data.set(Position, ListeProd);
}
else{
data.set(EmplacementLigne, new ListeProduit("","","","","","","",""));
}
}
}
else{
if(EmplacementLigne!= -1){
data.set(EmplacementLigne, ListeProd);
}
else{
data.add(ListeProd);
}
}
}
else{
data.add(ListeProd);
}
CalculeListeProduit();
TableViewListeProduitDevis.setItems(data);
TableViewListeProduitDevis.setVisible(false);
TableViewListeProduitDevis.setVisible(true);
}
private void CalculeListeProduit(){ //calculer et afficher la détail des produits
float NetaPayer = 0;
float Remise = 0;
float TotalTVA = 0;
float Total_H_T_Net= 0;
DevisTotalTVA.setText("");
DevisRemise.setText("");
DevisNetAPayer.setText("");
DevisTimbre.setText("");
DevisTotalHTNet.setText("");
//calcule
for(ListeProduit liste : data){
float totaht = Adaptateur.StringToFloat(liste.getTotalHT()) ;
float prix_U_H_T = Adaptateur.StringToFloat(liste.getPrixHT()) ;
float remise = Adaptateur.StringToFloat(liste.getRemise().replace("%", "")) ;
float tva = Adaptateur.StringToFloat(liste.getTVA().replace("%", ""));
float qte = Adaptateur.StringToFloat(liste.getQuantite());
TotalTVA = TotalTVA + ((totaht * tva) /100) ;
Remise = Remise + (prix_U_H_T * remise)/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 ;
DevisTotalTVA.setText(Adaptateur.ArrondFloatToString(TotalTVA));
DevisRemise.setText(Adaptateur.ArrondFloatToString(Remise));
devis.setRemise(Adaptateur.ArrondFloatToString(Remise));
DevisNetAPayer.setText(Adaptateur.ArrondFloatToString(NetaPayer));
DevisTimbre.setText(ParametreSystem.Timbre);
DevisTotalHTNet.setText(Adaptateur.ArrondFloatToString(Total_H_T_Net));
}
}
@FXML
private void ClientRessetDefautButtonAction(ActionEvent event) throws IOException {
DevisAjouterController.TypeClient = 2 ;
ClientExisteDejat.setVisible(true);
DevisNom.setVisible(true);
DevisPrenom.setVisible(true);
DevisAdresse.setVisible(true);
DevisTELE1.setVisible(true);
DevisTELE2.setVisible(true);
TextCltExistCode.setVisible(false);
ClientDefault.setVisible(false);
CltExistCode.setVisible(false);
CltExistNom.setVisible(false);
CltExistPrenom.setVisible(false);
CltExistAdresse.setVisible(false);
CltExistTELE1.setVisible(false);
CltExistTELE2.setVisible(false);
}
public void SetClient(String codeclt){
Client client = new Client();
ClientDB clientdb = new ClientDB();
DevisAjouterController.TypeClient = 0 ;
client = clientdb.getClient(codeclt);
ClientExisteDejat.setVisible(false);
DevisNom.setVisible(false);
DevisPrenom.setVisible(false);
DevisAdresse.setVisible(false);
DevisTELE1.setVisible(false);
DevisTELE2.setVisible(false);
CltExistCode.setText(client.getCodeclient().toString());
CltExistNom.setText(client.getNom());
CltExistPrenom.setText(client.getPrenom());
CltExistAdresse.setText(client.getAdresse());
CltExistTELE1.setText(client.getTelefix().toString());
CltExistTELE2.setText(client.getTelemobileString());
TextCltExistCode.setVisible(true);
ClientDefault.setVisible(true);
CltExistCode.setVisible(true);
CltExistNom.setVisible(true);
CltExistPrenom.setVisible(true);
CltExistAdresse.setVisible(true);
CltExistTELE1.setVisible(true);
CltExistTELE2.setVisible(true);
}
public void SetProduit(String Refprod){
produit = produitDB.getProduit(Refprod);
ListeProduit ListeProd = new ListeProduit(produit.getReference(),produit.getDesignation(),"1",produit.getPrixventeht(),"0",produit.getPrixventettc(),produit.getTvavente(),"0");
//Supprimer les igne vide
if((data.size()>0) && (data.get(data.size()-1).getReference().isEmpty())){
data.remove(data.size()-1);
}
AffectationTableView(ListeProd,-1);
}
public void SetClientEntre(String codecliententre){
ClientEntreprise ClientEtr = new ClientEntreprise();
ClientEntrepriseDB ClientEtrDB = new ClientEntrepriseDB();
ClientEtr = ClientEtrDB.GetClientEtr(codecliententre);
DevisAjouterController.TypeClient = 1 ;
TextMatricule.setVisible(true);
TextPrenom.setVisible(false);
ClientExisteDejat.setVisible(false);
DevisNom.setVisible(false);
DevisPrenom.setVisible(false);
DevisAdresse.setVisible(false);
DevisTELE1.setVisible(false);
DevisTELE2.setVisible(false);
CltExistCode.setText(ClientEtr.getCode().toString());
CltExistNom.setText(ClientEtr.getNom());
CltExistPrenom.setText(ClientEtr.getMatricule());
CltExistAdresse.setText(ClientEtr.getAdresse());
CltExistTELE1.setText(ClientEtr.getTele1().toString());
CltExistTELE2.setText(ClientEtr.getTele2().toString());
TextCltExistCode.setVisible(true);
ClientDefault.setVisible(true);
CltExistCode.setVisible(true);
CltExistNom.setVisible(true);
CltExistPrenom.setVisible(true);
CltExistAdresse.setVisible(true);
CltExistTELE1.setVisible(true);
CltExistTELE2.setVisible(true);
}
}
@@ -0,0 +1,425 @@
package Controllers.DevisClt;
import Models.DevisClt.DevisCltListe;
import Models.DevisClt.DevisDB;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
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.RadioButton;
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.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.util.Callback;
/**
* FXML Controller class
* @author PC-Maher
*/
public class DevisCltGestionController implements Initializable {
@FXML private AnchorPane PaneDevisGestion ;
@FXML private ProgressBar ProgressBarDevisClt;
@FXML private Button ButtonSearchDevisClt;
@FXML private AnchorPane ListerPages;
@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 ;
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;
@FXML public TableView<DevisCltListe> TableViewGestionDevis;
@FXML public TableColumn<DevisCltListe ,String> TabColCodeDevis;
@FXML public TableColumn<DevisCltListe ,String> TabColModePaiement;
@FXML public TableColumn<DevisCltListe ,String> TabColTypeClient;
@FXML public TableColumn<DevisCltListe ,String> TabColCodeClient;
@FXML public TableColumn<DevisCltListe ,String> TabColTotalDevis;
@FXML public TableColumn<DevisCltListe ,String> TabColDateCreation ;
@FXML public TableColumn<DevisCltListe ,String> TabColDateFinValidite;
@FXML public TableColumn<DevisCltListe ,Boolean>TabColDetail ;
@FXML public TextField TextFieldCodeDevis ;
@FXML public TextField TextFieldCodeClient ;
@FXML public TextField TextFieldNomPrenomClient ;
@FXML public TextField TextFieldCinClient;
@FXML public DatePicker DatePickerCreation ;
@FXML public RadioButton RadioComptant;
@FXML public RadioButton RadioFacilite;
private Service<Void> ThreadSearchDevisClt;
@FXML
private void AddDevisButtonAction(ActionEvent event) throws IOException {
//inisialiser les données de Sauvgarde des opération
DevisAjouterController.TypeClient = 2 ;
DevisAjouterController.codeclient = null ;
DevisAjouterController.codecliententre = null ;
DevisAjouterController.data.clear();
DevisAjouterController.FinValidite = null;
DevisAjouterController.Mode = null;
PaneDevisGestion.getChildren().clear();
PaneDevisGestion.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Devis/DevisAjouter.fxml")));
}
@Override
public void initialize(URL url, ResourceBundle rb) {
//comboboxnombre des lignes tableview
NbrLigne.setItems(cursors);
NbrLigne.getSelectionModel().selectFirst();
TableViewGestionDevis.setEditable(true);
TabColCodeDevis.setStyle( "-fx-alignment: CENTER;");TabColCodeDevis.getStyleClass().add("Center");
TabColCodeDevis.setCellValueFactory(new PropertyValueFactory<DevisCltListe, String>("CodeDevis"));
TabColTypeClient.setStyle( "-fx-alignment: CENTER;");TabColTypeClient.getStyleClass().add("Center");
TabColTypeClient.setCellValueFactory(new PropertyValueFactory<DevisCltListe, String>("TypeClient"));
TabColCodeClient.setStyle( "-fx-alignment: CENTER;");TabColCodeClient.getStyleClass().add("Center");
TabColCodeClient.setCellValueFactory(new PropertyValueFactory<DevisCltListe, String>("CodeClient"));
TabColModePaiement.setStyle( "-fx-alignment: CENTER;");TabColModePaiement.getStyleClass().add("Center");
TabColModePaiement.setCellValueFactory(new PropertyValueFactory<DevisCltListe, String>("ModePaiement"));
TabColTotalDevis.setStyle( "-fx-alignment: CENTER;");TabColTotalDevis.getStyleClass().add("Center");
TabColTotalDevis.setCellValueFactory(new PropertyValueFactory<DevisCltListe, String>("TotalDevis"));
TabColDateCreation.setStyle( "-fx-alignment: CENTER;");TabColDateCreation.getStyleClass().add("Center");
TabColDateCreation.setCellValueFactory(new PropertyValueFactory<DevisCltListe, String>("DateCreation"));
TabColDateFinValidite.setStyle( "-fx-alignment: CENTER;");TabColDateFinValidite.getStyleClass().add("Center");
TabColDateFinValidite.setCellValueFactory(new PropertyValueFactory<DevisCltListe, String>("FinValidite"));
TabColDetail.setSortable(true);
TabColDetail.setStyle( "-fx-alignment: CENTER;");TabColDetail.getStyleClass().add("Center");
TabColDetail.setCellFactory(new Callback<TableColumn<DevisCltListe, Boolean>, TableCell<DevisCltListe, Boolean>>() {
@Override
public TableCell<DevisCltListe, Boolean> call(TableColumn<DevisCltListe, Boolean> personBooleanTableColumn) {
return new ButtonCell();
}
});
ButtonSearchDevisClt.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchDevisClt();
}
});
PaneDevisGestion.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchDevisClt();
}
}
});
GestionSearchDevisClt();
}
//Define the button cell
private class ButtonCell extends TableCell<DevisCltListe, Boolean> {
final Button cellButton = new Button();
ButtonCell(){
cellButton.getStyleClass().add("btn-icon-primary");
Image coffeeImage = new Image(getClass().getResourceAsStream("/Public/icon/iconedit.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) {
// get Selected Item
DevisCltListe current = (DevisCltListe) ButtonCell.this.getTableView().getItems().get(ButtonCell.this.getIndex());
String codedevis = current.getCodeDevis();
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Devis/DevisDetail.fxml"));
Parent NodeDetail = (Parent)fxmlLoader.load();
DevisDetailController devisdetail = fxmlLoader.getController();
devisdetail.AnchorPaneSucces.setVisible(false);
devisdetail.TextSucces.setText("Information Devis");
devisdetail.TextSucces.setLayoutX(30);
devisdetail.TextSucces.setFont(Font.font("Arial", FontWeight.NORMAL, 21));
devisdetail.TextDescSucces.setVisible(false);
devisdetail.SowDetailDevis(codedevis);
PaneDevisGestion.getChildren().add(NodeDetail);
} catch (IOException ex) {
Logger.getLogger(DevisCltGestionController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
//Display button if the row is not empty
@Override
protected void updateItem(Boolean t, boolean empty) {
if(!empty){
setGraphic(cellButton);
} else {
setGraphic(null);
}
}
}
/****************************************************************************** *
* *
* Methode last Next TableView client Entreprise *
* * *
******************************************************************************/
private void SearchDevisClt()
{
ProgressBarDevisClt.setVisible(true);
ButtonSearchDevisClt.setDisable(true);
ThreadSearchDevisClt = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
position = 0;
actuellepage = 1;
String DateCreation = "";
if(DatePickerCreation.getValue() != null){
DateCreation = DatePickerCreation.getValue().toString();
}
// 0comptant 1facilité
String TypeRegement = "";
if(RadioComptant.isSelected()){
TypeRegement = "0";
}else if(RadioFacilite.isSelected()){
TypeRegement = "1";
}
ObservableList<DevisCltListe> ListDevisClts = new DevisDB().SearchDevisCltGestion(
position,
nbrligne,
TextFieldCodeDevis.getText(),
TextFieldCodeClient.getText(),
TypeRegement,
DateCreation,
TextFieldNomPrenomClient.getText(),
TextFieldCinClient.getText());
TableViewGestionDevis.setItems(ListDevisClts);
totalcount = new DevisDB().nbrDevisCltGestion(TextFieldCodeDevis.getText(), TextFieldCodeClient.getText(), TypeRegement, DateCreation, TextFieldNomPrenomClient.getText(), TextFieldCinClient.getText());
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;
}
};
}
};
ThreadSearchDevisClt.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarDevisClt.setVisible(false);
ButtonSearchDevisClt.setDisable(false);
LabelCount.setText(totalcount.toString());
}
});
ThreadSearchDevisClt.start();
}
private void NextLastSearchDevisClt(Integer ParmPosition, Integer ParamNbrligne)
{
ProgressBarDevisClt.setVisible(true);
ButtonSearchDevisClt.setDisable(true);
ThreadSearchDevisClt = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
String DateCreation = "";
if(DatePickerCreation.getValue() != null){
DateCreation = DatePickerCreation.getValue().toString();
}
// 0comptant 1facilité
String TypeRegement = "";
if(RadioComptant.isSelected()){
TypeRegement = "0";
}else if(RadioFacilite.isSelected()){
TypeRegement = "1";
}
ObservableList<DevisCltListe> ListDevisClts = new DevisDB().SearchDevisCltGestion(ParmPosition, ParamNbrligne, TextFieldCodeDevis.getText(), TextFieldCodeClient.getText(), TypeRegement, DateCreation, TextFieldNomPrenomClient.getText(), TextFieldCinClient.getText());
TableViewGestionDevis.setItems(ListDevisClts);
return null;
}
};
}
};
ThreadSearchDevisClt.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarDevisClt.setVisible(false);
ButtonSearchDevisClt.setDisable(false);
}
});
ThreadSearchDevisClt.start();
}
private void GestionSearchDevisClt()
{
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;
NextLastSearchDevisClt(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;
NextLastSearchDevisClt(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;
NextLastSearchDevisClt(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;
NextLastSearchDevisClt(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;
NextLastSearchDevisClt(position, nbrligne);
actuellepage=actuellepage-3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
}
}
@@ -0,0 +1,240 @@
package Controllers.DevisClt;
import Controllers.Traitement.Adaptateur;
import Controllers.Traitement.ParametreSystem;
import Models.DevisClt.Devis;
import Models.Produit.ListeProduit;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Control;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.text.Text;
import javafx.util.Callback;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class DevisCltPrintController implements Initializable {
@FXML public ImageView ImageViewLogo;
@FXML private Text TextSteNom1;
@FXML private Text TextReference;
@FXML private Text TextDate;
@FXML private Text TextEcheance;
@FXML private Text TextClient;
@FXML private Text TextNumDevie;
@FXML private Text TextTotalHT;
@FXML private Text TextTVA;
@FXML private Text TextTotalTTC;
@FXML private Text TextSteNom2;
@FXML private Text TextSteContact;
@FXML private Text TextSteSIREN;
@FXML private TableView<ListProdDevis> TableViewProdDevis ;
@FXML private TableColumn<ListProdDevis ,String> TabColDevisReference;
@FXML private TableColumn<ListProdDevis ,String> TabColDevisDesignation;
@FXML private TableColumn<ListProdDevis ,String> TabColDevisQuantite ;
@FXML private TableColumn<ListProdDevis ,String> TabColDevisPrix;
@FXML private TableColumn<ListProdDevis ,String> TabColDevisMontant;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
setImageLogo();
TabColDevisReference.setCellValueFactory(new PropertyValueFactory<ListProdDevis, String>("Reference"));
TabColDevisDesignation.setCellValueFactory(new PropertyValueFactory<ListProdDevis, String>("Description"));
TabColDevisDesignation.setCellFactory(new Callback<TableColumn<ListProdDevis, String>,TableCell<ListProdDevis, String>>(){
@Override
public TableCell<ListProdDevis, String> call(TableColumn<ListProdDevis, String> param) {
TableCell<ListProdDevis, String> cell = new TableCell<ListProdDevis, String>(){
@Override
public void updateItem(String item, boolean empty) {
if (item == null) {
super.setText(null);
super.setGraphic(null);
} else {
String newItem = item.trim().toLowerCase();
Text text = new Text(newItem);
super.setPrefHeight(Control.USE_COMPUTED_SIZE);
text.wrappingWidthProperty().bind(super.widthProperty());
super.setGraphic(text);
}
}
};
return cell;
}
});
TabColDevisQuantite.setCellValueFactory(new PropertyValueFactory<ListProdDevis, String>("Quantite"));
TabColDevisQuantite.setStyle( "-fx-alignment: CENTER;");
TabColDevisQuantite.getStyleClass().add("Center");
TabColDevisPrix.setCellValueFactory(new PropertyValueFactory<ListProdDevis, String>("Prix"));
TabColDevisPrix.setStyle( "-fx-alignment: CENTER;");
TabColDevisPrix.getStyleClass().add("Center");
TabColDevisMontant.setCellValueFactory(new PropertyValueFactory<ListProdDevis, String>("Montant"));
TabColDevisMontant.setStyle( "-fx-alignment: CENTER;");
TabColDevisMontant.getStyleClass().add("Center");
TextSteNom1.setText(ParametreSystem.CompanyName);
TextSteNom2.setText("Ste:"+ParametreSystem.CompanyName+" | Adress:"+ParametreSystem.CompanyAddress+" | Tele: "+ParametreSystem.CompanyTele);
TextSteContact.setText("Fax:"+ParametreSystem.CompanyFax+" | Mail:"+ParametreSystem.CompanyMail+" | Site:"+ParametreSystem.CompanySite);
TextSteSIREN.setText(ParametreSystem.CompanySIREN);
}
public void SetDevis(Devis devis)
{
TextReference.setText(devis.getCodeDevis());
TextDate.setText(Adaptateur.NormalDateFormat(devis.getDate()));
TextEcheance.setText(devis.getValidite());
TextClient.setText(devis.getCodeClient()+" - "+devis.getNom()+" - "+devis.getPrenom());
TextNumDevie.setText(devis.getCodeDevis());
ObservableList<ListProdDevis> PodDevis = FXCollections.observableArrayList();
for(ListeProduit liste : devis.getListeproduit()){
if(!liste.getReference().equals("")){
float remise = Adaptateur.ArrondStringToFloat(liste.getRemise().replace("%", "")) ;
float prixht = Adaptateur.ArrondStringToFloat(liste.getPrixHT()) ;
float tva = Adaptateur.StringToFloat(liste.getTVA().replace("%", "")) ;
float qte = Adaptateur.StringToFloat(liste.getQuantite()) ;
float totalht = (prixht - ((prixht * remise)/100)) ;
float prixttc = totalht + ((totalht * tva)/100) ;
float montant = prixttc * qte;
PodDevis.add(new ListProdDevis(liste.getReference(), liste.getDesignation(), liste.getQuantite(), Adaptateur.FloatToStringEspace(prixttc), Adaptateur.FloatToStringEspace(montant)));
}
}
TextTVA.setText(Adaptateur.StringToStringEspaceCurrency(devis.getTotalTVA()));
TextTotalHT.setText(Adaptateur.StringToStringEspaceCurrency(devis.getTotalHorsTaxNet()));
TextTotalTTC.setText(Adaptateur.StringToStringEspaceCurrency(devis.getNetAPayer()));
TableViewProdDevis.setItems(PodDevis);
}
private void setImageLogo()
{
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
// optional, but recommended
// process XML securely, avoid attacks like XML External Entities (XXE)
dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
// parse XML file
DocumentBuilder db = dbf.newDocumentBuilder();
//PowerERP\conf\logo.xml
Document doc = db.parse(new File("./conf/logo.xml"));
doc.getDocumentElement().normalize();
Element elementCNX = (Element) doc.getElementsByTagName("DevisCltPrint").item(0);
String pathLogo = elementCNX.getElementsByTagName("PathImage").item(0).getTextContent();
FileInputStream fis = new FileInputStream(pathLogo);
ImageViewLogo.setImage(new Image(fis));
ImageViewLogo.setFitWidth(Double.parseDouble(elementCNX.getElementsByTagName("FitWidth").item(0).getTextContent()));
ImageViewLogo.setFitHeight(Double.parseDouble(elementCNX.getElementsByTagName("FitHeight").item(0).getTextContent()));
ImageViewLogo.setLayoutX(Double.parseDouble(elementCNX.getElementsByTagName("LayoutX").item(0).getTextContent()));
ImageViewLogo.setLayoutY(Double.parseDouble(elementCNX.getElementsByTagName("LayoutY").item(0).getTextContent()));
}
catch (ParserConfigurationException | SAXException | IOException e) {
System.out.println("error AuthentificationController/setImageLogo "+e.getMessage());
}
}
public static class ListProdDevis {
private final SimpleStringProperty Reference;
private final SimpleStringProperty Description;
private final SimpleStringProperty Quantite;
private final SimpleStringProperty Prix;
private final SimpleStringProperty Montant;
private ListProdDevis(String reference, String description, String quantite, String prix, String montant) {
this.Reference = new SimpleStringProperty(reference);
this.Description = new SimpleStringProperty(description);
this.Quantite = new SimpleStringProperty(quantite);
this.Prix = new SimpleStringProperty(prix);
this.Montant = new SimpleStringProperty(montant);
}
public String getReference() {
return Reference.get();
}
public void setReference(String reference) {
Reference.set(reference);
}
public String getDescription() {
return Description.get();
}
public void setDescription(String description) {
Description.set(description);
}
public String getQuantite() {
return Quantite.get();
}
public void setQuantite(String quantite) {
Quantite.set(quantite);
}
public String getPrix() {
return Prix.get();
}
public void setPrix(String prix) {
Prix.set(prix);
}
public String getMontant() {
return Montant.get();
}
public void setMontant(String montant) {
Montant.set(montant);
}
}
}
@@ -0,0 +1,174 @@
package Controllers.DevisClt;
import Models.Produit.ListeProduit;
import Controllers.Traitement.Adaptateur;
import Models.DevisClt.Devis;
import Models.DevisClt.DevisDB;
import Models.Fournisseur.FournisseurDB;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
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.print.PageRange;
import javafx.print.PrinterJob;
import javafx.scene.Node;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Text;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class DevisDetailController implements Initializable {
@FXML public AnchorPane AnchorPaneSucces;
@FXML public AnchorPane AnchorPaneDevisDetail;
@FXML public AnchorPane AnchorPaneLoadingDevisDetail;
@FXML public Text TextSucces;
@FXML public Text TextDescSucces;
@FXML private Text DevisDateCreation;
@FXML private Text DevisFinValidite;
@FXML private Text DevisReglement;
@FXML private Text DevisNetAPayer;
@FXML private Text DevisTotalHorsTaxNet;
@FXML private Text DevisCode;
@FXML private Text DevisTypeClt;
@FXML private Text DevisNom;
@FXML private Text DevisPrenom;
@FXML private Text DevisAdresse;
@FXML private Text DevisTELE1;
@FXML private Text DevisTELE2;
@FXML private Text DevisTextPrenom ;
@FXML private Text DevisTextMatricule ;
@FXML private TableView<ListeProduit> TableViewListeProduitDevis ;
@FXML private TableColumn<ListeProduit ,String> TabColDevisReference;
@FXML private TableColumn<ListeProduit ,String> TabColDevisDesignaton;
@FXML private TableColumn<ListeProduit ,String> TabColDevisQuantite ;
@FXML private TableColumn<ListeProduit ,String> TabColDevisPrixHT;
@FXML private TableColumn<ListeProduit ,String> TabColDevisRemise;
@FXML private TableColumn<ListeProduit ,String> TabColDevisTotalHT;
@FXML private TableColumn<ListeProduit ,String> TabColDevisTVA;
@FXML private TableColumn<ListeProduit ,String> TabColDevisTotalTTC;
Devis devis = new Devis();
private Service<Void> ThreadDevisDetail;
@Override
public void initialize(URL url, ResourceBundle rb) {
TabColDevisReference.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("reference"));
TabColDevisDesignaton.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("designation"));
TabColDevisQuantite.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("quantite"));
TabColDevisQuantite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDevisQuantite.getStyleClass().add("Center");
TabColDevisPrixHT.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("PrixHT"));
TabColDevisPrixHT.setStyle( "-fx-alignment: CENTER;");
TabColDevisPrixHT.getStyleClass().add("Center");
TabColDevisRemise.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("Remise"));
TabColDevisRemise.setStyle( "-fx-alignment: CENTER;");
TabColDevisRemise.getStyleClass().add("Center");
TabColDevisTotalHT.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("TotalHT"));
TabColDevisTotalHT.setStyle( "-fx-alignment: CENTER;");
TabColDevisTotalHT.getStyleClass().add("Center");
TabColDevisTVA.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("TVA"));
TabColDevisTVA.setStyle( "-fx-alignment: CENTER;");
TabColDevisTVA.getStyleClass().add("Center");
TabColDevisTotalTTC.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("TotalTTC"));
TabColDevisTotalTTC.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDevisTotalTTC.getStyleClass().add("Center");
}
public void SowDetailDevis(String codedevis)
{
ThreadDevisDetail = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
devis = new DevisDB().getDevis(codedevis);
return null;
}
};
}
};
ThreadDevisDetail.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
DevisDateCreation.setText(Adaptateur.NormalDateFormat(devis.getDate()));
DevisFinValidite.setText(devis.getValidite());
DevisReglement.setText(devis.getTypeRegementString());
DevisTotalHorsTaxNet.setText(Adaptateur.StringToStringEspace(devis.getTotalHorsTaxNet()));
DevisCode.setText(codedevis);
DevisTypeClt.setText(devis.getTypeClientString());
DevisNom.setText(devis.getNom());
if(devis.getTypeClient()==0 || devis.getTypeClient()==2){
DevisTextPrenom.setVisible(true);
DevisTextMatricule.setVisible(false);
DevisPrenom.setText(devis.getPrenom());
}
if(devis.getTypeClient()==1){
DevisTextPrenom.setVisible(false);
DevisTextMatricule.setVisible(true);
DevisPrenom.setText(devis.getMatricule());
}
DevisAdresse.setText(devis.getAdresse());
DevisTELE1.setText(devis.getTele1());
DevisTELE2.setText(devis.getTele2());
DevisNetAPayer.setText(Adaptateur.StringToStringEspaceCurrency(devis.getNetAPayer()));
TableViewListeProduitDevis.setItems(devis.getListeproduit());
AnchorPaneDevisDetail.setVisible(true);
AnchorPaneLoadingDevisDetail.setVisible(false);
}
});
ThreadDevisDetail.start();
}
@FXML
private void DevisPrintButtonAction(ActionEvent event) throws IOException {
PrinterJob jobPrint = PrinterJob.createPrinterJob();
jobPrint.getJobSettings().setPageRanges(new PageRange(1, 1));
if (jobPrint.showPrintDialog(null)) {
FXMLLoader fxmlLoaderPrintDevis = new FXMLLoader(getClass().getResource("/Views/Devis/DevisCltPrint.fxml"));
final Node ParentFxmlPrintDevis = (Node)fxmlLoaderPrintDevis.load();
DevisCltPrintController PrintDevis = fxmlLoaderPrintDevis.getController();
PrintDevis.SetDevis(devis);
jobPrint.printPage(ParentFxmlPrintDevis);
jobPrint.endJob();
}
}
}
@@ -0,0 +1,167 @@
/*
* 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.DevisClt;
import Models.Produit.ListeProduit;
import Controllers.Traitement.MyWindow;
import Models.DevisClt.Devis;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;
/**
* FXML Controller class
*
* @author PC-Maher
*/
public class DevisDialogConfirmationController implements Initializable {
/**
* Initializes the controller class.
*/
public Node nodeFxml ;
@FXML public AnchorPane AnchorPrincipal ;
@FXML public Button DevisEnregister ;
@FXML private Text DevisDateCreation;
@FXML private Text DevisFinValidite;
@FXML private Text DevisReglement;
@FXML private Text DevisNetAPayer;
@FXML private Text DevisTotalHorsTaxNet;
@FXML private Text DevisTotalTVA;
@FXML private Text DevisTypeClt;
@FXML private Text DevisNom;
@FXML private Text DevisPrenom;
@FXML private Text DevisAdresse;
@FXML private Text DevisTELE1;
@FXML private Text DevisTELE2;
@FXML private Text DevisTextPrenom ;
@FXML private Text DevisTextMatricule ;
@FXML public TableView<ListeProduit> TableViewListeProduitDevis ;
@FXML public TableColumn<ListeProduit ,String> TabColDevisReference;
@FXML public TableColumn<ListeProduit ,String> TabColDevisDesignaton;
@FXML public TableColumn<ListeProduit ,String> TabColDevisQuantite ;
@FXML public TableColumn<ListeProduit ,String> TabColDevisPrixHT;
@FXML public TableColumn<ListeProduit ,String> TabColDevisRemise;
@FXML public TableColumn<ListeProduit ,String> TabColDevisTotalHT;
@FXML public TableColumn<ListeProduit ,String> TabColDevisTVA;
@FXML public TableColumn<ListeProduit ,String> TabColDevisTotalTTC;
@Override
public void initialize(URL url, ResourceBundle rb) {
TabColDevisReference.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("reference"));
TabColDevisDesignaton.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("designation"));
TabColDevisQuantite.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("quantite"));
TabColDevisQuantite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDevisQuantite.getStyleClass().add("Center");
TabColDevisPrixHT.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("PrixHT"));
TabColDevisPrixHT.setStyle( "-fx-alignment: CENTER;");
TabColDevisPrixHT.getStyleClass().add("Center");
TabColDevisRemise.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("Remise"));
TabColDevisRemise.setStyle( "-fx-alignment: CENTER;");
TabColDevisRemise.getStyleClass().add("Center");
TabColDevisTotalHT.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("TotalHT"));
TabColDevisTotalHT.setStyle( "-fx-alignment: CENTER;");
TabColDevisTotalHT.getStyleClass().add("Center");
TabColDevisTVA.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("TVA"));
TabColDevisTVA.setStyle( "-fx-alignment: CENTER;");
TabColDevisTVA.getStyleClass().add("Center");
TabColDevisTotalTTC.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("TotalTTC"));
TabColDevisTotalTTC.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDevisTotalTTC.getStyleClass().add("Center");
Image coffeeImage = new Image(getClass().getResourceAsStream("/Public/icon/iconsave.png"));
ImageView buttonGraphic = new ImageView();
buttonGraphic.setImage(coffeeImage);
DevisEnregister.setGraphic(buttonGraphic);
}
public void Getdevis(Devis devis){
DevisDateCreation.setText(devis.getDate());
DevisFinValidite.setText(devis.getValidite());
DevisReglement.setText(devis.getTypeRegement());
DevisNetAPayer.setText(devis.getNetAPayer());
DevisTotalHorsTaxNet.setText(devis.getTotalHorsTaxNet());
DevisTotalTVA.setText(devis.getTotalTVA());
DevisTypeClt.setText(devis.getTypeClientString());
DevisNom.setText(devis.getNom());
DevisPrenom.setText(devis.getPrenom());
if(DevisAjouterController.TypeClient == 1){
DevisTextPrenom.setVisible(false);
DevisTextMatricule.setVisible(true);
DevisPrenom.setText(devis.getMatricule());
}
DevisAdresse.setText(devis.getAdresse());
DevisTELE1.setText(devis.getTele1());
DevisTELE2.setText(devis.getTele2());
TableViewListeProduitDevis.setItems(devis.getListeproduit());
}
public DevisDialogConfirmationController(){
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Devis/DevisDialogConfirmation.fxml"));
fxmlLoader.setController(this);
nodeFxml = (Node) fxmlLoader.load();
} catch (IOException ex) {
Logger.getLogger(DevisDialogConfirmationController.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void Show()
{
StackPane Sp = new StackPane();
Scene scene = new Scene(Sp);
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(nodeFxml);
Stage stage = MyWindow.myStage;
stage.setScene(scene);
stage.show();
}
@FXML
private void ExitButtonAction(ActionEvent event) throws IOException {
AnchorPrincipal.setVisible(false);
}
}
@@ -0,0 +1,396 @@
package Controllers.DevisClt;
import Controllers.Traitement.MyWindow;
import Models.DevisClt.DevisCltListe;
import Models.DevisClt.DevisDB;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
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.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class DevisImporterController implements Initializable {
@FXML private AnchorPane anchorpane ;
@FXML private ProgressBar ProgressBarDevisClt;
@FXML private Button ButtonSearchDevisClt;
@FXML public TableView<DevisCltListe> TableViewGestionDevis;
@FXML public TableColumn<DevisCltListe ,String> TabColCodeDevis;
@FXML public TableColumn<DevisCltListe ,String> TabColModePaiement;
@FXML public TableColumn<DevisCltListe ,String> TabColTypeClient;
@FXML public TableColumn<DevisCltListe ,String> TabColCodeClient;
@FXML public TableColumn<DevisCltListe ,String> TabColTotalDevis;
@FXML public TableColumn<DevisCltListe ,String> TabColDateCreation ;
@FXML public TableColumn<DevisCltListe ,String> TabColDateFinValidite;
@FXML public TableColumn<DevisCltListe ,Boolean>TabColDetail ;
@FXML public TextField TextFieldCodeDevis ;
@FXML public TextField TextFieldCodeClient ;
@FXML public DatePicker DatePickerCreation ;
@FXML public TextField TextFieldNomPrenomClient ;
@FXML public TextField TextFieldCinClient;
@FXML public RadioButton RadioComptant;
@FXML public RadioButton RadioFacilite;
@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 ;
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;
public Node node;
private Service<Void> ThreadSearchDevisCltRechercher;
public DevisImporterController() {
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Devis/DevisImporter.fxml"));
fxmlLoader.setController(this);
node = (Node) fxmlLoader.load();
} catch (IOException ex) {
Logger.getLogger(DevisImporterController.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void Show()
{
StackPane Sp = new StackPane();
Scene scene = new Scene(Sp);
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(node);
Stage stage = MyWindow.myStage;
stage.setScene(scene);
stage.show();
}
@Override
public void initialize(URL url, ResourceBundle rb) {
//comboboxnombre des lignes tableview
NbrLigne.setItems(cursors);
NbrLigne.getSelectionModel().selectFirst();
TableViewGestionDevis.setEditable(true);
TabColCodeDevis.setStyle( "-fx-alignment: CENTER;");TabColCodeDevis.getStyleClass().add("Center");
TabColCodeDevis.setCellValueFactory(new PropertyValueFactory<DevisCltListe, String>("CodeDevis"));
TabColTypeClient.setStyle( "-fx-alignment: CENTER;");TabColTypeClient.getStyleClass().add("Center");
TabColTypeClient.setCellValueFactory(new PropertyValueFactory<DevisCltListe, String>("TypeClient"));
TabColCodeClient.setStyle( "-fx-alignment: CENTER;");TabColCodeClient.getStyleClass().add("Center");
TabColCodeClient.setCellValueFactory(new PropertyValueFactory<DevisCltListe, String>("CodeClient"));
TabColModePaiement.setStyle( "-fx-alignment: CENTER;");TabColModePaiement.getStyleClass().add("Center");
TabColModePaiement.setCellValueFactory(new PropertyValueFactory<DevisCltListe, String>("ModePaiement"));
TabColTotalDevis.setStyle( "-fx-alignment: CENTER;");TabColTotalDevis.getStyleClass().add("Center");
TabColTotalDevis.setCellValueFactory(new PropertyValueFactory<DevisCltListe, String>("TotalDevis"));
TabColDateCreation.setStyle( "-fx-alignment: CENTER;");TabColDateCreation.getStyleClass().add("Center");
TabColDateCreation.setCellValueFactory(new PropertyValueFactory<DevisCltListe, String>("DateCreation"));
TabColDateFinValidite.setStyle( "-fx-alignment: CENTER;");TabColDateFinValidite.getStyleClass().add("Center");
TabColDateFinValidite.setCellValueFactory(new PropertyValueFactory<DevisCltListe, String>("FinValidite"));
TabColDetail.setSortable(true);
TabColDetail.setStyle( "-fx-alignment: CENTER;");TabColDetail.getStyleClass().add("Center");
ButtonSearchDevisClt.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchDevisClt();
}
});
anchorpane.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchDevisClt();
}
}
});
GestionSearchDevisClt();
}
@FXML
private void QuiterButtonAction(ActionEvent event) throws IOException {
anchorpane.setVisible(false);
}
/****************************************************************************** *
* *
* Methode last Next TableView *
* * *
******************************************************************************/
private void SearchDevisClt()
{
ProgressBarDevisClt.setVisible(true);
ButtonSearchDevisClt.setDisable(true);
ThreadSearchDevisCltRechercher = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
position = 0;
actuellepage = 1;
String DateCreation = "";
if(DatePickerCreation.getValue() != null){
DateCreation = DatePickerCreation.getValue().toString();
}
// 0comptant 1facilité
String TypeRegement = "";
if(RadioComptant.isSelected()){
TypeRegement = "0";
}else if(RadioFacilite.isSelected()){
TypeRegement = "1";
}
ObservableList<DevisCltListe> ListDevisClts = new DevisDB().SearchDevisCltGestion(
position,
nbrligne,
TextFieldCodeDevis.getText(),
TextFieldCodeClient.getText(),
TypeRegement,
DateCreation,
TextFieldNomPrenomClient.getText(),
TextFieldCinClient.getText());
TableViewGestionDevis.setItems(ListDevisClts);
totalcount = new DevisDB().nbrDevisCltGestion(TextFieldCodeDevis.getText(), TextFieldCodeClient.getText(), TypeRegement, DateCreation, TextFieldNomPrenomClient.getText(), TextFieldCinClient.getText());
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;
}
};
}
};
ThreadSearchDevisCltRechercher.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarDevisClt.setVisible(false);
ButtonSearchDevisClt.setDisable(false);
LabelCount.setText(totalcount.toString());
}
});
ThreadSearchDevisCltRechercher.start();
}
private void NextLastSearchDevisClt(Integer ParmPosition, Integer ParamNbrligne)
{
ProgressBarDevisClt.setVisible(true);
ButtonSearchDevisClt.setDisable(true);
ThreadSearchDevisCltRechercher = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
String DateCreation = "";
if(DatePickerCreation.getValue() != null){
DateCreation = DatePickerCreation.getValue().toString();
}
// 0comptant 1facilité
String TypeRegement = "";
if(RadioComptant.isSelected()){
TypeRegement = "0";
}else if(RadioFacilite.isSelected()){
TypeRegement = "1";
}
ObservableList<DevisCltListe> ListDevisClts = new DevisDB().SearchDevisCltGestion(ParmPosition, ParamNbrligne, TextFieldCodeDevis.getText(), TextFieldCodeClient.getText(), TypeRegement, DateCreation, TextFieldNomPrenomClient.getText(), TextFieldCinClient.getText());
TableViewGestionDevis.setItems(ListDevisClts);
return null;
}
};
}
};
ThreadSearchDevisCltRechercher.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarDevisClt.setVisible(false);
ButtonSearchDevisClt.setDisable(false);
}
});
ThreadSearchDevisCltRechercher.start();
}
private void GestionSearchDevisClt()
{
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;
NextLastSearchDevisClt(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;
NextLastSearchDevisClt(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;
NextLastSearchDevisClt(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;
NextLastSearchDevisClt(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;
NextLastSearchDevisClt(position, nbrligne);
actuellepage=actuellepage-3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
}
}
@@ -0,0 +1,118 @@
/*
* 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.DevisClt;
import Controllers.Traitement.Adaptateur;
import javafx.beans.property.SimpleStringProperty;
/**
*
* @author PC-Maher
*/
public class ListProduitDevis {
private final SimpleStringProperty reference;
private final SimpleStringProperty designaton;
private final SimpleStringProperty quantite;
private final SimpleStringProperty PrixHT;
private final SimpleStringProperty Remise;
private final SimpleStringProperty TotalHT;
private final SimpleStringProperty TVA;
private final SimpleStringProperty TotalTTC;
public ListProduitDevis(String reference, String designaton, String quantite, String PrixHT, String Remise, String TotalHT, String TVA, String TotalTTC) {
if(!reference.isEmpty()){
float remise = Adaptateur.ArrondStringToFloat(Remise.replace("%", "")) ;
float prixht = Adaptateur.ArrondStringToFloat(PrixHT) ;
float tva = Adaptateur.StringToFloat(TVA) ;
float qte = Adaptateur.StringToFloat(quantite) ;
float totalht = (prixht - ((prixht * remise)/100))* qte ;
float totalttc = totalht + ((totalht * tva)/100) ;
if(!Remise.contains("%")){ Remise=Remise+"%"; }
if(!TVA.contains("%")){ TVA=TVA+"%"; }
TotalHT = Adaptateur.ArrondFloatToString(totalht);
TotalTTC= Adaptateur.ArrondFloatToString(totalttc);
}
this.reference = new SimpleStringProperty(reference);
this.designaton = new SimpleStringProperty(designaton);
this.quantite = new SimpleStringProperty(quantite);
this.PrixHT = new SimpleStringProperty(PrixHT);
this.Remise = new SimpleStringProperty(Remise);
this.TotalHT = new SimpleStringProperty(TotalHT);
this.TVA = new SimpleStringProperty(TVA);
this.TotalTTC = new SimpleStringProperty(TotalTTC);
}
public String getReference() {
return reference.get();
}
public void setReference(String Reference) {
reference.set(Reference);
}
public String getDesignaton() {
return designaton.get();
}
public void setDesignaton(String Designaton) {
designaton.set(Designaton);
}
public String getQuantite() {
return quantite.get();
}
public void setQuantite(String Quantite) {
quantite.set(Quantite);
}
public String getPrixHT() {
return PrixHT.get();
}
public void setPrixHT(String prixHT) {
PrixHT.set(prixHT);
}
public String getRemise() {
return Remise.get();
}
public void setRemise(String remise) {
Remise.set(remise);
}
public String getTotalHT() {
return TotalHT.get();
}
public void setTotalHT(String totalHT) {
TotalHT.set(totalHT);
}
public String getTVA() {
return TVA.get();
}
public void setTVA(String tva) {
TVA.set(tva);
}
public String getTotalTTC() {
return TotalTTC.get();
}
public void setTotalTTC(String totalTTC) {
TotalTTC.set(totalTTC);
}
}
@@ -0,0 +1,87 @@
/*
* 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.Dialog;
import Controllers.Traitement.MyWindow;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;
/**
*
* @author Maher
*/
public class Dialog {
public double Height = MyWindow.myStage.getHeight() ;
public double Width = MyWindow.myStage.getWidth() ;
@FXML public Text Titre;
@FXML public Text Message;
@FXML public Button Valider;
@FXML public Button Annuler;
@FXML public AnchorPane PaneDialog;
public Node DialogNotification() throws IOException{
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Dialog/DialogNotification.fxml"));
fxmlLoader.setController(this);
Node node = (Node)fxmlLoader.load();
return node;
}
public Node DialogAlert() {
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Dialog/DialogAlert.fxml"));
fxmlLoader.setController(this);
Node node;
node = (Node)fxmlLoader.load();
return node;
} catch (IOException ex) {
Logger.getLogger(Dialog.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
public void DefaultAnnuler(){
Annuler.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
PaneDialog.setVisible(false);
}
});
}
public void Show(Node node)
{
StackPane Sp = new StackPane();
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(node);
Scene scene = new Scene(Sp);
Stage stage = MyWindow.myStage;
stage.setScene(scene);
stage.show();
}
}
@@ -0,0 +1,62 @@
/*
* 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.Dialog;
import Controllers.Traitement.MyWindow;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class DialogSuccessController {
public Node nodeFxml ;
@FXML public Button Valider;
@FXML public Text Message;
@FXML public AnchorPane PaneDialog;
public DialogSuccessController() {
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Dialog/DialogSuccess.fxml"));
fxmlLoader.setController(this);
nodeFxml = (Node) fxmlLoader.load();
} catch (IOException ex) {
Logger.getLogger(DialogSuccessController.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void Show()
{
StackPane Sp = new StackPane();
Scene scene = new Scene(Sp);
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(nodeFxml);
Stage stage = MyWindow.myStage;
stage.setScene(scene);
stage.show();
}
}
@@ -0,0 +1,123 @@
/*
* 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.Dialog;
import Controllers.Traitement.MyWindow;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import javafx.stage.Stage;
/**
*
* @author Maher
*/
public class MessageControle {
public double Height = MyWindow.myStage.getHeight() ;
public double Width = MyWindow.myStage.getWidth() ;
public Button bouttonNo = new Button();
public Button bouttonOK = new Button();
public Text titre = new Text();
public TextFlow DetailMSG = new TextFlow();
public Text titreMSG = new Text();
public Text detail = new Text();
public StackPane stackpane = new StackPane();
public Node Setnotification(){
Group group = new Group();
AnchorPane Ap = new AnchorPane();
Ap.setStyle("-fx-background-color: rgba(0,0,0,0.6);");
Pane pa1 = new Pane();
pa1.setStyle("-fx-background-color:#ffffff; -fx-border-color: #212121; -fx-border-radius: 10 10 0 0; -fx-background-radius: 10 10 0 0;");
pa1.setPrefHeight(200);
pa1.setPrefWidth(497);
Pane pa2 = new Pane();
pa2.setStyle("-fx-background-color:linear-gradient(to bottom, #585858, #333333); -fx-background-radius: 10 10 0 0;");
pa2.setPrefHeight(30);
pa2.setPrefWidth(497);
Pane pa3 = new Pane();
pa3.setStyle("-fx-background-color:linear-gradient(to bottom, #E2E2E2, #EDEDED); -fx-border-color: #B4B4B4;");
pa3.setLayoutY(30);
pa3.setPrefHeight(100);
pa3.setPrefWidth(497);
titre.setText("Alert Dialog");
titre.setFont(Font.font("System", FontWeight.BOLD, 13));
titre.setFill(Color.web("#ffffff"));
titre.setLayoutX(17);
titre.setLayoutY(22);
Image imgicon = new Image(getClass().getResourceAsStream("/Public/icon/iconalert.png"));
ImageView icon = new ImageView(imgicon);
icon.setLayoutX(410);
icon.setLayoutY(50);
icon.setFitWidth(64);
icon.setFitHeight(64);
DetailMSG.setPrefHeight(120);
DetailMSG.setPrefWidth(400);
DetailMSG.setLayoutX(20);
DetailMSG.setLayoutY(60);
bouttonOK.setText("Ok");
bouttonOK.setFont(Font.font ("System", FontWeight.BOLD, 12));
bouttonOK.setPrefWidth(73);
bouttonOK.setPrefHeight(30);
bouttonOK.setLayoutX(210);
bouttonOK.setLayoutY(150);
group.getChildren().addAll(pa1, pa2, pa3, titre, icon, DetailMSG, bouttonOK);
stackpane.setVisible(true);
stackpane.getChildren().add(Ap);
stackpane.getChildren().add(group);
return stackpane;
}
public void ShowNotification()
{
Node node = this.Setnotification();
StackPane Sp = new StackPane();
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(node);
Scene scene = new Scene(Sp);
Stage stage = MyWindow.myStage;
stage.setScene(scene);
stage.show();
}
}
@@ -0,0 +1,125 @@
/*
* 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.Dialog;
import Controllers.Traitement.MyWindow;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import javafx.stage.Stage;
/**
*
* @author PC-Maher
*/
public class Notification {
public double Height = MyWindow.myStage.getHeight() ;
public double Width = MyWindow.myStage.getWidth() ;
public Button bouttonNo = new Button();
public Button bouttonOK = new Button();
public Text titre = new Text();
public TextFlow DetailMSG = new TextFlow();
public Text titreMSG = new Text();
public Text detail = new Text();
public StackPane stackpane = new StackPane();
public Node Setnotification(){
Group group = new Group();
AnchorPane Ap = new AnchorPane();
Ap.setStyle("-fx-background-color: rgba(0,0,0,0.6);");
Pane pa1 = new Pane();
pa1.setStyle("-fx-background-color:#ffffff; -fx-border-color: #212121; -fx-border-radius: 10 10 0 0; -fx-background-radius: 10 10 0 0;");
pa1.setPrefHeight(200);
pa1.setPrefWidth(497);
Pane pa2 = new Pane();
pa2.setStyle("-fx-background-color:linear-gradient(to bottom, #585858, #333333); -fx-background-radius: 10 10 0 0;");
pa2.setPrefHeight(30);
pa2.setPrefWidth(497);
titre.setText("Dialog de notification");
titre.setFont(Font.font("System", FontWeight.BOLD, 13));
titre.setFill(Color.web("#ffffff"));
titre.setLayoutX(17);
titre.setLayoutY(22);
Image imgicon = new Image(getClass().getResourceAsStream("/Public/icon/dialoginform.png"));
ImageView icon = new ImageView(imgicon);
icon.setLayoutX(20);
icon.setLayoutY(60);
icon.setFitWidth(46);
icon.setFitHeight(50);
DetailMSG.setPrefHeight(120);
DetailMSG.setPrefWidth(400);
DetailMSG.setLayoutX(80);
DetailMSG.setLayoutY(55);
bouttonOK.setText("Valider");
bouttonOK.setFont(Font.font ("System", FontWeight.BOLD, 12));
bouttonOK.setStyle("{-fx-background-color:#EFEFEF; -fx-border-color: #959595; -fx-border-radius: 5 5 5 5;} hover:{-fx-background-color:#E6E6E6;}");
bouttonOK.setPrefWidth(73);
bouttonOK.setPrefHeight(30);
bouttonOK.setLayoutX(320);
bouttonOK.setLayoutY(160);
bouttonNo.setText("Annuler");
bouttonNo.setFont(Font.font ("System", FontWeight.BOLD, 12));
bouttonNo.setStyle("{-fx-background-color:#EFEFEF; -fx-border-color: #959595; -fx-border-radius: 5 5 5 5;} hover:{-fx-background-color:#E6E6E6;}");
bouttonNo.setPrefWidth(73);
bouttonNo.setPrefHeight(30);
bouttonNo.setLayoutX(410);
bouttonNo.setLayoutY(160);
bouttonNo.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
stackpane.setVisible(false);
}
});
group.getChildren().addAll(pa1, pa2, titre, icon, DetailMSG, bouttonOK, bouttonNo);
stackpane.setVisible(true);
stackpane.getChildren().add(Ap);
stackpane.getChildren().add(group);
return stackpane;
}
public void ShowNotification()
{
Node node = this.Setnotification();
StackPane Sp = new StackPane();
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(node);
Scene scene = new Scene(Sp);
Stage stage = MyWindow.myStage;
stage.setScene(scene);
stage.show();
}
}
@@ -0,0 +1,306 @@
/*
* 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.Dialog;
import Controllers.Traitement.MyWindow;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import javafx.stage.Stage;
/**
*
* @author Maher
*/
public class ShowDialog{
public static String titre ;
public static String detail ;
public static String getTitre() {
return titre;
}
public static String getDetail() {
return detail;
}
public static void setTitre(String titre) {
ShowDialog.titre = titre;
}
public static void setDetail(String detail) {
ShowDialog.detail = detail;
}
public Node DialogAlert(String MsgTitre, String MsgDetail){
final StackPane stackpane = new StackPane();
Group group = new Group();
AnchorPane Ap = new AnchorPane();
Ap.setStyle("-fx-background-color: rgba(0,0,0,0.6);");
Ap.addEventFilter(MouseEvent.MOUSE_PRESSED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
System.out.println("mouse click detected! ");
}
});
Pane pa1 = new Pane();
pa1.setStyle("-fx-background-color:#ffffff; -fx-border-color: #212121; -fx-border-radius: 10 10 0 0; -fx-background-radius: 10 10 0 0;");
pa1.setPrefHeight(231);
pa1.setPrefWidth(497);
Pane pa2 = new Pane();
pa2.setStyle("-fx-background-color:linear-gradient(to bottom, #585858, #333333); -fx-background-radius: 10 10 0 0;");
pa2.setPrefHeight(36);
pa2.setPrefWidth(497);
Text titre = new Text();
titre.setText("Exception Dialog");
titre.setFont(Font.font("System", FontWeight.BOLD, 13));
titre.setFill(Color.web("#ffffff"));
titre.setLayoutX(17);
titre.setLayoutY(22);
Pane pa3 = new Pane();
pa3.setStyle("-fx-background-color:linear-gradient(to bottom, #E2E2E2, #EDEDED); -fx-border-color: #B4B4B4;");
pa3.setLayoutY(36);
pa3.setPrefHeight(48);
pa3.setPrefWidth(497);
//Image imgicon = new Image(getClass().getResourceAsStream("/Public/icon/dialoginform.png"));
//ImageView icon = new ImageView(imgicon);
Image image = new Image(getClass().getResourceAsStream("/Public/icon/dialog_error.png"));
ImageView icon = new ImageView(image);
icon.setLayoutX(440);
icon.setLayoutY(40);
icon.setFitWidth(38);
icon.setFitHeight(38);
Text titreMSG = new Text();
titreMSG.setText(MsgTitre);
titreMSG.setFont(Font.font("System", FontWeight.NORMAL, 13));
titreMSG.setFill(Color.web("#000000"));
titreMSG.setLayoutX(27);
titreMSG.setLayoutY(65);
Text detail = new Text();
detail.setText(MsgDetail);
detail.setFont(Font.font("System", FontWeight.NORMAL, 12));
detail.setFill(Color.web("#000000"));
TextFlow DetailMSG = new TextFlow(detail);
DetailMSG.setPrefHeight(92);
DetailMSG.setPrefWidth(344);
DetailMSG.setLayoutX(28);
DetailMSG.setLayoutY(95);
Button boutton = new Button();
boutton.setText("Valider");
boutton.setFont(Font.font ("System", FontWeight.BOLD, 12));
boutton.setStyle("{-fx-background-color:#EFEFEF; -fx-border-color: #959595; -fx-border-radius: 5 5 5 5;} hover:{-fx-background-color:#E6E6E6;}");
boutton.setPrefWidth(84);
boutton.setPrefHeight(31);
boutton.setLayoutX(388);
boutton.setLayoutY(186);
boutton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
stackpane.setVisible(false);
}
});
group.getChildren().addAll(pa1, pa2, titre, pa3, titreMSG, icon, DetailMSG, boutton);
stackpane.getChildren().add(Ap);
stackpane.getChildren().add(group);
return stackpane ;
}
public Node DialogNotification(String MsgTitre, String MsgDetail){
final StackPane stackpane = new StackPane();
Group group = new Group();
AnchorPane Ap = new AnchorPane();
Ap.setStyle("-fx-background-color: rgba(0,0,0,0.6);");
Ap.addEventFilter(MouseEvent.MOUSE_PRESSED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
System.out.println("mouse click detected! ");
}
});
Pane pa1 = new Pane();
pa1.setStyle("-fx-background-color:#ffffff; -fx-border-color: #212121; -fx-border-radius: 10 10 0 0; -fx-background-radius: 10 10 0 0;");
pa1.setPrefHeight(231);
pa1.setPrefWidth(497);
Pane pa2 = new Pane();
pa2.setStyle("-fx-background-color:linear-gradient(to bottom, #585858, #333333); -fx-background-radius: 10 10 0 0;");
pa2.setPrefHeight(36);
pa2.setPrefWidth(497);
Text titre = new Text();
titre.setText("Dialog de notification");
titre.setFont(Font.font("System", FontWeight.BOLD, 13));
titre.setFill(Color.web("#ffffff"));
titre.setLayoutX(17);
titre.setLayoutY(22);
Pane pa3 = new Pane();
pa3.setStyle("-fx-background-color:linear-gradient(to bottom, #E2E2E2, #EDEDED); -fx-border-color: #B4B4B4;");
pa3.setLayoutY(36);
pa3.setPrefHeight(48);
pa3.setPrefWidth(497);
Image image = new Image(getClass().getResourceAsStream("/Public/icon/dialog_notification.png"));
ImageView icon = new ImageView(image);
icon.setLayoutX(440);
icon.setLayoutY(40);
icon.setFitWidth(40);
icon.setFitHeight(40);
Text titreMSG = new Text();
titreMSG.setText(MsgTitre);
titreMSG.setFont(Font.font("System", FontWeight.NORMAL, 16));
titreMSG.setFill(Color.web("#000000"));
titreMSG.setLayoutX(27);
titreMSG.setLayoutY(65);
Text detail = new Text();
detail.setText(MsgDetail);
detail.setFont(Font.font("System", FontWeight.NORMAL, 15));
detail.setFill(Color.web("#000000"));
TextFlow DetailMSG = new TextFlow(detail);
DetailMSG.setPrefHeight(92);
DetailMSG.setPrefWidth(344);
DetailMSG.setLayoutX(28);
DetailMSG.setLayoutY(95);
Button bouttonOK = new Button();
bouttonOK.setText("Valider");
bouttonOK.setFont(Font.font ("System", FontWeight.BOLD, 12));
bouttonOK.setStyle("{-fx-background-color:#EFEFEF; -fx-border-color: #959595; -fx-border-radius: 5 5 5 5;} hover:{-fx-background-color:#E6E6E6;}");
bouttonOK.setPrefWidth(73);
bouttonOK.setPrefHeight(28);
bouttonOK.setLayoutX(300);
bouttonOK.setLayoutY(186);
bouttonOK.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
stackpane.setVisible(false);
}
});
Button bouttonNo = new Button();
bouttonNo.setText("Annuler");
bouttonNo.setFont(Font.font ("System", FontWeight.BOLD, 12));
bouttonNo.setStyle("{-fx-background-color:#EFEFEF; -fx-border-color: #959595; -fx-border-radius: 5 5 5 5;} hover:{-fx-background-color:#E6E6E6;}");
bouttonNo.setPrefWidth(73);
bouttonNo.setPrefHeight(28);
bouttonNo.setLayoutX(400);
bouttonNo.setLayoutY(186);
bouttonNo.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
stackpane.setVisible(false);
}
});
group.getChildren().addAll(pa1, pa2, titre, pa3, titreMSG, icon, DetailMSG, bouttonOK, bouttonNo);
stackpane.getChildren().add(Ap);
stackpane.getChildren().add(group);
return stackpane ;
}
public void ShowAletDialog()
{
Node node = DialogAlert(titre, detail);
StackPane Sp = new StackPane();
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(node);
Scene scene = new Scene(Sp);
Stage stage = MyWindow.myStage;
stage.setScene(scene);
stage.show();
}
public void ShowNotificationDialog(String Titre, String Detail)
{
Node node = DialogNotification(Titre, Detail);
StackPane Sp = new StackPane();
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(node);
Scene scene = new Scene(Sp);
Stage stage = MyWindow.myStage;
stage.setScene(scene);
stage.show();
}
public void Show(Node node)
{
StackPane Sp = new StackPane();
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(node);
Scene scene = new Scene(Sp);
Stage stage = MyWindow.myStage;
stage.setScene(scene);
stage.show();
}
}
@@ -0,0 +1,416 @@
package Controllers.FactureClt;
import Models.CommandeClt.CommandeCltDB;
import Models.CommandeClt.CommandeCltListe;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
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.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.RadioButton;
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.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;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class FactureCltAjouterController implements Initializable {
@FXML private AnchorPane PaneFactCltAjouter ;
@FXML private ProgressBar ProgressBarFactureCltCommande;
@FXML private Button ButtonSearchFactureCltCommande ;
@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 ;
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;
@FXML public TableView<CommandeCltListe> TableViewGestionCommande;
@FXML public TableColumn<CommandeCltListe ,String> TabColCodeCommande;
@FXML public TableColumn<CommandeCltListe ,String> TabColModePaiement;
@FXML public TableColumn<CommandeCltListe ,String> TabColTypeClient;
@FXML public TableColumn<CommandeCltListe ,String> TabColCodeClient;
@FXML public TableColumn<CommandeCltListe ,String> TabColTotalCommande;
@FXML public TableColumn<CommandeCltListe ,String> TabColDateCreation ;
@FXML public TableColumn<CommandeCltListe ,Boolean>TabColAction ;
@FXML public TextField TextFieldCodeCommande;
@FXML public TextField TextFieldCodeClient;
@FXML public TextField TextFieldNameClient;
@FXML public TextField TextFieldCodeDevis;
@FXML public DatePicker DatePickerCreation;
@FXML public RadioButton RadioComptant;
@FXML public RadioButton RadioFacilite;
private Service<Void> ThreadSearchFactureCltCommande;
@Override
public void initialize(URL url, ResourceBundle rb) {
//comboboxnombre des lignes tableview
NbrLigne.setItems(cursors);
NbrLigne.getSelectionModel().selectFirst();
TableViewGestionCommande.setEditable(true);
TabColCodeCommande.setStyle( "-fx-alignment: CENTER;");TabColCodeCommande.getStyleClass().add("Center");
TabColCodeCommande.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("CodeCommande"));
TabColTypeClient.setStyle( "-fx-alignment: CENTER;");TabColTypeClient.getStyleClass().add("Center");
TabColTypeClient.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("TypeClient"));
TabColCodeClient.setStyle( "-fx-alignment: CENTER;");TabColCodeClient.getStyleClass().add("Center");
TabColCodeClient.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("CodeClient"));
TabColModePaiement.setStyle( "-fx-alignment: CENTER;");TabColModePaiement.getStyleClass().add("Center");
TabColModePaiement.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("ModePaiement"));
TabColTotalCommande.setStyle( "-fx-alignment: CENTER;");TabColTotalCommande.getStyleClass().add("Center");
TabColTotalCommande.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("TotalCommande"));
TabColDateCreation.setStyle( "-fx-alignment: CENTER;");TabColDateCreation.getStyleClass().add("Center");
TabColDateCreation.setCellValueFactory(new PropertyValueFactory<CommandeCltListe, String>("DateCreation"));
TabColAction.setSortable(true);
TabColAction.setStyle( "-fx-alignment: CENTER;");TabColAction.getStyleClass().add("Center");
TabColAction.setCellFactory(new Callback<TableColumn<CommandeCltListe, Boolean>, TableCell<CommandeCltListe, Boolean>>() {
@Override
public TableCell<CommandeCltListe, Boolean> call(TableColumn<CommandeCltListe, Boolean> personBooleanTableColumn) {
return new ButtonCell();
}
});
ButtonSearchFactureCltCommande.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchFactureCltCommande();
}
});
PaneFactCltAjouter.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchFactureCltCommande();
}
}
});
RadioComptant.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchFactureCltCommande();
}
});
RadioFacilite.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchFactureCltCommande();
}
});
GestionSearchFactureCltCommande();
}
//Define the button cell
private class ButtonCell extends TableCell<CommandeCltListe, Boolean> {
final Button cellButton = new Button();
ButtonCell(){
cellButton.getStyleClass().add("btn-icon-primary");
Image coffeeImage = new Image(getClass().getResourceAsStream("/Public/icon/iconedit.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 {
// get Selected Item
CommandeCltListe current = (CommandeCltListe) ButtonCell.this.getTableView().getItems().get(ButtonCell.this.getIndex());
String codeCommande = current.getCodeCommande();
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/FactureClt/FactureCltAjouterDetailSelect.fxml"));
Parent NodeDetailSelect = (Parent)fxmlLoader.load();
FactureCltAjouterDetailSelectController FactureCltAjouterDetailSelect = fxmlLoader.getController();
FactureCltAjouterDetailSelect.setDataCommande(codeCommande);
PaneFactCltAjouter.getChildren().clear();
PaneFactCltAjouter.getChildren().add(NodeDetailSelect);
} catch (IOException ex) {
Logger.getLogger(FactureCltAjouterController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
//Display button if the row is not empty
@Override
protected void updateItem(Boolean t, boolean empty) {
if(!empty){
setGraphic(cellButton);
} else {
setGraphic(null);
}
}
}
/****************************************************************************** *
* *
* Methode last Next TableView *
* * *
******************************************************************************/
private void SearchFactureCltCommande()
{
ProgressBarFactureCltCommande.setVisible(true);
ButtonSearchFactureCltCommande.setDisable(true);
ThreadSearchFactureCltCommande = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
position = 0;
actuellepage = 1;
String DateCreation = "";
if(DatePickerCreation.getValue() != null){
DateCreation = DatePickerCreation.getValue().toString();
}
// 0comptant 1facilité
String TypeRegement = "";
if(RadioComptant.isSelected()){
TypeRegement = "0";
}else if(RadioFacilite.isSelected()){
TypeRegement = "1";
}
ObservableList<CommandeCltListe> ListFactureCltCommandes = new CommandeCltDB().SearchCommande(
position,
nbrligne,
TypeRegement,
TextFieldCodeCommande.getText(),
TextFieldCodeClient.getText(),
TextFieldNameClient.getText(),
TextFieldCodeDevis.getText(),
DateCreation);
TableViewGestionCommande.setItems(ListFactureCltCommandes);
totalcount = new CommandeCltDB().nbrSearchCommande(TypeRegement, TextFieldCodeCommande.getText(), TextFieldCodeClient.getText(), TextFieldNameClient.getText(), TextFieldCodeDevis.getText(), DateCreation);
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;
}
};
}
};
ThreadSearchFactureCltCommande.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarFactureCltCommande.setVisible(false);
ButtonSearchFactureCltCommande.setDisable(false);
LabelCount.setText(totalcount.toString());
}
});
ThreadSearchFactureCltCommande.start();
}
private void NextLastSearchFactureCltCommande(Integer ParmPosition, Integer ParamNbrligne)
{
ProgressBarFactureCltCommande.setVisible(true);
ButtonSearchFactureCltCommande.setDisable(true);
ThreadSearchFactureCltCommande = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
String DateCreation = "";
if(DatePickerCreation.getValue() != null){
DateCreation = DatePickerCreation.getValue().toString();
}
// 0comptant 1facilité
String TypeRegement = "";
if(RadioComptant.isSelected()){
TypeRegement = "0";
}else if(RadioFacilite.isSelected()){
TypeRegement = "1";
}
ObservableList<CommandeCltListe> ListFactureCltCommandes = new CommandeCltDB().SearchCommande(ParmPosition, ParamNbrligne, TypeRegement, TextFieldCodeCommande.getText(), TextFieldCodeClient.getText(), TextFieldNameClient.getText(), TextFieldCodeDevis.getText(), DateCreation);
TableViewGestionCommande.setItems(ListFactureCltCommandes);
return null;
}
};
}
};
ThreadSearchFactureCltCommande.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarFactureCltCommande.setVisible(false);
ButtonSearchFactureCltCommande.setDisable(false);
}
});
ThreadSearchFactureCltCommande.start();
}
private void GestionSearchFactureCltCommande()
{
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;
NextLastSearchFactureCltCommande(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;
NextLastSearchFactureCltCommande(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;
NextLastSearchFactureCltCommande(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;
NextLastSearchFactureCltCommande(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;
NextLastSearchFactureCltCommande(position, nbrligne);
actuellepage=actuellepage-3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
}
}
@@ -0,0 +1,184 @@
package Controllers.FactureClt;
import Controllers.Traitement.Adaptateur;
import Models.Produit.ListeProduit;
import Controllers.Traitement.ParametreSystem;
import Models.CommandeClt.CommandeClt;
import Models.CommandeClt.CommandeCltDB;
import Models.FactureClt.FactureClt;
import Models.User.User;
import java.io.IOException;
import java.net.URL;
import java.util.Date;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Text;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class FactureCltAjouterDetailSelectController implements Initializable {
@FXML private AnchorPane AnchorPaneFactAddDetailSelect ;
private String TypeRegement;
public CommandeClt Commande;
public FactureClt Facture = new FactureClt();
@FXML private Text InfoCltNom ;
@FXML private Text InfoCltPrenom ;
@FXML private Text InfoCltAdress ;
@FXML private Text InfoCommCode ;
@FXML private Text InfoCommDateCreation ;
@FXML private Text InfoCommTypeReglement ;
@FXML private Text InfoCommTotalTVA ;
@FXML private Text InfoCommRemise ;
@FXML private Text InfoCommTotalHTNet ;
@FXML private Text InfoCommNetAPayer ;
@FXML private Text TextPrenomMatricule;
@FXML private TableView<ListeProduit> TableViewListeProduitCommClt ;
@FXML private TableColumn<ListeProduit ,String> TabColReference;
@FXML private TableColumn<ListeProduit ,String> TabColDesignaton;
@FXML private TableColumn<ListeProduit ,String> TabColQuantite ;
@FXML private TableColumn<ListeProduit ,String> TabColPrixHT;
@FXML private TableColumn<ListeProduit ,String> TabColRemise;
@FXML private TableColumn<ListeProduit ,String> TabColTotalHT;
@FXML private TableColumn<ListeProduit ,String> TabColTVA;
@FXML private TableColumn<ListeProduit ,String> TabColTotalTTC;
@Override
public void initialize(URL url, ResourceBundle rb) {
TableViewListeProduitCommClt.setEditable(false);
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");
}
public void setDataCommande(String CodeCommande){
CommandeCltDB CommandeDB = new CommandeCltDB();
Commande = CommandeDB.getCommandeClt(CodeCommande);
if(Commande.getTypeClient()==0){
InfoCltNom.setText(Commande.CltPersonne.getNom());
InfoCltPrenom.setText(Commande.CltPersonne.getPrenom());
InfoCltAdress.setText(Commande.CltPersonne.getAdresse());
}
if(Commande.getTypeClient()==1){
InfoCltNom.setText(Commande.CltEntreprise.getNom());
InfoCltPrenom.setText(Commande.CltEntreprise.getMatricule());
InfoCltAdress.setText(Commande.CltEntreprise.getAdresse());
TextPrenomMatricule.setText("Matricule");
}
if(Commande.getTypeClient()==2){
InfoCltNom.setText(Commande.CltPassager.getNom());
InfoCltPrenom.setText(Commande.CltPassager.getPrenom());
InfoCltAdress.setText(Commande.CltPassager.getAdresse());
}
//Adaptateur.StringToStringEspaceCurrency()
InfoCommCode.setText(Commande.getCodecommandeclt());
InfoCommDateCreation.setText(Adaptateur.NormalDateFormat(Commande.getDate()));
InfoCommTypeReglement.setText(Commande.getTypeRegementString());
TypeRegement = Commande.getTypeRegement();
InfoCommTotalTVA.setText(Adaptateur.StringToStringEspaceCurrency(Commande.getTotalTVA()));
InfoCommRemise.setText(Adaptateur.StringToStringEspaceCurrency(Commande.getRemise()));
InfoCommTotalHTNet.setText(Adaptateur.StringToStringEspaceCurrency(Commande.getTotalHorsTaxNet()));
InfoCommNetAPayer.setText(Adaptateur.StringToStringEspaceCurrency(Commande.getNetAPayer()));
TableViewListeProduitCommClt.setItems(Commande.getListeproduit());
this.SetDataFacture();
}
public void SetDataFacture(){
Facture.setIdCommandeClt(Commande.getCodecommandeclt());
Facture.setIdBonLivraisonClt(Commande.getCodeBonLivraison());
Facture.setTypeClient(Commande.getTypeClient());
if(Commande.getTypeClient() == 0){
Facture.setCltPersonne(Commande.getCltPersonne());
}else if(Commande.getTypeClient() == 1){
Facture.setCltEntreprise(Commande.getCltEntreprise());
}else if(Commande.getTypeClient() == 2){
Facture.setCltPassager(Commande.getCltPassager());
}
Facture.setDateFacture(new Date().toString());
Facture.setTypeRegement(Commande.getTypeRegement());
Facture.setNetAPayer(Commande.getNetAPayer());
Facture.setTotalTVA(Commande.getTotalTVA());
Facture.setTotalHorsTaxNet(Commande.getTotalHorsTaxNet());
Facture.setRemise(Commande.getRemise());
Facture.setTimbre(Commande.getTimbre());
Facture.setDevise(Commande.getCodeDevis());
Facture.setCodeUser(User.idprofile);
}
//Boutton Présédent
@FXML
private void FactureCltAjouterButtonAction(ActionEvent event) throws IOException {
AnchorPaneFactAddDetailSelect.getChildren().clear();
AnchorPaneFactAddDetailSelect.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/FactureClt/FactureCltAjouter.fxml")));
}
//Boutton Suivant
@FXML
private void FactureCltPaiementButtonAction(ActionEvent event) throws IOException {
AnchorPaneFactAddDetailSelect.getChildren().clear();
if(TypeRegement.equals("0")){
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/FactureClt/FactureCltAjouterPaiementComptent.fxml"));
Parent NodeAjouterPaiementComptent = (Parent)fxmlLoader.load();
FactureCltAjouterPaiementComptentController FactureCltAjouterPaiementComptent = fxmlLoader.getController();
FactureCltAjouterPaiementComptent.commande = Commande;
FactureCltAjouterPaiementComptent.TextNetaPayer.setText(Adaptateur.StringToStringEspaceCurrency(Commande.getNetAPayer()));
AnchorPaneFactAddDetailSelect.getChildren().add(NodeAjouterPaiementComptent);
}
else if(TypeRegement.equals("1")){
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/FactureClt/FactureCltAjouterPaiementFacilite.fxml"));
Parent NodeAjouterPaiementFacilite= (Parent)fxmlLoader.load();
FactureCltAjouterPaiementFaciliteController FactureCltAjouterPaiementFacilite= fxmlLoader.getController();
FactureCltAjouterPaiementFacilite.commande = Commande;
FactureCltAjouterPaiementFacilite.Facture = Facture;
FactureCltAjouterPaiementFacilite.TextNetaPayer.setText(Adaptateur.StringToStringEspaceCurrency(Commande.getNetAPayer()));
AnchorPaneFactAddDetailSelect.getChildren().add(NodeAjouterPaiementFacilite);
}
}
}
@@ -0,0 +1,209 @@
/*
* 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.FactureClt;
import Controllers.Traitement.ParametreSystem;
import Models.CommandeClt.CommandeClt;
import Models.FactureClt.FactureClt;
import Models.ChequeClt.ChequeList;
import Models.FactureClt.FactureCltChequeListe;
import Models.FactureClt.FactureCltDB;
import Models.TraiteClt.TraiteList;
import Models.FactureClt.FactureCltTraiteListe;
import Models.ChequeClt.ChequeClt;
import Models.TraiteClt.TraiteClt;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.ResourceBundle;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Text;
/**
* FXML Controller class
*
* @author PC-Maher
*/
public class FactureCltAjouterDetailTraiteController implements Initializable {
@FXML private AnchorPane PaneFactureCltAjouterDetailTraite;
@FXML public AnchorPane PaneTableViewTraites ;
@FXML public AnchorPane PaneTableViewCheques;
@FXML public Text TextNom ;
@FXML public Text TextPrenomMatricule;
@FXML public Text TextPrenom ;
@FXML public Text TextAdress ;
@FXML public Text TextAvance ;
@FXML public Text TextTypeReglement ; // Traite | Cheque
@FXML public Text TextMontantInteret ;
@FXML public Text TextDetail ;
@FXML public Text TextNbrTraite ;
@FXML public Text TextBanque ;
@FXML public Text Banque ;
@FXML public Text TextMontantTraite ;
@FXML public Text ValMontantTraite;
@FXML public TableView<FactureCltTraiteListe> TableViewListeTraites ;
@FXML public TableColumn<FactureCltTraiteListe ,String> TabColDateTraites;
@FXML public TableColumn<FactureCltTraiteListe ,String> TabColMontantTraites;
@FXML public TableView<FactureCltChequeListe> TableViewListeCheques ;
@FXML public TableColumn<FactureCltChequeListe ,String> TabColDateCheques;
@FXML public TableColumn<FactureCltChequeListe ,String> TabColNumeroCheques;
@FXML public TableColumn<FactureCltChequeListe ,String> TabColBanqueCheques;
@FXML public TableColumn<FactureCltChequeListe ,String> TabColMontantCheques;
final ObservableList<FactureCltTraiteListe> dataListe = FXCollections.observableArrayList();
final ObservableList<FactureCltChequeListe> dataListeCheque = FXCollections.observableArrayList();
public ObservableList<TraiteList> data_List_Traite = FXCollections.observableArrayList();
public ObservableList<ChequeList> data_List_Cheque = FXCollections.observableArrayList();
public boolean TypeFacilite = true; // True Traite | False Cheque
public CommandeClt commande;
public FactureClt Facture ;
public String TextTauxInteret;
public String Net_A_Payer;
public String Avance ;
@Override
public void initialize(URL url, ResourceBundle rb) {
TabColDateTraites.setStyle( "-fx-alignment: CENTER;");
TabColDateTraites.getStyleClass().add("Center");
TabColDateTraites.setCellValueFactory(new PropertyValueFactory<FactureCltTraiteListe, String>("DateTraites"));
TabColMontantTraites.setStyle( "-fx-alignment: CENTER;");
TabColMontantTraites.getStyleClass().add("Center");
TabColMontantTraites.setCellValueFactory(new PropertyValueFactory<FactureCltTraiteListe, String>("MontantTraites"));
TabColDateCheques.setStyle( "-fx-alignment: CENTER;");
TabColDateCheques.getStyleClass().add("Center");
TabColDateCheques.setCellValueFactory(new PropertyValueFactory<FactureCltChequeListe, String>("DateCheques"));
TabColNumeroCheques.setStyle( "-fx-alignment: CENTER;");
TabColNumeroCheques.getStyleClass().add("Center");
TabColNumeroCheques.setCellValueFactory(new PropertyValueFactory<FactureCltChequeListe, String>("NumeroCheques"));
TabColBanqueCheques.setStyle( "-fx-alignment: CENTER;");
TabColBanqueCheques.getStyleClass().add("Center");
TabColBanqueCheques.setCellValueFactory(new PropertyValueFactory<FactureCltChequeListe, String>("BanqueCheques"));
TabColMontantCheques.setStyle( "-fx-alignment: CENTER;");
TabColMontantCheques.getStyleClass().add("Center");
TabColMontantCheques.setCellValueFactory(new PropertyValueFactory<FactureCltChequeListe, String>("MontantCheques"));
}
public void SetDataTraiteFacilite(FactureClt facture){
this.Facture = facture;
TextAvance.setText(Facture.getAvance()+" "+ParametreSystem.CurrencySign);
TextMontantInteret.setText(Facture.getMontantInteret());
ValMontantTraite.setText(Facture.getTotalMontantTraite()+" "+ParametreSystem.CurrencySign);
TextNbrTraite.setText(Facture.getNbrTraite());
TextTauxInteret = Facture.getTauxInteret();
Net_A_Payer = Facture.getNetAPayer();
TypeFacilite = Facture.getTypeFaciliteBoolean();
if(TypeFacilite == true){
TextTypeReglement.setText("Traite");
PaneTableViewCheques.setVisible(false);
PaneTableViewTraites.setVisible(true);
TextMontantTraite.setText("Montant Traite:");
ArrayList<TraiteClt> ListTraites = Facture.getListeTraites();
for(int i=0; i<ListTraites.size(); i++){
//data_List_Traite.add(new FactureCltTraiteList(ListTraites.get(i).getMontantTraiteClt(),new Date()));
dataListe.add(new FactureCltTraiteListe(ListTraites.get(i).getDateTraiteClt(),ListTraites.get(i).getMontantTraiteClt()+" "+ParametreSystem.CurrencySign ));
}
TableViewListeTraites.setItems(dataListe);
}else if(TypeFacilite == false){
Banque.setVisible(true);
TextTypeReglement.setText("Cheque");
PaneTableViewTraites.setVisible(false);
PaneTableViewCheques.setVisible(true);
TextMontantTraite.setText("Montant Chéques:");
ArrayList<ChequeClt> dataListCheque = Facture.getListeCheques();
TextBanque.setText( dataListCheque.get(0).getBanqueChequeClt());
for(int i=0; i<dataListCheque.size(); i++){
dataListeCheque.add(new FactureCltChequeListe( dataListCheque.get(i).getDatePaiement(),
dataListCheque.get(i).getNumeroChequeClt(),
dataListCheque.get(i).getBanqueChequeClt(),
dataListCheque.get(i).getMontantChequeClt()));
}
TableViewListeCheques.setItems(dataListeCheque);
}
}
//Boutton Présédent
@FXML
private void FactureCltAjouterLastButtonAction(ActionEvent event) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/FactureClt/FactureCltAjouterPaiementFacilite.fxml"));
Parent NodePaneFactureCltAjouterPaiementFacilite = (Parent)fxmlLoader.load();
FactureCltAjouterPaiementFaciliteController FactureCltAjouterPaiementFacilite = fxmlLoader.getController();
FactureCltAjouterPaiementFacilite.TextFieldAvance.setText(Avance);
FactureCltAjouterPaiementFacilite.TextFieldNbrTraite.setText(TextNbrTraite.getText());
FactureCltAjouterPaiementFacilite.TextFieldTauxIntere.setText(TextTauxInteret);
FactureCltAjouterPaiementFacilite.TextMontant_Traite.setVisible(true);
FactureCltAjouterPaiementFacilite.TextMontant_Interet.setVisible(true);
FactureCltAjouterPaiementFacilite.TextMontantTraite.setVisible(true);
FactureCltAjouterPaiementFacilite.TextMontantInteret.setVisible(true);
FactureCltAjouterPaiementFacilite.TextNetaPayer.setText(TextTauxInteret);
FactureCltAjouterPaiementFacilite.TextMontantTraite.setText(ValMontantTraite.getText());
FactureCltAjouterPaiementFacilite.TextMontantInteret.setText(TextMontantInteret.getText());
FactureCltAjouterPaiementFacilite.TextNetaPayer.setText(Net_A_Payer+" "+ParametreSystem.CurrencySign);
FactureCltAjouterPaiementFacilite.commande = commande;
if(TypeFacilite == true){
FactureCltAjouterPaiementFacilite.TypeSelect = true;
FactureCltAjouterPaiementFacilite.RadioTraite.setSelected(true);
FactureCltAjouterPaiementFacilite.dataList = data_List_Traite;
FactureCltAjouterPaiementFacilite.SetTableViewTraite();
}
else if(TypeFacilite == false){
FactureCltAjouterPaiementFacilite.TypeSelect = false;
FactureCltAjouterPaiementFacilite.RadioCheque.setSelected(true);
FactureCltAjouterPaiementFacilite.dataListCheque = data_List_Cheque;
FactureCltAjouterPaiementFacilite.SetTableViewCheque();
}
PaneFactureCltAjouterDetailTraite.getChildren().clear();
PaneFactureCltAjouterDetailTraite.getChildren().add(NodePaneFactureCltAjouterPaiementFacilite);
}
//Boutton Suivant
@FXML
private void FactureCltSaveButtonAction(ActionEvent event) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/FactureClt/FactureCltDetail.fxml"));
Parent NodeFactureCltDetail = (Parent)fxmlLoader.load();
FactureCltDetailController FactureCltDetail= fxmlLoader.getController();
FactureCltDB FactureDB= new FactureCltDB();
String CodeFacture = FactureDB.AddFactureClt(Facture);
FactureCltDetail.codeFactClt = CodeFacture;
FactureCltDetail.SowDetailFactureClt(true);
PaneFactureCltAjouterDetailTraite.getChildren().clear();
PaneFactureCltAjouterDetailTraite.getChildren().add(NodeFactureCltDetail);
}
}
@@ -0,0 +1,193 @@
package Controllers.FactureClt;
import Controllers.Traitement.ParametreSystem;
import Controllers.Traitement.contro;
import Models.Caisse.CarteBancaireClt;
import Models.CommandeClt.CommandeClt;
import Models.FactureClt.FactureClt;
import Models.FactureClt.FactureCltDB;
import Models.User.User;
import Models.ChequeClt.ChequeClt;
import java.io.IOException;
import java.net.URL;
import java.util.Date;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.control.DatePicker;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Text;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class FactureCltAjouterPaiementComptentController implements Initializable {
@FXML public Text TextNetaPayer ;
@FXML private AnchorPane PaneFactureCltAjouterPaiementComptent;
@FXML public AnchorPane PaneCheque;
@FXML public AnchorPane PaneCarte;
@FXML public TextField FactureCltChequeNomBanque;
@FXML public TextField FactureCltChequeNumero;
@FXML public TextField FactureCltChequeNomComple;
@FXML public DatePicker FactureCltChequeDatePaiement;
@FXML public Text MsgCltChequeNomBanque;
@FXML public Text MsgCltChequeNumero;
@FXML public Text MsgCltChequeNomComple;
@FXML public Text MsgCltChequeDatePaiement;
@FXML public TextField TextFieldCarteNumeroTransation;
@FXML public TextField TextFieldCarteNomBanque;
@FXML public TextField TextFieldCarteNumero;
@FXML public TextField TextFieldCarteNomComplet;
@FXML public Text MsgCltCarteNumeroTransation;
@FXML public Text MsgCltCarteNumeroCarte;
public Integer TypeSelect = 0; // 0:espace 1:Cheque 2:Carte Bancaire
public FactureClt Facture = new FactureClt();
public CommandeClt commande;
contro clt = new contro();
@Override
public void initialize(URL url, ResourceBundle rb) {
}
@FXML
public void RadioEspaceAction(ActionEvent event) throws IOException {
PaneCheque.setVisible(false);
PaneCarte.setVisible(false);
TypeSelect = 0;
}
@FXML
public void RadioChequeAction(ActionEvent event) throws IOException {
PaneCarte.setVisible(false);
PaneCheque.setVisible(true);
TypeSelect = 1;
}
@FXML
public void RadioCarteAction(ActionEvent event) throws IOException {
PaneCheque.setVisible(false);
PaneCarte.setVisible(true);
TypeSelect = 2;
}
//Boutton Suivant
@FXML
private void FactureCltAjouterSuivantAction(ActionEvent event) throws IOException {
this.SetDataFacture();
FactureCltDB FactureDB= new FactureCltDB();
if(TypeSelect == 0){
Facture.setModePaiement("0");
String CodeFacture = FactureDB.AddFactureClt(Facture);
if(CodeFacture != null){
this.FactureCltDetail(CodeFacture);
}
}else if(TypeSelect == 1){
Facture.setModePaiement("1");
if( clt.ContrNull(FactureCltChequeNomBanque, MsgCltChequeNomBanque) &&
clt.ContrNumeriqueNotnull(FactureCltChequeNumero, MsgCltChequeNumero) &&
clt.ContrNullDatePicker(FactureCltChequeDatePaiement, MsgCltChequeDatePaiement)){
ChequeClt Cheque = new ChequeClt();
Cheque.setBanqueChequeClt(FactureCltChequeNomBanque.getText());
Cheque.setNumeroChequeClt(FactureCltChequeNumero.getText());
Cheque.setNomCompletChequeClt(FactureCltChequeNomComple.getText());
Cheque.setDatePaiement(FactureCltChequeDatePaiement.getValue().toString());
Cheque.setMontantChequeClt(Facture.getNetAPayer());
Facture.setCheque(Cheque);
String CodeFacture = FactureDB.AddFactureClt(Facture);
if(CodeFacture != null){
this.FactureCltDetail(CodeFacture);
}
}
}else if(TypeSelect == 2){
Facture.setModePaiement("2");
if( clt.ContrNull(TextFieldCarteNumeroTransation, MsgCltCarteNumeroTransation) &&
clt.ContrNumerique(TextFieldCarteNumero, MsgCltCarteNumeroCarte) )
{
CarteBancaireClt CarteBancaire = new CarteBancaireClt();
CarteBancaire.setNumeroTransation(TextFieldCarteNumeroTransation.getText());
CarteBancaire.setNomBanque(TextFieldCarteNomBanque.getText());
CarteBancaire.setNumeroCarte(TextFieldCarteNumero.getText());
CarteBancaire.setNomComplet(TextFieldCarteNomComplet.getText());
CarteBancaire.setMontant(Facture.getNetAPayer());
CarteBancaire.setLocalNom(ParametreSystem.NomLocalPC);
CarteBancaire.setIdProfile(User.idprofile);
Facture.setCarteBancaire(CarteBancaire);
String CodeFacture = FactureDB.AddFactureClt(Facture);
if(CodeFacture != null){
this.FactureCltDetail(CodeFacture);
}
}
}
}
//Boutton Présédent
@FXML
private void FactureCltAjouterButtonAction(ActionEvent event) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/FactureClt/FactureCltAjouterDetailSelect.fxml"));
Parent NodeFactureCltAjouterDetailSelect = (Parent)fxmlLoader.load();
FactureCltAjouterDetailSelectController FactureCltAjouterDetailSelect = fxmlLoader.getController();
FactureCltAjouterDetailSelect.setDataCommande(commande.getCodecommandeclt());
PaneFactureCltAjouterPaiementComptent.getChildren().clear();
PaneFactureCltAjouterPaiementComptent.getChildren().add(NodeFactureCltAjouterDetailSelect);
}
public void FactureCltDetail(String CodeFacture) throws IOException{
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/FactureClt/FactureCltDetail.fxml"));
Parent NodeFactureCltDetail = (Parent)fxmlLoader.load();
FactureCltDetailController FactureCltDetail= fxmlLoader.getController();
FactureCltDetail.codeFactClt = CodeFacture;
FactureCltDetail.SowDetailFactureClt(true);
PaneFactureCltAjouterPaiementComptent.getChildren().clear();
PaneFactureCltAjouterPaiementComptent.getChildren().add(NodeFactureCltDetail);
}
public void SetDataFacture(){
Facture.setIdCommandeClt(commande.getCodecommandeclt());
Facture.setTypeClient(commande.getTypeClient());
if(commande.getTypeClient() == 0){
Facture.setCltPersonne(commande.getCltPersonne());
}else if(commande.getTypeClient() == 1){
Facture.setCltEntreprise(commande.getCltEntreprise());
}else if(commande.getTypeClient() == 2){
Facture.setCltPassager(commande.getCltPassager());
}
Facture.setDateFacture(new Date().toString());
Facture.setTypeRegement(commande.getTypeRegement());
Facture.setNetAPayer(commande.getNetAPayer());
Facture.setTotalTVA(commande.getTotalTVA());
Facture.setTotalHorsTaxNet(commande.getTotalHorsTaxNet());
Facture.setRemise(commande.getRemise());
Facture.setTimbre(commande.getTimbre());
Facture.setDevise(commande.getCodeDevis());
Facture.setCodeUser(User.idprofile);
Facture.setListeproduit(commande.getListeproduit());
}
}
@@ -0,0 +1,624 @@
/*
* 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.FactureClt;
import Controllers.Dialog.MessageControle;
import Controllers.Traitement.Adaptateur;
import Controllers.Traitement.ParametreSystem;
import Controllers.Traitement.contro;
import Models.CommandeClt.CommandeClt;
import Models.TraiteClt.DatePickerCell;
import Models.ChequeClt.DatePickerCellCheque;
import Models.FactureClt.FactureClt;
import Models.ChequeClt.ChequeList;
import Models.TraiteClt.TraiteList;
import Models.ChequeClt.ChequeClt;
import Models.TraiteClt.TraiteClt;
import java.io.IOException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.ResourceBundle;
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.RadioButton;
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.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;
/**
* FXML Controller class
*
* @author PC-Maher
*/
public class FactureCltAjouterPaiementFaciliteController implements Initializable {
@FXML private AnchorPane PaneFactureCltAjouterPaiementFacilite;
@FXML public AnchorPane PaneTableViewTraite ;
@FXML public AnchorPane PaneTableViewCheque;
@FXML public Text TextMontant_Traite;
@FXML public Text TextMontant_Interet;
@FXML public RadioButton RadioCheque;
@FXML public RadioButton RadioTraite;
@FXML public Text TextNetaPayer ;
@FXML public Text TextMontantTraite;
@FXML public Text TextMontantInteret;
@FXML public TextField TextFieldAvance;
@FXML public TextField TextFieldNbrTraite;
@FXML public TextField TextFieldTauxIntere;
@FXML public Text TextAvance;
@FXML public Text TextNbrTraite;
@FXML public Text TextTauxIntere;
@FXML public TableView<TraiteList> TableViewListeTraite ;
@FXML public TableColumn TabColDateTraite;
@FXML public TableColumn<TraiteList ,String> TabColMontantTraite;
@FXML public TableView<ChequeList> TableViewListeCheque ;
@FXML public TableColumn TabColDateCheque;
@FXML public TableColumn<ChequeList ,String> TabColNumeroCheque;
@FXML public TableColumn<ChequeList ,String> TabColBanqueCheque;
@FXML public TableColumn<ChequeList ,String> TabColMontantCheque;
public CommandeClt commande;
public FactureClt Facture ;
public boolean TypeSelect = true; // True Traite | False Cheque
float NetaPayer, TotalMontantTraite, MontantInteret, Avance, NbrTraite, TauxIntere;
public ObservableList<TraiteList> dataList = FXCollections.observableArrayList();
public ObservableList<ChequeList> dataListCheque = FXCollections.observableArrayList();
@Override
public void initialize(URL url, ResourceBundle rb) {
TableViewListeTraite.setEditable(true);
TabColMontantTraite.setStyle( "-fx-alignment: CENTER;");
TabColMontantTraite.getStyleClass().add("Center");
TabColMontantTraite.setCellValueFactory(new PropertyValueFactory<TraiteList, String>("MontantTraite"));
TabColMontantTraite.setCellFactory(TextFieldTableCell.<TraiteList>forTableColumn()); //Ajouter l'option textfield
//Valier l'opertion
TabColMontantTraite.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent<TraiteList, String>>() {
@Override
public void handle(TableColumn.CellEditEvent<TraiteList, String> t) {
String NewQuantite = t.getNewValue();
((TraiteList) t.getTableView().getItems().get(t.getTablePosition().getRow())).setMontantTraite(NewQuantite);
}
});
TabColDateTraite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDateTraite.getStyleClass().add("Center");
TabColDateTraite.setCellValueFactory(new PropertyValueFactory<TraiteList, Date>("date"));
TabColDateTraite.setEditable(true);
TabColDateTraite.setCellFactory(new Callback<TableColumn, TableCell>() {
@Override
public TableCell call(TableColumn p) {
DatePickerCell datePick = new DatePickerCell(dataList);
return datePick;
}
});
TableViewListeTraite.setItems(dataList);
//Cheque
TabColNumeroCheque.setStyle( "-fx-alignment: CENTER;");
TabColNumeroCheque.getStyleClass().add("Center");
TabColNumeroCheque.setCellValueFactory(new PropertyValueFactory<ChequeList, String>("NumeroCheque"));
TabColNumeroCheque.setCellFactory(TextFieldTableCell.<ChequeList>forTableColumn()); //Ajouter l'option textfield
//Valier l'opertion
TabColNumeroCheque.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent<ChequeList, String>>() {
@Override
public void handle(TableColumn.CellEditEvent<ChequeList, String> t) {
String NewNumeroCheque = t.getNewValue();
contro clt = new contro();
if(!clt.isNumeric(NewNumeroCheque)){
if(t.getTablePosition().getRow() == 0){
Integer NumeroCheque = Integer.valueOf(NewNumeroCheque);
int indise = 0;
while(indise<dataListCheque.size()){
((ChequeList) t.getTableView().getItems().get(indise)).setNumeroCheque(NumeroCheque.toString());
indise++;NumeroCheque++;
}
}else{
((ChequeList) t.getTableView().getItems().get(t.getTablePosition().getRow())).setNumeroCheque(NewNumeroCheque);
}
}else{
((ChequeList) t.getTableView().getItems().get(t.getTablePosition().getRow())).setNumeroCheque(null);
}
}
});
TabColBanqueCheque.setStyle( "-fx-alignment: CENTER;");
TabColBanqueCheque.getStyleClass().add("Center");
TabColBanqueCheque.setCellValueFactory(new PropertyValueFactory<ChequeList, String>("BanqueCheque"));
TabColBanqueCheque.setCellFactory(TextFieldTableCell.<ChequeList>forTableColumn()); //Ajouter l'option textfield
//Valier l'opertion
TabColBanqueCheque.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent<ChequeList, String>>() {
@Override
public void handle(TableColumn.CellEditEvent<ChequeList, String> t) {
String NewBanque = t.getNewValue();
if(t.getTablePosition().getRow() == 0){
int indise = 0;
while(indise<dataListCheque.size()){
((ChequeList) t.getTableView().getItems().get(indise)).setBanqueCheque(NewBanque);
indise++;
}
}else{
((ChequeList) t.getTableView().getItems().get(t.getTablePosition().getRow())).setBanqueCheque(NewBanque);
}
}
});
TabColMontantCheque.setStyle( "-fx-alignment: CENTER;");
TabColMontantCheque.getStyleClass().add("Center");
TabColMontantCheque.setCellValueFactory(new PropertyValueFactory<ChequeList, String>("MontantCheque"));
TabColMontantCheque.setCellFactory(TextFieldTableCell.<ChequeList>forTableColumn()); //Ajouter l'option textfield
//Valier l'opertion
TabColMontantCheque.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent<ChequeList, String>>() {
@Override
public void handle(TableColumn.CellEditEvent<ChequeList, String> t) {
String NewQuantite = t.getNewValue();
((ChequeList) t.getTableView().getItems().get(t.getTablePosition().getRow())).setMontantCheque(NewQuantite);
}
});
TabColDateCheque.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDateCheque.getStyleClass().add("Center");
TabColDateCheque.setCellValueFactory(new PropertyValueFactory<ChequeList, Date>("date"));
TabColDateCheque.setEditable(true);
TabColDateCheque.setCellFactory(new Callback<TableColumn, TableCell>() {
@Override
public TableCell call(TableColumn p) {
DatePickerCellCheque datePick = new DatePickerCellCheque(dataListCheque);
return datePick;
}
});
TableViewListeCheque.setItems(dataListCheque);
}
private void CalculeTraite(){
dataList.clear();
PaneTableViewCheque.setVisible(false);
PaneTableViewTraite.setVisible(true);
NbrTraite = Adaptateur.StringToFloat(TextFieldNbrTraite.getText());
TauxIntere = Adaptateur.StringToFloat(TextFieldTauxIntere.getText());
MontantInteret = ((NetaPayer - Avance) * TauxIntere) / 100 ;
TotalMontantTraite = (NetaPayer - Avance) + MontantInteret ;
TextMontantInteret.setText(Adaptateur.ArrondFloatToString(MontantInteret)+" "+ParametreSystem.CurrencySign);
TextMontantTraite.setText(Adaptateur.ArrondFloatToString(TotalMontantTraite)+" "+ParametreSystem.CurrencySign);
Integer divTotal = Adaptateur.Diviseur(TotalMontantTraite);
float modeTotal = Adaptateur.Modulo(TotalMontantTraite);
float Value = (float) TotalMontantTraite / NbrTraite;
Integer div = Adaptateur.Diviseur(Value);
Date date= new Date();
Calendar cal = Calendar.getInstance();
Integer Somme = 0;
for(int i=0; i<NbrTraite; i++){
cal.setTime(date);
cal.add(Calendar.MONTH, i+1);
if(i != NbrTraite-1){
Somme = Somme + div ;
dataList.add(new TraiteList(Adaptateur.floatDeleZero(div), cal.getTime()));
}else{
dataList.add(new TraiteList(Adaptateur.floatDeleZero((divTotal - Somme) + modeTotal) , cal.getTime()));
}
}
TextMontantInteret.setVisible(true);
TextMontantTraite.setVisible(true);
TextMontant_Traite.setVisible(true);
TextMontant_Interet.setVisible(true);
}
private void CalculeCheque(){
dataListCheque.clear();
PaneTableViewTraite.setVisible(false);
PaneTableViewCheque.setVisible(true);
NbrTraite = Adaptateur.StringToFloat(TextFieldNbrTraite.getText());
TauxIntere = Adaptateur.StringToFloat(TextFieldTauxIntere.getText());
MontantInteret = ((NetaPayer - Avance) * TauxIntere) / 100 ;
TotalMontantTraite = (NetaPayer - Avance) + MontantInteret ;
TextMontantInteret.setText(Adaptateur.ArrondFloatToString(MontantInteret)+" "+ParametreSystem.CurrencySign);
TextMontantTraite.setText(Adaptateur.ArrondFloatToString(TotalMontantTraite)+" "+ParametreSystem.CurrencySign);
Integer divTotal = Adaptateur.Diviseur(TotalMontantTraite);
float modeTotal = Adaptateur.Modulo(TotalMontantTraite);
float Value = (float) TotalMontantTraite / NbrTraite;
Integer div = Adaptateur.Diviseur(Value);
Date date= new Date();
Calendar cal = Calendar.getInstance();
Integer Somme = 0;
for(int i=0; i<NbrTraite; i++){
cal.setTime(date);
cal.add(Calendar.MONTH, i+1);
if(i != NbrTraite-1){
Somme = Somme + div ;
dataListCheque.add(new ChequeList(cal.getTime(),"","",Adaptateur.floatDeleZero(div)));
}else{
dataListCheque.add(new ChequeList(cal.getTime(),"","",Adaptateur.floatDeleZero((divTotal - Somme) + modeTotal)));
}
}
TextMontantInteret.setVisible(true);
TextMontantTraite.setVisible(true);
TextMontant_Traite.setVisible(true);
TextMontant_Interet.setVisible(true);
}
//Suivant
@FXML
private void FactureCltAjouterSuivantButtonAction(ActionEvent event) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/FactureClt/FactureCltAjouterDetailTraite.fxml"));
Parent NodeDetailTraite = (Parent)fxmlLoader.load();
FactureCltAjouterDetailTraiteController FactureCltAjouterDetailTraite = fxmlLoader.getController();
if(commande.getTypeClient()==0){
FactureCltAjouterDetailTraite.TextNom.setText(commande.CltPersonne.getNom());
FactureCltAjouterDetailTraite.TextPrenom.setText(commande.CltPersonne.getPrenom());
FactureCltAjouterDetailTraite.TextAdress.setText(commande.CltPersonne.getAdresse());
}else if(commande.getTypeClient()==1){
FactureCltAjouterDetailTraite.TextNom.setText(commande.CltEntreprise.getNom());
FactureCltAjouterDetailTraite.TextPrenom.setText(commande.CltEntreprise.getMatricule());
FactureCltAjouterDetailTraite.TextAdress.setText(commande.CltEntreprise.getAdresse());
FactureCltAjouterDetailTraite.TextPrenomMatricule.setText("Matricule");
FactureCltAjouterDetailTraite.TextPrenom.setText(commande.CltEntreprise.getMatricule());
}else if(commande.getTypeClient()==2){
FactureCltAjouterDetailTraite.TextNom.setText(commande.CltPassager.getNom());
FactureCltAjouterDetailTraite.TextPrenom.setText(commande.CltPassager.getPrenom());
FactureCltAjouterDetailTraite.TextAdress.setText(commande.CltPassager.getAdresse());
}
if(TypeSelect == true){
if(this.ControleListTraite()){
SetDataFactureClt(true);
PaneFactureCltAjouterPaiementFacilite.getChildren().clear();
PaneFactureCltAjouterPaiementFacilite.getChildren().add(NodeDetailTraite);
FactureCltAjouterDetailTraite.data_List_Traite = dataList;
FactureCltAjouterDetailTraite.SetDataTraiteFacilite(Facture);
}
}else{
if(this.ControleListCheque()){
SetDataFactureClt(false);
PaneFactureCltAjouterPaiementFacilite.getChildren().clear();
PaneFactureCltAjouterPaiementFacilite.getChildren().add(NodeDetailTraite);
FactureCltAjouterDetailTraite.data_List_Cheque = dataListCheque;
FactureCltAjouterDetailTraite.SetDataTraiteFacilite(Facture);
}
}
}
private void SetDataFactureClt(boolean type_reglement){
Facture.setAvance(TextFieldAvance.getText());
Facture.setTotalMontantTraite(Adaptateur.ArrondFloatToString(TotalMontantTraite));
Facture.setNbrTraite(TextFieldNbrTraite.getText());
Facture.setMontantInteret(Adaptateur.ArrondFloatToString(MontantInteret));
Facture.setTauxInteret(TextFieldTauxIntere.getText());
Facture.setTypeRegement(commande.getTypeRegement());
if(commande.getTypeClient() == 0){
Facture.setCltPersonne(commande.getCltPersonne());
}else if(commande.getTypeClient() == 1){
Facture.setCltEntreprise(commande.getCltEntreprise());
}else if(commande.getTypeClient() == 2){
Facture.setCltPassager(commande.getCltPassager());
}
Facture.setListeproduit(commande.getListeproduit());
if(type_reglement == true){
Facture.setTypeFacilite("0");
ArrayList<TraiteClt> ListTraites = new ArrayList();
for(int i=0; i<dataList.size(); i++){
TraiteClt Traite = new TraiteClt();
Traite.setDateCreationTraiteClt(new Date().toString());
String DateTraite = new SimpleDateFormat("dd/MM/yyyy").format(dataList.get(i).getDate());
Traite.setDateTraiteClt(DateTraite);
Traite.setMontantTraiteClt(dataList.get(i).getMontantTraite());
ListTraites.add(Traite);
}
Facture.setListeTraites(ListTraites);
}else if(type_reglement == false){
Facture.setTypeFacilite("1");
ArrayList<ChequeClt> ListCheque = new ArrayList();
for(int i=0; i<dataListCheque.size(); i++){
ChequeClt Cheque = new ChequeClt();
Cheque.setNumeroChequeClt(dataListCheque.get(i).getNumeroCheque());
Cheque.setBanqueChequeClt(dataListCheque.get(i).getBanqueCheque());
Cheque.setMontantChequeClt(dataListCheque.get(i).getMontantCheque());
String DateChequePaiement = new SimpleDateFormat("yyyy-MM-dd").format(dataListCheque.get(i).getDate());
Cheque.setDatePaiement(DateChequePaiement);
Cheque.setDateCreation(new Date().toString());
ListCheque.add(Cheque);
}
Facture.setListeCheques(ListCheque);
}
}
//Boutton Traitement
@FXML
private void FactureCltAjouterTraitementButtonAction(ActionEvent event) throws IOException {
if(this.Controle()){
if(TypeSelect == true){
this.CalculeTraite();
}else{
this.CalculeCheque();
}
}
}
//Radio Cheque
@FXML
private void FactureCltAjouterChequeButtonAction(ActionEvent event) throws IOException {
TypeSelect = false;
TextMontant_Traite.setVisible(false);TextMontant_Interet.setVisible(false);
PaneTableViewTraite.setVisible(false);PaneTableViewCheque.setVisible(false);
TextMontantInteret.setVisible(false);TextMontantTraite.setVisible(false);
if(this.Controle()){
this.CalculeCheque();
}
}
//Radio Traite
@FXML
private void FactureCltAjouterTraiteButtonAction(ActionEvent event) throws IOException {
TypeSelect = true;
TextMontant_Traite.setVisible(false);TextMontant_Interet.setVisible(false);
PaneTableViewTraite.setVisible(false);PaneTableViewCheque.setVisible(false);
TextMontantInteret.setVisible(false);TextMontantTraite.setVisible(false);
if(this.Controle()){
this.CalculeTraite();
}
}
//Boutton Présédent
@FXML
private void FactureCltAjouterButtonAction(ActionEvent event) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/FactureClt/FactureCltAjouterDetailSelect.fxml"));
Parent NodeFactureCltAjouterDetailSelect = (Parent)fxmlLoader.load();
FactureCltAjouterDetailSelectController FactureCltAjouterDetailSelect = fxmlLoader.getController();
FactureCltAjouterDetailSelect.setDataCommande(commande.getCodecommandeclt());
PaneFactureCltAjouterPaiementFacilite.getChildren().clear();
PaneFactureCltAjouterPaiementFacilite.getChildren().add(NodeFactureCltAjouterDetailSelect);
}
public void SetTableViewTraite(){
PaneTableViewTraite.setVisible(true);
TableViewListeTraite.setItems(dataList);
}
public void SetTableViewCheque(){
PaneTableViewCheque.setVisible(true);
TableViewListeCheque.setItems(dataListCheque);
}
private Boolean ControleListTraite(){
boolean Resulta = true;
boolean MontantTraite = true;
int indise = 0;
float Somme = 0;
while(indise<dataList.size()){
if(dataList.get(indise).getMontantTraite().equals("0")){
MontantTraite = false;
}
Somme = Somme + Adaptateur.ArrondStringToFloat(dataList.get(indise).getMontantTraite());
indise++;
}
if(!MontantTraite){
final MessageControle messagecontrol = new MessageControle();
Text text3 = new Text();
text3.setText("Le montant des traites doit être différent de zéro (0)");
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();
Resulta = false;
}
else if(Adaptateur.ArrondFloatToFloat(Somme) != Adaptateur.ArrondFloatToFloat(TotalMontantTraite)){
final MessageControle messagecontrol = new MessageControle();
Text text3 = new Text();
text3.setText("La sommes des traites est différent à la montant de TotalMontantTraite");
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();
Resulta = false;
}
return Resulta;
}
private Boolean ControleListCheque(){
boolean Resulta = true;
boolean NumeroCheque = true;
boolean MontantCheque = true;
boolean Banque = true;
int indise = 0;
float Somme = 0;
contro clt = new contro();
while(indise<dataListCheque.size()){
if(!clt.isNumericNotnull(dataListCheque.get(indise).getNumeroCheque())){
NumeroCheque = false;
}
if(dataListCheque.get(indise).getBanqueCheque().isEmpty()){
Banque = false;
}
if(dataListCheque.get(indise).getMontantCheque().equals("0") || dataListCheque.get(indise).getNumeroCheque().isEmpty()){
MontantCheque = false;
}
Somme = Somme + Adaptateur.ArrondStringToFloat(dataListCheque.get(indise).getMontantCheque());
indise++;
}
System.out.println(Adaptateur.ArrondFloatToFloat(Somme));
System.out.println(Adaptateur.ArrondFloatToFloat(TotalMontantTraite));
if(NumeroCheque){
final MessageControle messagecontrol = new MessageControle();
Text text3 = new Text();
text3.setText("Incorrect Numéro Chéque");
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();
Resulta = false;
}
else if(!Banque){
final MessageControle messagecontrol = new MessageControle();
Text text3 = new Text();
text3.setText("Le nom de la banque est vide");
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();
Resulta = false;
}
else if(!MontantCheque){
final MessageControle messagecontrol = new MessageControle();
Text text3 = new Text();
text3.setText("Incorrect montant chéque");
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();
Resulta = false;
}
else if(Adaptateur.ArrondFloatToFloat(Somme) != Adaptateur.ArrondFloatToFloat(TotalMontantTraite)){
final MessageControle messagecontrol = new MessageControle();
Text text3 = new Text();
text3.setText("La sommes des chéques est différent à la montant de TotalMontantTraite");
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();
Resulta = false;
}
return Resulta;
}
private Boolean Controle(){
contro clt = new contro();
if(clt.ContrNumeriqueNotnull(TextFieldAvance, TextAvance) &&
clt.ContrNumeriqueNotnull(TextFieldNbrTraite, TextNbrTraite) &&
clt.ContrNumeriqueNotnull(TextFieldTauxIntere, TextTauxIntere)){
NetaPayer = Adaptateur.StringToFloat(commande.getNetAPayer());
Avance = Adaptateur.StringToFloat(TextFieldAvance.getText());
if(NetaPayer< Avance){
TextFieldAvance.setStyle("-fx-border-color:#f20606;");
TextAvance.setText("doit être inférieur a Net A payer");
return false ;
}else if(Adaptateur.StringToFloat(TextFieldNbrTraite.getText())<= 0){
TextFieldNbrTraite.setStyle("-fx-border-color:#f20606;");
TextNbrTraite.setText("doit être supérieur a 0");
return false ;
}else{
TextAvance.setText("");
TextFieldAvance.setStyle("-fx-border-color: transparent;");
return true;
}
}
else{
return false;
}
}
}
@@ -0,0 +1,363 @@
package Controllers.FactureClt;
import Controllers.TraiteClt.TraiteCltPrintController;
import Controllers.Traitement.Adaptateur;
import Models.Produit.ListeProduit;
import Models.FactureClt.FactureClt;
import Models.FactureClt.FactureCltChequeListe;
import Models.FactureClt.FactureCltDB;
import Models.FactureClt.FactureCltTraiteListe;
import Models.ChequeClt.ChequeClt;
import Models.TraiteClt.TraiteClt;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URL;
import java.util.ArrayList;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
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.print.JobSettings;
import javafx.print.PageLayout;
import javafx.print.PageOrientation;
import javafx.print.PageRange;
import javafx.print.Paper;
import javafx.print.Printer;
import javafx.print.PrinterJob;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.control.Button;
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.text.Text;
/**
* FXML Controller class
* @author PC-Maher
*/
public class FactureCltDetailController implements Initializable{
@FXML public AnchorPane PaneSucces;
@FXML public AnchorPane AnchorPaneLoading;
@FXML public AnchorPane AnchorPaneDetailFactureClt;
@FXML private Text DateCreation;
@FXML private Text Reglement;
@FXML private Text NetAPayer;
@FXML private Text TotalHorsTaxNet;
@FXML private Text TotalTVA;
@FXML private Text CodeFactClt;
@FXML private Text TypeClt;
@FXML private Text Nom;
@FXML private Text Prenom;
@FXML private Text Adresse;
@FXML private Text TELE1;
@FXML private Text TELE2;
@FXML private Text TextPrenom ;
@FXML private Text TextMatricule ;
@FXML private Text TextMontant;
@FXML private Text ValMontant;
@FXML private TableView<ListeProduit> TableViewListeProduit ;
@FXML private TableColumn<ListeProduit ,String> TabColReference;
@FXML private TableColumn<ListeProduit ,String> TabColDesignation;
@FXML private TableColumn<ListeProduit ,String> TabColQuantite ;
@FXML private TableColumn<ListeProduit ,String> TabColPrixHT;
@FXML private TableColumn<ListeProduit ,String> TabColRemise;
@FXML private TableColumn<ListeProduit ,String> TabColTotalHT;
@FXML private TableColumn<ListeProduit ,String> TabColTVA;
@FXML private TableColumn<ListeProduit ,String> TabColTotalTTC;
@FXML private TableView<FactureCltTraiteListe> TableViewListeTraites ;
@FXML private TableColumn<FactureCltTraiteListe ,String> TabColDateTraites;
@FXML private TableColumn<FactureCltTraiteListe ,String> TabColMontantTraites;
@FXML private TableView<FactureCltChequeListe> TableViewListeCheques ;
@FXML private TableColumn<FactureCltChequeListe ,String> TabColDateCheques;
@FXML private TableColumn<FactureCltChequeListe ,String> TabColNumeroCheques;
@FXML private TableColumn<FactureCltChequeListe ,String> TabColBanqueCheques;
@FXML private TableColumn<FactureCltChequeListe ,String> TabColMontantCheques;
@FXML public Button ButtonImprimerTraite;
@FXML private Tab TabTypeRegement;
private Service<Void> ThreadFactureCltDetail;
FactureClt factureClt;
public String codeFactClt;
public boolean NewFacture;
@Override
public void initialize(URL url, ResourceBundle rb) {
TableViewListeProduit.setEditable(false);
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");
TabColDateTraites.setStyle( "-fx-alignment: CENTER;");
TabColDateTraites.getStyleClass().add("Center");
TabColDateTraites.setCellValueFactory(new PropertyValueFactory<FactureCltTraiteListe, String>("DateTraites"));
TabColMontantTraites.setStyle( "-fx-alignment: CENTER;");
TabColMontantTraites.getStyleClass().add("Center");
TabColMontantTraites.setCellValueFactory(new PropertyValueFactory<FactureCltTraiteListe, String>("MontantTraites"));
TabColDateCheques.setStyle( "-fx-alignment: CENTER;");
TabColDateCheques.getStyleClass().add("Center");
TabColDateCheques.setCellValueFactory(new PropertyValueFactory<FactureCltChequeListe, String>("DateCheques"));
TabColNumeroCheques.setStyle( "-fx-alignment: CENTER;");
TabColNumeroCheques.getStyleClass().add("Center");
TabColNumeroCheques.setCellValueFactory(new PropertyValueFactory<FactureCltChequeListe, String>("NumeroCheques"));
TabColBanqueCheques.setStyle( "-fx-alignment: CENTER;");
TabColBanqueCheques.getStyleClass().add("Center");
TabColBanqueCheques.setCellValueFactory(new PropertyValueFactory<FactureCltChequeListe, String>("BanqueCheques"));
TabColMontantCheques.setStyle( "-fx-alignment: CENTER;");
TabColMontantCheques.getStyleClass().add("Center");
TabColMontantCheques.setCellValueFactory(new PropertyValueFactory<FactureCltChequeListe, String>("MontantCheques"));
ButtonPrintTraite();
}
@FXML
private void FactureCltPrintButtonAction(ActionEvent event) throws IOException {
PrinterJob jobPrint = PrinterJob.createPrinterJob();
try {
jobPrint.getJobSettings().setPageRanges(new PageRange(1, 1));
if (jobPrint.showPrintDialog(null)) {
FXMLLoader fxmlLoaderPrintFactureClt = new FXMLLoader(getClass().getResource("/Views/FactureClt/FactureCltPrint.fxml"));
final Node ParentFxmlPrintFactureClt = (Node)fxmlLoaderPrintFactureClt.load();
FactureCltPrintController PrintFactureClt = fxmlLoaderPrintFactureClt.getController();
if(NewFacture){
PrintFactureClt.setFactureClt(factureClt, false);
}else{
PrintFactureClt.setFactureClt(factureClt, true);
}
jobPrint.printPage(ParentFxmlPrintFactureClt);
jobPrint.endJob();
}
} catch (IOException ex) {
System.err.println("Erreur dans: Controllers.FactureClt.FactureCltDetailController.FactureCltPrintButtonAction ");
System.err.println(ex.getMessage());
}
}
public void SowDetailFactureClt(boolean newFacture)
{
ThreadFactureCltDetail = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
NewFacture = newFacture;
FactureCltDB factureCltDB = new FactureCltDB();
factureClt = factureCltDB.getFactureClt(codeFactClt);
return null;
}
};
}
};
ThreadFactureCltDetail.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
CodeFactClt.setText(factureClt.getCodeFactureClt());
DateCreation.setText(Adaptateur.NormalDateFormat(factureClt.getDateFacture()));
Reglement.setText(factureClt.getTypeRegementString());
TotalHorsTaxNet.setText(Adaptateur.StringToStringEspaceCurrency(factureClt.getTotalHorsTaxNet()));
TotalTVA.setText(Adaptateur.StringToStringEspaceCurrency(factureClt.getTotalTVA()));
TypeClt.setText(factureClt.getTypeClientString());
NetAPayer.setText(Adaptateur.StringToStringEspaceCurrency(factureClt.getNetAPayer()));
if(factureClt.getTypeClient()==0 ){
TextPrenom.setVisible(true);
TextMatricule.setVisible(false);
Nom.setText(factureClt.CltPersonne.getNom());
Prenom.setText(factureClt.CltPersonne.getPrenom());
Adresse.setText(factureClt.CltPersonne.getAdresse());
TELE1.setText(factureClt.CltPersonne.getTelemobileString());
TELE2.setText(factureClt.CltPersonne.getTelefixString());
}
if(factureClt.getTypeClient()==1){
TextPrenom.setVisible(false);
TextMatricule.setVisible(true);
Nom.setText(factureClt.CltEntreprise.getNom());
Prenom.setText(factureClt.CltEntreprise.getMatricule());
Adresse.setText(factureClt.CltEntreprise.getAdresse());
TELE1.setText(factureClt.CltEntreprise.getTele1String());
TELE2.setText(factureClt.CltEntreprise.getTele2String());
}
if(factureClt.getTypeClient()==2 ){
TextPrenom.setVisible(true);
TextMatricule.setVisible(false);
Nom.setText(factureClt.CltPassager.getNom());
Prenom.setText(factureClt.CltPassager.getPrenom());
Adresse.setText(factureClt.CltPassager.getAdresse());
TELE1.setText(factureClt.CltPassager.getTelefixString());
TELE2.setText(factureClt.CltPassager.getTelemobileString());
}
TableViewListeProduit.setItems(factureClt.getListeproduit());
if(factureClt.getTypeRegementInteger() == 1)
{
ValMontant.setText(Adaptateur.StringToStringEspaceCurrency(factureClt.getTotalMontantTraite()));
TabTypeRegement.setClosable(false);
TabTypeRegement.setDisable(false);
if(factureClt.getTypeFaciliteBoolean()){ //true Traite | false Cheque
TabTypeRegement.setText("Liste des traites");
TextMontant.setText("Total Montant Traites:");
TableViewListeTraites.setVisible(true);
//ButtonImprimerTraite.setVisible(true);
ObservableList<FactureCltTraiteListe> dataListe = FXCollections.observableArrayList();
ArrayList<TraiteClt> ListTraites = factureClt.getListeTraites();
for(int i=0; i<ListTraites.size(); i++)
{
dataListe.add(new FactureCltTraiteListe(ListTraites.get(i).getDateTraiteClt(), Adaptateur.StringToStringEspaceCurrency(ListTraites.get(i).getMontantTraiteClt()) ));
}
TableViewListeTraites.setItems(dataListe);
}else{
TextMontant.setText("Total Montant Cheques:");
TableViewListeCheques.setVisible(true);
TabTypeRegement.setText("Liste des Chéques");
ArrayList<ChequeClt> dataListCheque = factureClt.getListeCheques();
ObservableList<FactureCltChequeListe> dataListeCheque = FXCollections.observableArrayList();
for(int i=0; i<dataListCheque.size(); i++){
dataListeCheque.add(new FactureCltChequeListe(dataListCheque.get(i).getDatePaiement(),dataListCheque.get(i).getNumeroChequeClt(),dataListCheque.get(i).getBanqueChequeClt(),dataListCheque.get(i).getMontantChequeClt()));
}
TableViewListeCheques.setItems(dataListeCheque);
}
}
AnchorPaneLoading.setVisible(false);
AnchorPaneDetailFactureClt.setVisible(true);
}
});
ThreadFactureCltDetail.start();
}
public void ButtonPrintTraite()
{
ButtonImprimerTraite.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
ArrayList<TraiteClt> ListTraites = factureClt.getListeTraites();
String strCIN= "";
String strNomComplet = "";
if(factureClt.getTypeClient() == 0){
strCIN = factureClt.getCltPersonne().getCinString();
strNomComplet = factureClt.getCltPersonne().getNomcomplet();
}else if(factureClt.getTypeClient() == 1){
strCIN = factureClt.getCltEntreprise().getMatricule();
strNomComplet = factureClt.getCltEntreprise().getNom();
}
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/TraiteClt/TraiteCltPrint.fxml"));
try {
Parent FxmlPrintTraite = (Parent)fxmlLoader.load();
TraiteCltPrintController TraiteCltPrint = fxmlLoader.getController();
PrinterJob jobPrint = PrinterJob.createPrinterJob();
Printer printer = Printer.getDefaultPrinter();
PageLayout pageLayout = printer.createPageLayout(Paper.NA_LETTER,PageOrientation.PORTRAIT, 0, 0, 0, 0);
JobSettings jobSettings = jobPrint.getJobSettings();
jobSettings.setPageLayout(pageLayout);
jobPrint.getJobSettings().setPageRanges(new PageRange(1, ListTraites.size()));
if (jobPrint.showPrintDialog(null))
{
for(int i=0; i<ListTraites.size(); i++)
{
TraiteCltPrint.SetData(Adaptateur.ChiffreToLettre(new BigDecimal(ListTraites.get(i).getMontantTraiteClt())),
Adaptateur.StringToStringEspaceCurrency(ListTraites.get(i).getMontantTraiteClt()),
ListTraites.get(i).getDateTraiteClt(),
strNomComplet,
strCIN);
jobPrint.printPage(FxmlPrintTraite);
}
}
jobPrint.endJob();
} catch (IOException ex) {
Logger.getLogger(FactureCltDetailController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
}
@@ -0,0 +1,186 @@
/*
* 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.FactureClt;
import Controllers.CommandeClt.*;
import Models.Produit.ListeProduit;
import Controllers.Traitement.MyWindow;
import Models.CommandeClt.CommandeClt;
import Models.FactureClt.FactureClt;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;
/**
*
* @author PC-Maher
*/
public class FactureCltDialogConfirmationController implements Initializable {
/**
* Initializes the controller class.
*/
public Node nodeFxml ;
@FXML public AnchorPane AnchorPrincipal ;
@FXML public Button Enregister ;
@FXML private Text DateCreation;
@FXML private Text Reglement;
@FXML private Text NetAPayer;
@FXML private Text TotalHorsTaxNet;
@FXML private Text TotalTVA;
@FXML private Text TypeClt;
@FXML private Text Nom;
@FXML private Text Prenom;
@FXML private Text Adresse;
@FXML private Text TELE1;
@FXML private Text TELE2;
@FXML private Text TextPrenom ;
@FXML private Text TextMatricule ;
@FXML public TableView<ListeProduit> TableViewListeProduitPassCommClt ;
@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> TabColRemise;
@FXML public TableColumn<ListeProduit ,String> TabColTotalHT;
@FXML public TableColumn<ListeProduit ,String> TabColTVA;
@FXML public TableColumn<ListeProduit ,String> TabColTotalTTC;
@Override
public void initialize(URL url, ResourceBundle rb) {
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");
Image coffeeImage = new Image(getClass().getResourceAsStream("/Public/icon/iconsave.png"));
ImageView buttonGraphic = new ImageView();
buttonGraphic.setImage(coffeeImage);
Enregister.setGraphic(buttonGraphic);
}
public void GetFactureClt(FactureClt factureclt){
DateCreation.setText(factureclt.getDateFacture());
Reglement.setText(factureclt.getTypeRegement());
NetAPayer.setText(factureclt.getNetAPayer());
TotalHorsTaxNet.setText(factureclt.getTotalHorsTaxNet());
TotalTVA.setText(factureclt.getTotalTVA());
TypeClt.setText(factureclt.getTypeClientString());
/*
if(FactureCltAjouterController.TypeClient == 0){
TextPrenom.setVisible(true);
TextMatricule.setVisible(false);
Nom.setText(factureclt.CltPersonne.getNom());
Prenom.setText(factureclt.CltPersonne.getPrenom());
Adresse.setText(factureclt.CltPersonne.getAdresse());
TELE1.setText(factureclt.CltPersonne.getTelefixString());
TELE2.setText(factureclt.CltPersonne.getTelemobileString());
}
else if(FactureCltAjouterController.TypeClient == 1){
TextPrenom.setVisible(false);
TextMatricule.setVisible(true);
Prenom.setText(factureclt.CltEntreprise.getMatricule());
Adresse.setText(factureclt.CltEntreprise.getAdresse());
TELE1.setText(factureclt.CltEntreprise.getTele1().toString());
TELE2.setText(factureclt.CltEntreprise.getTele2().toString());
}
else if(FactureCltAjouterController.TypeClient == 2){
TextPrenom.setVisible(true);
TextMatricule.setVisible(false);
Nom.setText(factureclt.CltPassager.getNom());
Prenom.setText(factureclt.CltPassager.getPrenom());
Adresse.setText(factureclt.CltPassager.getAdresse());
TELE1.setText(factureclt.CltPassager.getTelefix().toString());
TELE2.setText(factureclt.CltPassager.getTelemobile().toString());
}
*/
TableViewListeProduitPassCommClt.setItems(factureclt.getListeproduit());
}
public FactureCltDialogConfirmationController(){
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/FactureClt/FactureCltDialogConfirmation.fxml"));
fxmlLoader.setController(this);
nodeFxml = (Node) fxmlLoader.load();
} catch (IOException ex) {
Logger.getLogger(FactureCltDialogConfirmationController.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void Show()
{
StackPane Sp = new StackPane();
Scene scene = new Scene(Sp);
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(nodeFxml);
Stage stage = MyWindow.myStage;
stage.setScene(scene);
stage.show();
}
@FXML
private void ExitButtonAction(ActionEvent event) throws IOException {
AnchorPrincipal.setVisible(false);
}
}
@@ -0,0 +1,454 @@
package Controllers.FactureClt;
import Models.FactureClt.FactureCltDB;
import javafx.collections.FXCollections;
import Models.FactureClt.FactureCltGestionList;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
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.RadioButton;
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.KeyCode;
import javafx.scene.input.KeyEvent;
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;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class FactureCltGestionController implements Initializable {
@FXML private AnchorPane PaneFactureGestion ;
@FXML private ProgressBar ProgressBarFactureClt;
@FXML private Button ButtonSearchFactureClt;
@FXML public TableView<FactureCltGestionList> TableViewFactureCltListGestion;
@FXML public TableColumn<FactureCltGestionList ,String> TabColCodeFacture;
@FXML public TableColumn<FactureCltGestionList ,String> TabColTypeClient;
@FXML public TableColumn<FactureCltGestionList ,String> TabColCodeClient;
@FXML public TableColumn<FactureCltGestionList ,String> TabColMode ;
@FXML public TableColumn<FactureCltGestionList ,String> TabColTotal;
@FXML public TableColumn<FactureCltGestionList ,String> TabColCodeCommande;
@FXML public TableColumn<FactureCltGestionList ,String> TabColCreation;
@FXML public TableColumn<FactureCltGestionList ,Boolean>TabColDetail ;
@FXML public TextField TextFieldCodeFacture ;
@FXML public TextField TextFieldCodeClient ;
@FXML public TextField TextFieldCodeCommande ;
@FXML public DatePicker PickerDateCreation;
@FXML public RadioButton RadioComptant;
@FXML public RadioButton RadioFacilite;
@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> ThreadSearchFactureClt;
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;
@Override
public void initialize(URL url, ResourceBundle rb) {
//comboboxnombre des lignes tableview
NbrLigne.setItems(cursors);
NbrLigne.getSelectionModel().selectFirst();
TableViewFactureCltListGestion.setEditable(true);
TabColCodeFacture.setStyle( "-fx-alignment: CENTER;");TabColCodeFacture.getStyleClass().add("Center");
TabColCodeFacture.setCellValueFactory(new PropertyValueFactory<FactureCltGestionList, String>("CodeFacture"));
TabColTypeClient.setStyle( "-fx-alignment: CENTER;");TabColTypeClient.getStyleClass().add("Center");
TabColTypeClient.setCellValueFactory(new PropertyValueFactory<FactureCltGestionList, String>("TypeClient"));
TabColCodeClient.setStyle( "-fx-alignment: CENTER;");TabColCodeClient.getStyleClass().add("Center");
TabColCodeClient.setCellValueFactory(new PropertyValueFactory<FactureCltGestionList, String>("CodeClient"));
TabColMode.setStyle( "-fx-alignment: CENTER;");TabColMode.getStyleClass().add("Center");
TabColMode.setCellValueFactory(new PropertyValueFactory<FactureCltGestionList, String>("Mode"));
TabColMode.setCellFactory(new Callback<TableColumn<FactureCltGestionList,String>,TableCell<FactureCltGestionList,String>>(){
@Override
public TableCell<FactureCltGestionList, String> call(TableColumn<FactureCltGestionList, String> param) {
TableCell<FactureCltGestionList, String> cell = new TableCell<FactureCltGestionList, String>(){
@Override
public void updateItem(String item, boolean empty) {
if(item!= null && item.equals("Comptant")){
Text text = new Text(item);
text.setFill(Color.web("#428BCA"));
text.setFont(Font.font("Arial", FontWeight.BOLD, 14));
setGraphic(text);
}else if(item!= null && item.equals("Facilité")){
Text text = new Text(item);
text.setFill(Color.web("#000000"));
text.setFont(Font.font("Arial", FontWeight.BOLD, 14));
setGraphic(text);
}else{
setGraphic(null);
}
}
};
return cell;
}
});
TabColTotal.setStyle( "-fx-alignment: CENTER;");TabColTotal.getStyleClass().add("Center");
TabColTotal.setCellValueFactory(new PropertyValueFactory<FactureCltGestionList, String>("Total"));
TabColCodeCommande.setStyle( "-fx-alignment: CENTER;");TabColCodeCommande.getStyleClass().add("Center");
TabColCodeCommande.setCellValueFactory(new PropertyValueFactory<FactureCltGestionList, String>("CodeCommande"));
TabColCreation.setStyle( "-fx-alignment: CENTER;");TabColCreation.getStyleClass().add("Center");
TabColCreation.setCellValueFactory(new PropertyValueFactory<FactureCltGestionList, String>("DateCreation"));
TabColDetail.setStyle( "-fx-alignment: CENTER;");TabColDetail.getStyleClass().add("Center");
TabColDetail.setCellFactory(new Callback<TableColumn<FactureCltGestionList, Boolean>, TableCell<FactureCltGestionList, Boolean>>() {
@Override
public TableCell<FactureCltGestionList, Boolean> call(TableColumn<FactureCltGestionList, Boolean> personBooleanTableColumn) {
return new ButtonCell();
}
});
ButtonSearchFactureClt.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchFactureClt();
}
});
PaneFactureGestion.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchFactureClt();
}
}
});
RadioComptant.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchFactureClt();
}
});
RadioFacilite.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchFactureClt();
}
});
GestionSearchFactureClt();
}
private class ButtonCell extends TableCell<FactureCltGestionList, 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 {
// get Selected Item
FactureCltGestionList current = (FactureCltGestionList) ButtonCell.this.getTableView().getItems().get(ButtonCell.this.getIndex());
String code_facture = current.getCodeFacture();
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/FactureClt/FactureCltDetail.fxml"));
Parent NodeFactureCltDetail = (Parent)fxmlLoader.load();
FactureCltDetailController FactureCltDetail= fxmlLoader.getController();
FactureCltDetail.PaneSucces.setVisible(false);
FactureCltDetail.codeFactClt = code_facture;
FactureCltDetail.SowDetailFactureClt(false);
PaneFactureGestion.getChildren().clear();
PaneFactureGestion.getChildren().add(NodeFactureCltDetail);
FactureCltDetail.ButtonImprimerTraite.setVisible(false);
} catch (IOException ex) {
Logger.getLogger(FactureCltAjouterController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
//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 FactureCltAjouterButtonAction(ActionEvent event) throws IOException {
PaneFactureGestion.getChildren().clear();
PaneFactureGestion.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/FactureClt/FactureCltAjouter.fxml")));
}
/****************************************************************************** *
* *
* Methode last Next TableView *
* * *
******************************************************************************/
private void SearchFactureClt()
{
ProgressBarFactureClt.setVisible(true);
ButtonSearchFactureClt.setDisable(true);
ThreadSearchFactureClt = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
position = 0;
actuellepage = 1;
String DateCreation = "";
if(PickerDateCreation.getValue() != null){
DateCreation = PickerDateCreation.getValue().toString();
}
// 0comptant 1facilité
String TypeRegement = "";
if(RadioComptant.isSelected()){
TypeRegement = "0";
}else if(RadioFacilite.isSelected()){
TypeRegement = "1";
}
ObservableList<FactureCltGestionList> ListFactureClts = new FactureCltDB().SearchFactureCltGestion(
position,
nbrligne,
TextFieldCodeFacture.getText(),
TextFieldCodeClient.getText(),
TypeRegement,
TextFieldCodeCommande.getText(),
DateCreation);
TableViewFactureCltListGestion.setItems(ListFactureClts);
totalcount = new FactureCltDB().nbrFactureCltGestion(TextFieldCodeFacture.getText(),
TextFieldCodeClient.getText(),
TypeRegement,
TextFieldCodeCommande.getText(),
DateCreation);
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;
}
};
}
};
ThreadSearchFactureClt.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarFactureClt.setVisible(false);
ButtonSearchFactureClt.setDisable(false);
LabelCount.setText(totalcount.toString());
}
});
ThreadSearchFactureClt.start();
}
private void NextLastSearchFactureClt(Integer ParmPosition, Integer ParamNbrligne)
{
ProgressBarFactureClt.setVisible(true);
ButtonSearchFactureClt.setDisable(true);
ThreadSearchFactureClt = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
String DateCreation = "";
if(PickerDateCreation.getValue() != null){
DateCreation = PickerDateCreation.getValue().toString();
}
ObservableList<FactureCltGestionList> ListFactureClts = new FactureCltDB().SearchFactureCltGestion(ParmPosition, ParamNbrligne, TextFieldCodeFacture.getText(), TextFieldCodeClient.getText(), "", TextFieldCodeCommande.getText(), DateCreation);
TableViewFactureCltListGestion.setItems(ListFactureClts);
return null;
}
};
}
};
ThreadSearchFactureClt.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarFactureClt.setVisible(false);
ButtonSearchFactureClt.setDisable(false);
}
});
ThreadSearchFactureClt.start();
}
private void GestionSearchFactureClt()
{
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;
NextLastSearchFactureClt(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;
NextLastSearchFactureClt(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;
NextLastSearchFactureClt(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;
NextLastSearchFactureClt(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;
NextLastSearchFactureClt(position, nbrligne);
actuellepage=actuellepage-3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
}
}
@@ -0,0 +1,228 @@
package Controllers.FactureClt;
import Controllers.Traitement.Adaptateur;
import Controllers.Traitement.ParametreSystem;
import Models.Client.Client;
import Models.Client.ClientEntreprise;
import Models.Client.ClientPassager;
import Models.FactureClt.FactureClt;
import Models.Produit.ListeProduit;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.print.PageRange;
import javafx.print.PrinterJob;
import javafx.scene.control.Control;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
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.layout.AnchorPane;
import javafx.scene.text.Text;
import javafx.util.Callback;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class FactureCltPrintController implements Initializable {
@FXML private AnchorPane AnchorPaneTotal;
@FXML public ImageView ImageViewLogo;
@FXML private Text TextSteNom;
@FXML private Text TextSteAdress;
@FXML private Text TextSteTeleFax;
@FXML private Text TextSteIFCR;
@FXML private Text TextSteRIB;
@FXML private Text TextSteEmailSite;
@FXML private Text TextNumFacture;
@FXML private Text TextDateFacture;
@FXML private Text TextNumCommande;
@FXML private Text TextPagination;
@FXML private Text TextCltNomPrenom;
@FXML private Text TextCltTele;
@FXML private Text TextCltAdress;
@FXML private Text TextDuplicata;
@FXML private TableView<ListeProduit> TableViewListeProduit ;
@FXML private TableColumn<ListeProduit ,String> TabColReference;
@FXML private TableColumn<ListeProduit ,String> TabColDesignation;
@FXML private TableColumn<ListeProduit ,String> TabColQuantite ;
@FXML private TableColumn<ListeProduit ,String> TabColPrixHT;
@FXML private TableColumn<ListeProduit ,String> TabColRemise;
@FXML private TableColumn<ListeProduit ,String> TabColTotalHT;
@FXML private TableColumn<ListeProduit ,String> TabColTVA;
@FXML private TableColumn<ListeProduit ,String> TabColTotalTTC;
@FXML private Text TextTotalRemise;
@FXML private Text TextTotalHT;
@FXML private Text TextTotalTVA;
@FXML private Text TextTimbre;
@FXML private Text TextNetPayer;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
setImageLogo();
TextSteNom.setText(ParametreSystem.CompanyName);
TextSteAdress.setText(ParametreSystem.CompanyAddress);
TextSteTeleFax.setText(ParametreSystem.CompanyTele+" | Fax: "+ParametreSystem.CompanyFax);
TextSteIFCR.setText(ParametreSystem.CompanyIF+" | M.F: "+ParametreSystem.CompanyMF);
TextSteRIB.setText(ParametreSystem.RIB);
TextSteEmailSite.setText(ParametreSystem.CompanyMail+" | Site:"+ParametreSystem.CompanySite);
TabColReference.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("reference"));
TabColReference.setStyle( "-fx-alignment: CENTER;");
TabColReference.getStyleClass().add("Center");
TabColDesignation.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("designation"));
TabColDesignation.setCellFactory(new Callback<TableColumn<ListeProduit,String>,TableCell<ListeProduit,String>>(){
@Override
public TableCell<ListeProduit, String> call(TableColumn<ListeProduit, String> param) {
TableCell<ListeProduit, String> cell = new TableCell<ListeProduit, String>(){
@Override
public void updateItem(String item, boolean empty) {
if (item == null) {
super.setText(null);
super.setGraphic(null);
} else {
String newItem = item.trim().toLowerCase();
Text text = new Text(newItem);
super.setPrefHeight(Control.USE_COMPUTED_SIZE);
text.wrappingWidthProperty().bind(super.widthProperty());
super.setGraphic(text);
}
}
};
return cell;
}
});
TabColQuantite.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("quantite"));
TabColQuantite.setStyle( "-fx-alignment: CENTER;");
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;");
TabColTotalTTC.getStyleClass().add("Center");
TabColReference.setCellFactory(TextFieldTableCell.<ListeProduit>forTableColumn());
TabColQuantite.setCellFactory(TextFieldTableCell.<ListeProduit>forTableColumn());
TabColRemise.setCellFactory(TextFieldTableCell.<ListeProduit>forTableColumn());
}
public void setFactureClt(FactureClt factureClt, boolean duplicata)
{
if(duplicata){
TextDuplicata.setVisible(true);
}else{
TextDuplicata.setVisible(false);
}
TableViewListeProduit.setItems(factureClt.getListeproduit());
TextNumFacture.setText(factureClt.getCodeFactureClt());
TextDateFacture.setText(Adaptateur.NormalDateFormat(factureClt.getDateFacture()));
TextNumCommande.setText(factureClt.getIdCommandeClt());
TextPagination.setText("1/1");
//0 Personne 1 Entreprise 2 Passager
if(factureClt.getTypeClient() == 0){
Client client = factureClt.getCltPersonne();
TextCltNomPrenom.setText(client.getNom()+" "+client.getPrenom());
TextCltTele.setText(client.getTelefixString());
TextCltAdress.setText(client.getAdresse());
}else if(factureClt.getTypeClient() == 1){
ClientEntreprise entreprise = factureClt.getCltEntreprise();
TextCltNomPrenom.setText(entreprise.getNom());
TextCltTele.setText(entreprise.getTele1String());
TextCltAdress.setText(entreprise.getAdresse());
}else if(factureClt.getTypeClient() == 2){
ClientPassager passager = factureClt.getCltPassager();
TextCltNomPrenom.setText(passager.getNom()+" "+passager.getPrenom());
TextCltTele.setText(passager.getTelefixString());
TextCltAdress.setText(passager.adresse);
}
TextTotalRemise.setText(Adaptateur.StringToStringEspace(factureClt.getRemise()));
TextTotalHT.setText(Adaptateur.StringToStringEspace(factureClt.getTotalHorsTaxNet()));
TextTotalTVA.setText(Adaptateur.StringToStringEspace(factureClt.getTotalTVA()));
TextTimbre.setText(Adaptateur.StringToStringEspace(factureClt.getTimbre()));
TextNetPayer.setText(Adaptateur.StringToStringEspace(factureClt.getNetAPayer()));
}
private void setImageLogo()
{
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
// optional, but recommended
// process XML securely, avoid attacks like XML External Entities (XXE)
dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
// parse XML file
DocumentBuilder db = dbf.newDocumentBuilder();
//PowerERP\conf\logo.xml
Document doc = db.parse(new File("./conf/logo.xml"));
doc.getDocumentElement().normalize();
Element elementCNX = (Element) doc.getElementsByTagName("FactureCltPrint").item(0);
String pathLogo = elementCNX.getElementsByTagName("PathImage").item(0).getTextContent();
FileInputStream fis = new FileInputStream(pathLogo);
ImageViewLogo.setImage(new Image(fis));
ImageViewLogo.setFitWidth(Double.parseDouble(elementCNX.getElementsByTagName("FitWidth").item(0).getTextContent()));
ImageViewLogo.setFitHeight(Double.parseDouble(elementCNX.getElementsByTagName("FitHeight").item(0).getTextContent()));
ImageViewLogo.setLayoutX(Double.parseDouble(elementCNX.getElementsByTagName("LayoutX").item(0).getTextContent()));
ImageViewLogo.setLayoutY(Double.parseDouble(elementCNX.getElementsByTagName("LayoutY").item(0).getTextContent()));
}
catch (ParserConfigurationException | SAXException | IOException e) {
System.out.println("error AuthentificationController/setImageLogo "+e.getMessage());
}
}
}
@@ -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));
}
}
});
}
}
@@ -0,0 +1,344 @@
package Controllers.Fournisseur;
import Controllers.Traitement.contro;
import Models.Fournisseur.Fournisseur;
import Models.Fournisseur.FournisseurContactDB;
import Models.Fournisseur.FournisseurContactList;
import Models.Fournisseur.FournisseurDB;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
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.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
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.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Text;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class FournisseurGererController implements Initializable {
@FXML public AnchorPane PanePrincipalFournisseur;
@FXML public AnchorPane AnchorPaneLoadingFournisseur;
@FXML public Text TitreSecondaire;
@FXML private AnchorPane PaneFournisseurAjouter;
@FXML public Button AjouterContactFrsButton;
@FXML public Button ButtonGererAjouterFrs;
@FXML public Button ButtonGererModifierFrs;
@FXML public TextField TextFieldNomFrs ;
@FXML public TextField TextFieldSpecialiteFrs ;
@FXML public TextField TextFieldTele1Frs ;
@FXML public TextField TextFieldTele2Frs ;
@FXML public TextField TextFieldFaxFrs ;
@FXML public TextField TextFieldMailFrs ;
@FXML public TextField TextFieldSiteWebFrs ;
@FXML public TextField TextFieldAdresseFrs ;
@FXML public ChoiceBox ChoiceBoxFormes;
@FXML public Text TextNomFrs ;
@FXML public Text TextSpecialiteFrs ;
@FXML public Text TextTele1Frs ;
@FXML public Text TextTele2Frs ;
@FXML public Text TextFaxFrs ;
@FXML public Text TextMailFrs ;
@FXML public Text TextSiteWebFrs ;
@FXML public Text TextAdresseFrs ;
@FXML public TableView<FournisseurContactList> TableViewFournisseurContactFrs;
@FXML public TableColumn<FournisseurContactList ,String> TabColCodeContactFrs;
@FXML public TableColumn<FournisseurContactList ,String> TabColNomContactFrs;
@FXML public TableColumn<FournisseurContactList ,String> TabColPrenomContactFrs;
@FXML public TableColumn<FournisseurContactList ,String> TabColTele1ContactFrs;
@FXML public TableColumn<FournisseurContactList ,String> TabColTele2ContactFrs;
@FXML public TableColumn<FournisseurContactList ,String> TabColEmailContactFrs;
@FXML public TextField TextFieldNomContactFrs ;
@FXML public TextField TextFieldPrenomContactFrs ;
@FXML public TextField TextFieldTele1ContactFrs ;
@FXML public TextField TextFieldTele2ContactFrs ;
@FXML public TextField TextFieldMailContactFrs ;
@FXML public Text TextNomCltContactFrs ;
@FXML public Text TextPrenomCltContactFrs ;
@FXML public Text TextTele1CltContactFrs ;
@FXML public Text TextTele2CltContactFrs ;
@FXML public Text TextMailCltContactFrs ;
public ObservableList<FournisseurContactList> ObservableListContactFrs = FXCollections.observableArrayList();
private Service<Void> ThreadFournisseurGerer;
contro Controle = new contro();
Fournisseur Frs;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
ChoiceBoxFormes.setItems(FXCollections.observableArrayList("SARL","EURL","SAS","SASU","SA","SNC"));
ChoiceBoxFormes.getSelectionModel().selectFirst();
TabColCodeContactFrs.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColCodeContactFrs.getStyleClass().add("Center");
TabColCodeContactFrs.setCellValueFactory(new PropertyValueFactory<FournisseurContactList, String>("Code"));
TabColNomContactFrs.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColNomContactFrs.getStyleClass().add("Center");
TabColNomContactFrs.setCellValueFactory(new PropertyValueFactory<FournisseurContactList, String>("Nom"));
TabColPrenomContactFrs.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColPrenomContactFrs.getStyleClass().add("Center");
TabColPrenomContactFrs.setCellValueFactory(new PropertyValueFactory<FournisseurContactList, String>("Prenom"));
TabColTele1ContactFrs.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColTele1ContactFrs.getStyleClass().add("Center");
TabColTele1ContactFrs.setCellValueFactory(new PropertyValueFactory<FournisseurContactList, String>("Tele1"));
TabColTele2ContactFrs.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColTele2ContactFrs.getStyleClass().add("Center");
TabColTele2ContactFrs.setCellValueFactory(new PropertyValueFactory<FournisseurContactList, String>("Tele2"));
TabColEmailContactFrs.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColEmailContactFrs.getStyleClass().add("Center");
TabColEmailContactFrs.setCellValueFactory(new PropertyValueFactory<FournisseurContactList, String>("Mail"));
AjouterContactFrsButton.getStyleClass().add("btn-primary");
Image coffeeImage = new Image(getClass().getResourceAsStream("/Public/icon/iconaffecter.png"));
ImageView buttonGraphic = new ImageView();
buttonGraphic.setImage(coffeeImage);
AjouterContactFrsButton.setGraphic(buttonGraphic);
//Bouton Ajouter
ButtonGererAjouterFrs.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
if( Controle.ContrNull(TextFieldNomFrs, TextNomFrs) &&
Controle.ContrNull(TextFieldSpecialiteFrs, TextSpecialiteFrs) &&
Controle.ContrNumeriqueNotnull(TextFieldTele1Frs, TextTele1Frs) &&
Controle.ContrNumerique(TextFieldTele2Frs, TextTele2Frs) &&
Controle.ContrNumerique(TextFieldFaxFrs, TextFaxFrs) &&
Controle.ContrNull(TextFieldAdresseFrs, TextAdresseFrs)
){
Fournisseur fournisseur = SetDataFournissuer();
FournisseurDB FrsDB = new FournisseurDB();
fournisseur = FrsDB.SetFournisseurDB(fournisseur);
if(fournisseur.getCode()!= null){
PaneFournisseurAjouter.getChildren().clear();
try {
PaneFournisseurAjouter.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Fournisseur/FournisseurGestion.fxml")));
} catch (IOException ex) {
Logger.getLogger(FournisseurGererController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
});
}
@FXML
public void clickItem(MouseEvent event)
{
if (event.getClickCount() == 2) //Checking double click
{
FournisseurContactList FrsContact = TableViewFournisseurContactFrs.getSelectionModel().getSelectedItem();
TextFieldNomContactFrs.setText(FrsContact.getNom());
TextFieldPrenomContactFrs.setText(FrsContact.getPrenom());
TextFieldTele1ContactFrs.setText(FrsContact.getTele1());
TextFieldTele2ContactFrs.setText(FrsContact.getTele2());
TextFieldMailContactFrs.setText(FrsContact.getMail());
}
}
public Fournisseur SetDataFournissuer(){
Fournisseur fournisseur= new Fournisseur();
fournisseur.setNom(TextFieldNomFrs.getText());
fournisseur.setSpecialite(TextFieldSpecialiteFrs.getText());
fournisseur.setFormes(ChoiceBoxFormes.getValue().toString());
fournisseur.setTele1(TextFieldTele1Frs.getText());
fournisseur.setTele2(TextFieldTele2Frs.getText());
fournisseur.setFax(TextFieldFaxFrs.getText());
fournisseur.setMail(TextFieldMailFrs.getText());
fournisseur.setSiteWeb(TextFieldSiteWebFrs.getText());
fournisseur.setAdresse(TextFieldAdresseFrs.getText());
fournisseur.setContactFrs(ObservableListContactFrs);
return fournisseur;
}
@FXML
private void AjouterContactFrsButtonAction(ActionEvent event) throws IOException {
if( Controle.ContrNull(TextFieldNomContactFrs, TextNomCltContactFrs) &&
Controle.ContrNull(TextFieldPrenomContactFrs, TextPrenomCltContactFrs) &&
Controle.ContrNumeriqueNotnull(TextFieldTele1ContactFrs, TextTele1CltContactFrs) &&
Controle.ContrNumerique(TextFieldTele2ContactFrs, TextTele2CltContactFrs) ){
int indise = 0;
boolean notexiste = true;
while(indise<ObservableListContactFrs.size() && notexiste){
if( (TextFieldNomContactFrs.getText().equals(ObservableListContactFrs.get(indise).getNom())) && (TextFieldPrenomContactFrs.getText().equals(ObservableListContactFrs.get(indise).getPrenom()) ) )
{
ObservableListContactFrs.get(indise).SetTele1(TextFieldTele1ContactFrs.getText());
ObservableListContactFrs.get(indise).SetTele2(TextFieldTele2ContactFrs.getText());
ObservableListContactFrs.get(indise).SetMail(TextFieldMailContactFrs.getText());
notexiste = false;
}
indise++;
}
if(notexiste){
ObservableListContactFrs.add(new FournisseurContactList("", TextFieldNomContactFrs.getText(), TextFieldPrenomContactFrs.getText(), TextFieldTele1ContactFrs.getText(), TextFieldTele2ContactFrs.getText(), TextFieldMailContactFrs.getText()));
}
TableViewFournisseurContactFrs.setItems(ObservableListContactFrs);
TableViewFournisseurContactFrs.refresh();
}
}
public void SetDataFournissuer(final String CodeFrs){
PanePrincipalFournisseur.setVisible(false);
AnchorPaneLoadingFournisseur.setVisible(true);
TitreSecondaire.setText("Fournisseur / Modifier");
ButtonGererModifierFrs.setVisible(true);
ButtonGererAjouterFrs.setVisible(false);
ThreadFournisseurGerer = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
Frs = new FournisseurDB().GetFournisseurDB(CodeFrs);
return null;
}
};
}
};
ThreadFournisseurGerer.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ObservableListContactFrs = Frs.getContactFrs();
TableViewFournisseurContactFrs.setItems(Frs.getContactFrs());
TextFieldNomFrs.setText(Frs.getNom());
TextFieldSpecialiteFrs.setText(Frs.getSpecialite()) ;
TextFieldTele1Frs.setText(Frs.getTele1()) ;
TextFieldTele2Frs.setText(Frs.getTele2()) ;
TextFieldFaxFrs.setText(Frs.getFax()) ;
TextFieldMailFrs.setText(Frs.getMail()) ;
TextFieldSiteWebFrs.setText(Frs.getSiteWeb()) ;
TextFieldAdresseFrs.setText(Frs.getAdresse()) ;
if(Frs.getFormes() != null){
if(Frs.getFormes().equals("SARL")){
ChoiceBoxFormes.getSelectionModel().select(0);
}else if(Frs.getFormes().equals("EURL")){
ChoiceBoxFormes.getSelectionModel().select(1);
}else if(Frs.getFormes().equals("SAS")){
ChoiceBoxFormes.getSelectionModel().select(2);
}else if(Frs.getFormes().equals("SASU")){
ChoiceBoxFormes.getSelectionModel().select(3);
}else if(Frs.getFormes().equals("SA")){
ChoiceBoxFormes.getSelectionModel().select(4);
}else if(Frs.getFormes().equals("SNC")){
ChoiceBoxFormes.getSelectionModel().select(5);
}
}
PanePrincipalFournisseur.setVisible(true);
AnchorPaneLoadingFournisseur.setVisible(false);
}
});
ThreadFournisseurGerer.start();
ButtonGererModifierFrs.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
if( Controle.ContrNull(TextFieldNomFrs, TextNomFrs) &&
Controle.ContrNull(TextFieldSpecialiteFrs, TextSpecialiteFrs) &&
Controle.ContrNumeriqueNotnull(TextFieldTele1Frs, TextTele1Frs) &&
Controle.ContrNumerique(TextFieldTele2Frs, TextTele2Frs) &&
Controle.ContrNumerique(TextFieldFaxFrs, TextFaxFrs) &&
Controle.ContrNull(TextFieldAdresseFrs, TextAdresseFrs)
){
Fournisseur fournisseur = SetDataFournissuer();
fournisseur.setCode(CodeFrs);
FournisseurDB FrourDB= new FournisseurDB();
boolean ResultUpdate = FrourDB.UpdFournisseurDB(fournisseur);
if(ResultUpdate){
FournisseurContactDB FrsContactDB= new FournisseurContactDB();
ObservableList<FournisseurContactList> ObservableNewListContactFrs = FXCollections.observableArrayList();
for(FournisseurContactList ContactList : ObservableListContactFrs){
if(ContactList.getCode().length()>0){
FrsContactDB.UpdListFournisseurContact(ContactList.getCode(), ContactList.getNom(), ContactList.getPrenom(), ContactList.getTele1(), ContactList.getTele2(), ContactList.getMail());
}else{
ObservableNewListContactFrs.add(ContactList);
}
}
if(ObservableNewListContactFrs.size()>0){
FrsContactDB.SetListFournisseurContact(ObservableNewListContactFrs, CodeFrs);
PaneFournisseurAjouter.getChildren().clear();
}
try {
PaneFournisseurAjouter.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Fournisseur/FournisseurGestion.fxml")));
} catch (IOException ex) {
Logger.getLogger(FournisseurGererController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
});
}
}
@@ -0,0 +1,395 @@
package Controllers.Fournisseur;
import Models.Fournisseur.FournisseurDB;
import Models.Fournisseur.FournisseurGestionList;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
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.Label;
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.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;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class FournisseurGestionController implements Initializable {
@FXML private AnchorPane PaneFournisseurGestion ;
@FXML private ProgressBar ProgressBarFournisseurGestion;
@FXML public TableView<FournisseurGestionList> TableViewFournisseurGestion;
@FXML public TableColumn<FournisseurGestionList ,String> TabColCodeFournisseur;
@FXML public TableColumn<FournisseurGestionList ,String> TabColNomFournisseur;
@FXML public TableColumn<FournisseurGestionList ,String> TabColTele1Fournisseur;
@FXML public TableColumn<FournisseurGestionList ,String> TabColTele2Fournisseur;
@FXML public TableColumn<FournisseurGestionList ,String> TabColFaxFournisseur;
@FXML public TableColumn<FournisseurGestionList ,String> TabColMailFournisseur;
@FXML public TableColumn<FournisseurGestionList ,String> TabColAdresseFournisseur;
@FXML public TableColumn<FournisseurGestionList ,Boolean>TabColDetail ;
@FXML public TextField TextFieldCodeFournisseur ;
@FXML public TextField TextFieldNomFournisseur ;
@FXML public TextField TextFieldAdresseFournisseur ;
@FXML public TextField TextFieldTeleFournisseur ;
@FXML public TextField TextFieldFaxFournisseur ;
@FXML public TextField TextFieldMailFournisseur ;
@FXML private Button ButtonSearchFournisseurGestion;
@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 ;
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;
private Service<Void> ThreadSearchFournisseurGestion;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
//comboboxnombre des lignes tableview
NbrLigne.setItems(cursors);
NbrLigne.getSelectionModel().selectFirst();
TableViewFournisseurGestion.setEditable(true);
TabColCodeFournisseur.setStyle( "-fx-alignment: CENTER;");TabColCodeFournisseur.getStyleClass().add("Center");
TabColCodeFournisseur.setCellValueFactory(new PropertyValueFactory<FournisseurGestionList, String>("Code"));
TabColNomFournisseur.setStyle( "-fx-alignment: CENTER;");TabColNomFournisseur.getStyleClass().add("Center");
TabColNomFournisseur.setCellValueFactory(new PropertyValueFactory<FournisseurGestionList, String>("Nom"));
TabColTele1Fournisseur.setStyle( "-fx-alignment: CENTER;");TabColTele1Fournisseur.getStyleClass().add("Center");
TabColTele1Fournisseur.setCellValueFactory(new PropertyValueFactory<FournisseurGestionList, String>("Tele1"));
TabColTele2Fournisseur.setStyle( "-fx-alignment: CENTER;");TabColTele2Fournisseur.getStyleClass().add("Center");
TabColTele2Fournisseur.setCellValueFactory(new PropertyValueFactory<FournisseurGestionList, String>("Tele2"));
TabColFaxFournisseur.setStyle( "-fx-alignment: CENTER;");TabColFaxFournisseur.getStyleClass().add("Center");
TabColFaxFournisseur.setCellValueFactory(new PropertyValueFactory<FournisseurGestionList, String>("Fax"));
TabColMailFournisseur.setStyle( "-fx-alignment: CENTER;");TabColMailFournisseur.getStyleClass().add("Center");
TabColMailFournisseur.setCellValueFactory(new PropertyValueFactory<FournisseurGestionList, String>("Mail"));
TabColAdresseFournisseur.setStyle( "-fx-alignment: CENTER;");TabColAdresseFournisseur.getStyleClass().add("Center");
TabColAdresseFournisseur.setCellValueFactory(new PropertyValueFactory<FournisseurGestionList, String>("Adresse"));
TabColDetail.setStyle( "-fx-alignment: CENTER;");TabColDetail.getStyleClass().add("Center");
TabColDetail.setCellFactory(new Callback<TableColumn<FournisseurGestionList, Boolean>, TableCell<FournisseurGestionList, Boolean>>() {
@Override
public TableCell<FournisseurGestionList, Boolean> call(TableColumn<FournisseurGestionList, Boolean> personBooleanTableColumn) {
return new ButtonCell();
}
});
ButtonSearchFournisseurGestion.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchFournisseurGestion();
}
});
PaneFournisseurGestion.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchFournisseurGestion();
}
}
});
GestionSearchFournisseur();
}
private class ButtonCell extends TableCell<FournisseurGestionList, 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/Fournisseur/FournisseurGerer.fxml"));
Parent ParentFxmlFournisseur = (Parent)fxmlLoader.load();
FournisseurGererController FournisseurGerer = fxmlLoader.getController();
FournisseurGestionList FournisseurList = ((FournisseurGestionList)getTableRow().getItem());
FournisseurGerer.SetDataFournissuer(FournisseurList.getCode());
PaneFournisseurGestion.getChildren().clear();
PaneFournisseurGestion.getChildren().add(ParentFxmlFournisseur);
} catch (IOException ex) {
Logger.getLogger(FournisseurGestionController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
//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 FournisseurAjouterButtonAction(ActionEvent event) throws IOException {
PaneFournisseurGestion.getChildren().clear();
PaneFournisseurGestion.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Fournisseur/FournisseurGerer.fxml")));
}
/****************************************************************************** *
* *
* Methode last Next TableView *
* * *
******************************************************************************/
private void SearchFournisseurGestion()
{
ProgressBarFournisseurGestion.setVisible(true);
ButtonSearchFournisseurGestion.setDisable(true);
ThreadSearchFournisseurGestion = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
position = 0;
actuellepage = 1;
ObservableList<FournisseurGestionList> ListFournisseurGestions = new FournisseurDB().SearchFournisseurGestion(
position,
nbrligne,
TextFieldCodeFournisseur.getText(),
TextFieldNomFournisseur.getText(),
TextFieldAdresseFournisseur.getText(),
TextFieldTeleFournisseur.getText(),
TextFieldFaxFournisseur.getText(),
TextFieldMailFournisseur.getText());
TableViewFournisseurGestion.setItems(ListFournisseurGestions);
totalcount = new FournisseurDB().nbrFournisseurGestion(TextFieldCodeFournisseur.getText(), TextFieldNomFournisseur.getText(), TextFieldAdresseFournisseur.getText(), TextFieldTeleFournisseur.getText(), TextFieldFaxFournisseur.getText(), TextFieldMailFournisseur.getText());
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;
}
};
}
};
ThreadSearchFournisseurGestion.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarFournisseurGestion.setVisible(false);
ButtonSearchFournisseurGestion.setDisable(false);
LabelCount.setText(totalcount.toString());
}
});
ThreadSearchFournisseurGestion.start();
}
private void NextLastSearchFournisseurGestion(Integer ParmPosition, Integer ParamNbrligne)
{
ProgressBarFournisseurGestion.setVisible(true);
ButtonSearchFournisseurGestion.setDisable(true);
ThreadSearchFournisseurGestion = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
ObservableList<FournisseurGestionList> ListFournisseurGestions = new FournisseurDB().SearchFournisseurGestion(ParmPosition, ParamNbrligne, TextFieldCodeFournisseur.getText(), TextFieldNomFournisseur.getText(), TextFieldAdresseFournisseur.getText(), TextFieldTeleFournisseur.getText(), TextFieldFaxFournisseur.getText(), TextFieldMailFournisseur.getText());
TableViewFournisseurGestion.setItems(ListFournisseurGestions);
return null;
}
};
}
};
ThreadSearchFournisseurGestion.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarFournisseurGestion.setVisible(false);
ButtonSearchFournisseurGestion.setDisable(false);
}
});
ThreadSearchFournisseurGestion.start();
}
private void GestionSearchFournisseur()
{
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;
NextLastSearchFournisseurGestion(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;
NextLastSearchFournisseurGestion(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;
NextLastSearchFournisseurGestion(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;
NextLastSearchFournisseurGestion(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;
NextLastSearchFournisseurGestion(position, nbrligne);
actuellepage=actuellepage-3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
}
}
@@ -0,0 +1,38 @@
package Controllers.Home;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.animation.FadeTransition;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.layout.AnchorPane;
import javafx.util.Duration;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class AideController implements Initializable {
@FXML private AnchorPane AnchorPaneAide ;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
FadeTransitionNode(AnchorPaneAide);
}
public void FadeTransitionNode(Node AnchorPane){
FadeTransition ft = new FadeTransition(Duration.millis(200), AnchorPane);
ft.setFromValue(0);
ft.setToValue(1.0);
ft.play();
}
}
@@ -0,0 +1,44 @@
package Controllers.Home;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.animation.FadeTransition;
import javafx.collections.FXCollections;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.control.ChoiceBox;
import javafx.scene.layout.AnchorPane;
import javafx.util.Duration;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class ContactController implements Initializable {
@FXML private AnchorPane AnchorPaneContact ;
@FXML public ChoiceBox ChoiceBoxMsgSujet;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
ChoiceBoxMsgSujet.setItems(FXCollections.observableArrayList("Une question relative à un problème technique.",
"Besoin d'une nouvelle fonctionnalité."));
FadeTransitionNode(AnchorPaneContact);
}
public void FadeTransitionNode(Node AnchorPane){
FadeTransition ft = new FadeTransition(Duration.millis(200), AnchorPane);
ft.setFromValue(0);
ft.setToValue(1.0);
ft.play();
}
}
@@ -0,0 +1,119 @@
package Controllers.Home;
import Controllers.Traitement.Adaptateur;
import Controllers.Traitement.ParametreSystem;
import Models.Home.HomeDB;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.net.URL;
import java.util.Map;
import java.util.ResourceBundle;
import javafx.animation.FadeTransition;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.concurrent.WorkerStateEvent;
import javafx.event.EventHandler;
import javafx.scene.Node;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.chart.BarChart;
import javafx.scene.chart.PieChart;
import javafx.scene.chart.XYChart;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Text;
import javafx.util.Duration;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class DashboardController implements Initializable {
@FXML private AnchorPane AnchorPaneDashboard ;
@FXML private Text TextYearDashboard;
@FXML private Text TextNbrClient;
@FXML private Text TextNbrVente;
@FXML private Text TextNbrCheque;
@FXML public BarChart BarChartVente;
@FXML private PieChart PieChartVente;
@FXML private ProgressBar ProgressBarLoading;
private Service<Void> ThreadDashboard;
String Year = Adaptateur.getDefaultCurrentDate("yyyy");
HomeDB Homedb = new HomeDB();
XYChart.Series series1 = new XYChart.Series();
ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList();
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
TextYearDashboard.setText("L'année "+Year);
FadeTransitionNode(AnchorPaneDashboard);
ProgressBarLoading.setVisible(true);
ThreadDashboard = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
series1 = Homedb.HomeChiffreAffaireByMois();
series1.setName(ParametreSystem.NomLocalPC);
pieChartData = Homedb.HomeVente(Year);
NombreVCV();
return null;
}
};
}
};
ThreadDashboard.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
BarChartVente.getData().addAll(series1);
PieChartVente.setData(pieChartData);
ProgressBarLoading.setVisible(false);
}
});
ThreadDashboard.start();
}
public void FadeTransitionNode(Node AnchorPane){
FadeTransition ft = new FadeTransition(Duration.millis(200), AnchorPane);
ft.setFromValue(0);
ft.setToValue(1.0);
ft.play();
}
private void NombreVCV()
{
Map map = Homedb.HomeNbr();
TextNbrClient.setText(map.get("client").toString());
TextNbrVente.setText(map.get("factureclt").toString());
TextNbrCheque.setText(map.get("cheque").toString());
}
}
@@ -0,0 +1,35 @@
package Controllers.Home;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.animation.FadeTransition;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.layout.AnchorPane;
import javafx.util.Duration;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class LogicielController implements Initializable {
@FXML private AnchorPane AnchorPaneLogiciel ;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
FadeTransitionNode(AnchorPaneLogiciel);
}
public void FadeTransitionNode(Node AnchorPane){
FadeTransition ft = new FadeTransition(Duration.millis(200), AnchorPane);
ft.setFromValue(0);
ft.setToValue(1.0);
ft.play();
}
}
@@ -0,0 +1,35 @@
package Controllers.Home;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.animation.FadeTransition;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.layout.AnchorPane;
import javafx.util.Duration;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class MentionsController implements Initializable {
@FXML private AnchorPane AnchorPaneMentions ;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
FadeTransitionNode(AnchorPaneMentions);
}
public void FadeTransitionNode(Node AnchorPane){
FadeTransition ft = new FadeTransition(Duration.millis(200), AnchorPane);
ft.setFromValue(0);
ft.setToValue(1.0);
ft.play();
}
}
+11
View File
@@ -0,0 +1,11 @@
package Controllers;
/**
* @author Maher Ben Tili
*/
public class Main {
public static void main(String[] args) {
App.main(args);
}
}
@@ -0,0 +1,335 @@
package Controllers;
import Controllers.Traitement.MyWindow;
import Models.User.User;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.control.Accordion;
import javafx.scene.control.Label;
import javafx.scene.control.TitledPane;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Pane;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
public class PrincipalController implements Initializable{
@FXML public AnchorPane window ;
@FXML public AnchorPane Content ;
@FXML public Pane TitrePane;
@FXML public Label UsernomprenomBlad;
@FXML public Label LabelDefaultLocal;
@FXML public ImageView ImageViewLogoPrincipal;
@FXML public ImageView ImageViewProfile;
@FXML public Accordion accord;
@FXML public TitledPane TitledPaneAccueil;
@FXML public TitledPane TitledPaneAchat;
@FXML public TitledPane TitledPaneVente;
@FXML public TitledPane TitledPaneStock;
@FXML public TitledPane TitledPaneDiver;
@Override
public void initialize(URL url, ResourceBundle rb) {
setImageLogo();
UsernomprenomBlad.setText(User.nom+" "+User.prenom);
LabelDefaultLocal.setText(User.UserLocal);
ImageViewProfile.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
try {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/User/Profile.fxml")));
} catch (IOException ex) {
Logger.getLogger(PrincipalController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
/**********************Accueil************************/
try {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Home/Dashboard.fxml")));
} catch (IOException ex) {
Logger.getLogger(PrincipalController.class.getName()).log(Level.SEVERE, null, ex);
}
accord.setExpandedPane(TitledPaneAccueil);
/********************get Width and Height Content **************************/
Content.widthProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneWidth, Number newSceneWidth) {
MyWindow.PrincipalContentWidth = newSceneWidth;
}
});
Content.heightProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneHeight, Number newSceneHeight) {
MyWindow.PrincipalContentHeight = newSceneHeight;
}
});
}
public void DefaultSelectedTitledPane(Integer number_titled_Pane){
if(number_titled_Pane == 1){
accord.setExpandedPane(TitledPaneAccueil);
}else if(number_titled_Pane == 2){
accord.setExpandedPane(TitledPaneAchat);
}else if(number_titled_Pane == 3){
accord.setExpandedPane(TitledPaneVente);
}else if(number_titled_Pane == 4){
accord.setExpandedPane(TitledPaneStock);
}else if(number_titled_Pane == 5){
accord.setExpandedPane(TitledPaneDiver);
}
}
/*********************************Accueil****************************************/
@FXML
private void DashbordButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Home/Dashboard.fxml")));
}
@FXML
private void AideButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Home/Aide.fxml")));
}
@FXML
private void ContactButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Home/Contact.fxml")));
}
@FXML
private void LogicielButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Home/Logiciel.fxml")));
}
@FXML
private void MentionsButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Home/Mentions.fxml")));
}
/*********************************Pour l'Achat************************************/
@FXML
private void FournisseurButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Fournisseur/FournisseurGestion.fxml")));
}
@FXML
private void BonReceptionButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/BonReceptionFrs/BonReceptionGestionFrs.fxml")));
}
@FXML
private void FactureFrsButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/FactureFrs/FactureFrsGestion.fxml")));
}
@FXML
private void ReglementButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Reglement/ReglementGestion.fxml")));
}
/*********************************Pour la Vente***********************************/
@FXML
private void VenteRapideCltButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/VenteRapideClt/VenteRapideClt.fxml")));
}
@FXML
private void PasserCommandeCltButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/CommandeClt/CommandeCltGestion.fxml")));
}
@FXML
private void BonLivraisonCltButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/BonLivraisonClt/BonLivraisonCltGestion.fxml")));
}
@FXML
private void FactureCltButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/FactureClt/FactureCltGestion.fxml")));
}
@FXML
private void MenuClientButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Client/MenuClient.fxml")));
}
@FXML
private void DevisCltButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Devis/DevisCltGestion.fxml")));
}
@FXML
private void TraiteCltButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/TraiteClt/TraiteCltGestion.fxml")));
}
/*********************************Pour Produit**********************************/
@FXML
private void AjouterProduitButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Produit/AjouterProduit.fxml")));
}
@FXML
private void GestionProduitButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Produit/GestionProduit.fxml")));
}
/*********************************Pour l'utilisateur***********************************/
@FXML
private void AddUserButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/User/AddUser.fxml")));
}
@FXML
private void GestionUtilisateurButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/User/GestionUtilisateur.fxml")));
}
/********************************* Stock ***********************************/
@FXML
private void BondeSortieButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Stock/BondeSortie.fxml")));
}
@FXML
private void BondeEntrerButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Stock/BondeEntrer.fxml")));
}
@FXML
private void EtatStockButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Stock/EtatStockCategorie.fxml")));
}
/********************************* Diver ***********************************/
@FXML
private void ChequeCltButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/ChequeClt/ChequeCltGestion.fxml")));
}
@FXML
private void CaisseEntreButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Caisse/CaisseEntre.fxml")));
}
@FXML
private void CaisseSortieButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Caisse/CaisseSortie.fxml")));
}
@FXML
private void FraisButtonAction(ActionEvent event) throws IOException {
window.getChildren().clear();
window.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Caisse/FraisGestion.fxml")));
}
private void setImageLogo()
{
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
// optional, but recommended
// process XML securely, avoid attacks like XML External Entities (XXE)
dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
// parse XML file
DocumentBuilder db = dbf.newDocumentBuilder();
//PowerERP\conf\logo.xml
Document doc = db.parse(new File("./conf/logo.xml"));
doc.getDocumentElement().normalize();
Element elementCNX = (Element) doc.getElementsByTagName("Principal").item(0);
String pathLogo = elementCNX.getElementsByTagName("PathImage").item(0).getTextContent();
FileInputStream fis = new FileInputStream(pathLogo);
ImageViewLogoPrincipal.setImage(new Image(fis));
ImageViewLogoPrincipal.setFitWidth(Double.parseDouble(elementCNX.getElementsByTagName("FitWidth").item(0).getTextContent()));
ImageViewLogoPrincipal.setFitHeight(Double.parseDouble(elementCNX.getElementsByTagName("FitHeight").item(0).getTextContent()));
ImageViewLogoPrincipal.setLayoutX(Double.parseDouble(elementCNX.getElementsByTagName("LayoutX").item(0).getTextContent()));
ImageViewLogoPrincipal.setLayoutY(Double.parseDouble(elementCNX.getElementsByTagName("LayoutY").item(0).getTextContent()));
}
catch (ParserConfigurationException | SAXException | IOException e) {
System.out.println("error AuthentificationController/setImageLogo "+e.getMessage());
}
}
}
@@ -0,0 +1,349 @@
package Controllers.Produit;
import Controllers.Categorie.AjouterCategorieController;
import Controllers.Dialog.ShowDialog;
import Controllers.Traitement.Adaptateur;
import Controllers.Traitement.ParametreSystem;
import Controllers.Traitement.contro;
import Models.Categorie.CategorieDB;
import Models.Produit.Produit;
import Models.Produit.ProduitDB;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.animation.FadeTransition;
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.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ColorPicker;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.util.Duration;
import org.controlsfx.control.textfield.TextFields;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class AjouterProduitController implements Initializable {
@FXML private ProgressBar ProgressBarAjouterProduit;
//private AnchorPane Content ;
@FXML private AnchorPane AnchorPaneAjouterprod ;
@FXML private AnchorPane AnchorPaneAjouterProduit ;
@FXML private TextField AjouterProduitReference;
@FXML private TextField AjouterProduitCodeBarre;
@FXML private TextField AjouterProduitdesignation ;
@FXML private TextField AjouterProduitGarantie ;
@FXML private TextField AjouterProduitMarque ;
@FXML private TextField AjouterProduitPrixAchatTTC ;
@FXML private TextField AjouterProduittvaAchat ;
@FXML private TextField AjouterProduitPrixAchatHT ;
@FXML private TextField AjouterProduitMarge ;
@FXML private TextField AjouterProduitPrixVenteTTC ;
@FXML private TextField AjouterProduittvaVente ;
@FXML private TextField AjouterProduitPrixVenteHT ;
@FXML private TextField AjouterProduitPoids ;
@FXML private TextField AjouterProduitDimensions;
@FXML private TextField AjouterProduitVitesse;
@FXML private TextField AjouterProduitPuissance;
@FXML private TextField AjouterProduitCapacite;
@FXML public TextField AjouterProduitcategorie ;
@FXML private ColorPicker AjouterProduitCouleur ;
@FXML private TextArea TextAreaDescription ;
@FXML private Text ErreurReference ;
@FXML private Text ErreurDesignation ;
@FXML private Text ErreurPrixVenteHT;
@FXML private Text ErreurtvaVente ;
@FXML private Text ErreurPrixVenteTTC;
@FXML private Text ErreurGarantie ;
@FXML private Text Erreurcategorie ;
@FXML private Text ErreurMarque ;
@FXML private Text ErreurCodeBarre;
@FXML private Text ErreurPrixAchatHT;
@FXML private Text ErreurtvaAchat ;
@FXML private Text ErreurPrixAchatTTC;
@FXML private Text ErreurMarge;
@FXML private Text TextCurrencySign;
@FXML private GridPane GridPaneSuccessAddProd;
@FXML private Button ButtonResetFormProduit;
@FXML private Text TextSuccessAddProd;
private Service<Void> ThreadAjouterProduit;
String address = " ";
contro ctl= new contro() ;
Produit prod = new Produit();
ProduitDB dbproduit = new ProduitDB();
CategorieDB dbcategorie = new CategorieDB();
@Override
public void initialize(URL url, ResourceBundle rb) {
TextSuccessAddProd.setFont(Font.loadFont(getClass().getResourceAsStream("/Public/Fonts/Raleway-SemiBold.ttf"), 20));
setCategorieFormData();
TextCurrencySign.setText(ParametreSystem.CurrencySign);
AjouterProduittvaAchat.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke){
if(!ctl.isFloatNotnull(AjouterProduitPrixAchatHT.getText()) && !ctl.isFloatNotnull(AjouterProduittvaAchat.getText())){
float prixachatht = Adaptateur.StringToFloat(AjouterProduitPrixAchatHT.getText());
float tvavente = Adaptateur.StringToFloat(AjouterProduittvaAchat.getText());
float prixachatttc = prixachatht + (prixachatht*tvavente)/100 ;
AjouterProduitPrixAchatTTC.setText(Adaptateur.ArrondFloatToString(prixachatttc));
}
}
});
AjouterProduitMarge.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke){
if(!ctl.isFloatNotnull(AjouterProduitPrixAchatTTC.getText().replace(',','.')) && !ctl.isFloatNotnull(AjouterProduitMarge.getText().replace(',','.')) ){
float marge = Adaptateur.StringToFloat(AjouterProduitMarge.getText());
float prixachatttc = Adaptateur.StringToFloat(AjouterProduitPrixAchatTTC.getText());
float prixventht = prixachatttc + (prixachatttc*marge)/100 ;
AjouterProduitPrixVenteHT.setText(Adaptateur.ArrondFloatToString(prixventht));
}
}
});
AjouterProduittvaVente.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke){
if(!ctl.isFloatNotnull(AjouterProduitPrixVenteHT.getText().replace(',','.')) && !ctl.isFloatNotnull(AjouterProduittvaVente.getText().replace(',','.'))){
float prixventht = Adaptateur.StringToFloat(AjouterProduitPrixVenteHT.getText());
float tvavente = Adaptateur.StringToFloat(AjouterProduittvaVente.getText());
float prixventttc = prixventht + ((prixventht*tvavente)/100) ;
//System.out.println("Prix H.T: "+prixventht*6+" TVA: "+((prixventht*tvavente)/100)*6+" PrixTTC"+prixventttc*6);
AjouterProduitPrixVenteTTC.setText(Adaptateur.ArrondFloatToString(prixventttc));
}
}
});
}
//ajouter un nouvelle catégorie
@FXML
private void AjouterCategorieButtonAction(ActionEvent event) throws IOException {
final AjouterCategorieController AjouterCategorie = new AjouterCategorieController();
AjouterCategorie.Show();
AjouterCategorie.ButtonAjouterCategory.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
String NewCategory = AjouterCategorie.AjouterCategorieTraitement();
AjouterProduitcategorie.setText(NewCategory);
}
});
}
@FXML
private void AjouterProduitButtonAction(ActionEvent event) throws IOException {
if( ctl.ContrNull(AjouterProduitReference,ErreurReference) &&
ctl.ContrNull(AjouterProduitdesignation, ErreurDesignation)&&
ctl.ContrNull(AjouterProduitcategorie, Erreurcategorie)&&
ctl.ContrNull(AjouterProduitMarque, ErreurMarque)&&
ctl.ContrNumerique(AjouterProduitGarantie, ErreurGarantie)&&
ctl.ContrReelNotNull(AjouterProduitPrixAchatHT, ErreurPrixAchatHT)&&
ctl.ContrReelNotNull(AjouterProduittvaAchat, ErreurtvaAchat)&&
ctl.ContrReelNotNull(AjouterProduitPrixAchatTTC, ErreurPrixAchatTTC)&&
ctl.ContrReelNotNull(AjouterProduitMarge, ErreurMarge) &&
ctl.ContrReelNotNull(AjouterProduitPrixVenteHT, ErreurPrixVenteHT)&&
ctl.ContrReelNotNull(AjouterProduittvaVente, ErreurtvaVente)&&
ctl.ContrReelNotNull(AjouterProduitPrixVenteTTC, ErreurPrixVenteTTC) &&
ControleReferenceDB() && ControleCodeBarreDB()){
if(!new CategorieDB().verifyCategorie(AjouterProduitcategorie.getText())){
Erreurcategorie.setText("categorie n'existe pas");
Erreurcategorie.setStyle("-fx-border-color:#f20606;");
}else{
this.getProduit();
if(dbproduit.addProduit(prod)){ //l'insertion des données dont la Base des données et afficher le message du succés
FadeTransition ft = new FadeTransition(Duration.millis(400), AnchorPaneAjouterProduit);
ft.setFromValue(1.0);
ft.setToValue(0.0);
ft.play();
ft.setOnFinished(new EventHandler<ActionEvent>() {
//message de succés
@Override
public void handle(ActionEvent event)
{
GridPaneSuccessAddProd.setVisible(true);
ButtonResetFormProduit.setOnAction(new EventHandler<ActionEvent>() { //supprimer le message du suucés et reaficher les formulaires
@Override
public void handle(ActionEvent event) {
GridPaneSuccessAddProd.setVisible(false);
FadeTransition ft = new FadeTransition(Duration.millis(400), AnchorPaneAjouterProduit);
ft.setFromValue(0.0);
ft.setToValue(1.0);
ft.play();
restechamp();
}
});
}
});
}
else{
ShowDialog SD = new ShowDialog();
SD.ShowAletDialog();
}
}
}
}
private boolean ControleReferenceDB()
{
if(dbproduit.verifyReferenceProduit(AjouterProduitReference.getText()))
{
ErreurReference.setText("référence existe déja");
AjouterProduitReference.setStyle("-fx-border-color:#f20606;");
return false;
}else{
ErreurReference.setText("");
AjouterProduitReference.setStyle(null);
return true;
}
}
private boolean ControleCodeBarreDB()
{
if(!ctl.isStringNull(AjouterProduitCodeBarre.getText()))
{
if(dbproduit.verifyCodeBarreProduit(AjouterProduitCodeBarre.getText()))
{
ErreurCodeBarre.setText("Code Barre existe déja");
AjouterProduitCodeBarre.setStyle("-fx-border-color:#f20606;");
return false;
}else{
ErreurCodeBarre.setText("");
AjouterProduitCodeBarre.setStyle(null);
return true;
}
}
ErreurCodeBarre.setText("");
AjouterProduitCodeBarre.setStyle(null);
return true;
}
//récuperation des formulaire dans l'objet Produit
private void getProduit()
{
prod.setReference(AjouterProduitReference.getText());
prod.setCodebarre(AjouterProduitCodeBarre.getText());
prod.setDesignation(AjouterProduitdesignation.getText());
prod.setCategorie(AjouterProduitcategorie.getText());
prod.setGarantieString(AjouterProduitGarantie.getText());
prod.setMarque(AjouterProduitMarque.getText());
prod.setPrixachatttc(AjouterProduitPrixAchatTTC.getText());
prod.setPrixachatht(AjouterProduitPrixAchatHT.getText());
prod.setTvaachat(AjouterProduittvaAchat.getText());
prod.setMarge(AjouterProduitMarge.getText());
prod.setPrixventettc(AjouterProduitPrixVenteTTC.getText());
prod.setPrixventeht(AjouterProduitPrixVenteHT.getText());
prod.setTvavente(AjouterProduittvaVente.getText());
prod.setPoids(AjouterProduitPoids.getText());
prod.setCapacite(AjouterProduitCapacite.getText());
prod.setDimensions(AjouterProduitDimensions.getText());
prod.setVitesse(AjouterProduitVitesse.getText());
prod.setPuissance(AjouterProduitPuissance.getText());
prod.setCouleur(AjouterProduitCouleur.getValue().toString());
prod.setDescription(TextAreaDescription.getText());
}
private void restechamp()
{
AjouterProduitReference.setText("");
AjouterProduitCodeBarre.setText("");
AjouterProduitdesignation.setText("");
AjouterProduitGarantie.setText("");
AjouterProduitcategorie.setText("");
AjouterProduittvaAchat.setText("");
AjouterProduitPrixAchatHT.setText("");
AjouterProduitPrixVenteHT.setText("");
AjouterProduittvaVente.setText("");
AjouterProduitGarantie.setText("");
AjouterProduitMarque.setText("");
AjouterProduitPoids.setText("");
AjouterProduitPrixAchatTTC.setText("");
AjouterProduitPrixVenteTTC.setText("");
AjouterProduitMarge.setText("");
AjouterProduitDimensions.setText("");
AjouterProduitVitesse.setText("");
AjouterProduitPuissance.setText("");
AjouterProduitCapacite.setText("");
AjouterProduitCouleur.setValue(Color.TRANSPARENT);
TextAreaDescription.setText("");
}
private void setCategorieFormData()
{
ProgressBarAjouterProduit.setVisible(true);
ThreadAjouterProduit = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
TextFields.bindAutoCompletion(AjouterProduitcategorie, new CategorieDB().getListCategorie());
return null;
}
};
}
};
ThreadAjouterProduit.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarAjouterProduit.setVisible(false);
}
});
ThreadAjouterProduit.start();
}
}
@@ -0,0 +1,487 @@
package Controllers.Produit;
import Models.Categorie.CategorieDB;
import Models.Produit.Produit;
import Models.Produit.ProduitDB;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
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.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.Label;
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.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 GestionProduitController implements Initializable {
@FXML private Button addProduit ;
@FXML private Button ButtonSearchProduit ;
@FXML private Label LabelCount ;
@FXML private ChoiceBox NbrLigne ;
@FXML private AnchorPane AnchorPaneGestionClt;
@FXML private AnchorPane ListerPages;
@FXML private ProgressBar ProgressBarProduit;
@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 AnchorPane AnchorPaneProduit;
@FXML private TextField GestionProduitReference ;
@FXML private TextField GestionProduitCodeBarre;
@FXML private TextField GestionProduitCategorie;
@FXML private TextField GestionProduitDesignation;
@FXML private TableView<Produit> TableViewListeGestionProduit ;
@FXML private TableColumn<Produit ,String> TabColReference;
@FXML private TableColumn<Produit ,String> TabColDesignation;
@FXML private TableColumn<Produit ,String> TabColMarque ;
@FXML private TableColumn<Produit ,String> TabColCategorie;
@FXML private TableColumn<Produit ,String> TabColPrixTTC;
@FXML private TableColumn<Produit ,String> TabColQuantite;
@FXML private TableColumn<Produit, Boolean> TabColAction ;
private Service<Void> ThreadSearchProduit;
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;
public static String refprod ;
ProduitDB ProdDB =new ProduitDB();
@Override
public void initialize(URL url, ResourceBundle rb) {
getCategorie();
//comboboxnombre des lignes tableview
NbrLigne.setItems(cursors);
NbrLigne.getSelectionModel().selectFirst();
this.AjouterProduit();
TabColReference.setCellValueFactory(new PropertyValueFactory<Produit, String>("reference"));
TabColDesignation.setCellValueFactory(new PropertyValueFactory<Produit, String>("designation"));
TabColMarque.setCellValueFactory(new PropertyValueFactory<Produit, String>("marque"));
TabColCategorie.setCellValueFactory(new PropertyValueFactory<Produit, String>("categorie"));
TabColPrixTTC.setCellValueFactory(new PropertyValueFactory<Produit, String>("prixventettc"));
TabColQuantite.setCellValueFactory(new PropertyValueFactory<Produit, String>("quantite"));
TabColQuantite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColQuantite.getStyleClass().add("Center");
TabColAction.setSortable(true);
TabColAction.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColAction.getStyleClass().add("Center");
TabColAction.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Produit, Boolean>,ObservableValue<Boolean>>(){
@Override
public ObservableValue<Boolean> call(TableColumn.CellDataFeatures<Produit, Boolean> p) {
return new SimpleBooleanProperty(p.getValue() != null);
}
});
// create a cell value factory with an add button for each row in the table.
TabColAction.setCellFactory(new Callback<TableColumn<Produit, Boolean>, TableCell<Produit, Boolean>>() {
@Override
public TableCell<Produit, Boolean> call(TableColumn<Produit, Boolean> personBooleanTableColumn) {
return new ButtonCell();
}
});
//double clique sur une ligne
TableViewListeGestionProduit.setOnMouseClicked(new EventHandler<javafx.scene.input.MouseEvent>(){
public void handle(MouseEvent event){
if(event.getClickCount()>1){
if(TableViewListeGestionProduit.getSelectionModel().getSelectedIndex()>=0){
//System.out.println(getCode());
GestionProduitController.refprod=TableViewListeGestionProduit.getSelectionModel().getSelectedItem().getReference();
AnchorPaneProduit.getChildren().clear();
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Produit/ModifierProduit.fxml"));
Parent root = (Parent)fxmlLoader.load();
AnchorPaneProduit.getChildren().add(root);
} catch (IOException ex) {
Logger.getLogger(GestionProduitController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
});
GestionSearchProduit();
ButtonSearchProduit.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchProduit();
}
});
AnchorPaneProduit.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchProduit();
}
}
});
}
private void getCategorie()
{
ProgressBarProduit.setVisible(true);
ThreadSearchProduit = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
TextFields.bindAutoCompletion(GestionProduitCategorie, new CategorieDB().getListCategorie());
return null;
}
};
}
};
ThreadSearchProduit.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarProduit.setVisible(false);
}
});
ThreadSearchProduit.start();
}
private void AjouterProduit()
{
addProduit.getStyleClass().add("btn-success");
Image coffeeImage = new Image(getClass().getResourceAsStream("/Public/icon/iconadd.png"));
ImageView buttonGraphic = new ImageView();
buttonGraphic.setImage(coffeeImage);
addProduit.setGraphic(buttonGraphic);
addProduit.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent e) {
try {
AnchorPaneProduit.getChildren().clear();
AnchorPaneProduit.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Produit/AjouterProduit.fxml")));
} catch (IOException ex) {
Logger.getLogger(GestionProduitController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
//Define the button cell
private class ButtonCell extends TableCell<Produit, Boolean> {
final Button cellButton = new Button();
ButtonCell(){
cellButton.getStyleClass().add("btn-icon-primary");
Image coffeeImage = new Image(getClass().getResourceAsStream("/Public/icon/iconedit.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) {
// get Selected Item
Produit currentPerson = (Produit) ButtonCell.this.getTableView().getItems().get(ButtonCell.this.getIndex());
GestionProduitController.refprod=currentPerson.getReference();
AnchorPaneProduit.getChildren().clear();
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Produit/ModifierProduit.fxml"));
Parent root = (Parent)fxmlLoader.load();
AnchorPaneProduit.getChildren().add(root);
} catch (IOException ex) {
Logger.getLogger(GestionProduitController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
//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 getCategorieProduitOnclick()
{
GestionProduitCategorie.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if(totalcount<10){
ListerPages.setVisible(false);
}
else{
ListerPages.setVisible(true);
}
SearchProduit();
}
});
GestionProduitCategorie.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
SearchProduit();
}
});
}
/****************************************************************************** *
* *
* Methode last Next TableView client Entreprise *
* * *
******************************************************************************/
private void SearchProduit()
{
ProgressBarProduit.setVisible(true);
ButtonSearchProduit.setDisable(true);
ThreadSearchProduit = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
position = 0;
actuellepage = 1;
ObservableList<Produit> ListProduits = new ProduitDB().SearchProduit(position, nbrligne, true, GestionProduitReference.getText(), GestionProduitCategorie.getText(), GestionProduitCodeBarre.getText(), GestionProduitDesignation.getText());
TableViewListeGestionProduit.setItems(ListProduits);
totalcount = new ProduitDB().nbrSearchProduit(true, GestionProduitReference.getText(), GestionProduitCategorie.getText(), GestionProduitCodeBarre.getText(), GestionProduitDesignation.getText());
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;
}
};
}
};
ThreadSearchProduit.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarProduit.setVisible(false);
ButtonSearchProduit.setDisable(false);
LabelCount.setText(totalcount.toString());
}
});
ThreadSearchProduit.start();
}
private void NextLastSearchProduit(Integer ParmPosition, Integer ParamNbrligne)
{
ProgressBarProduit.setVisible(true);
ButtonSearchProduit.setDisable(true);
ThreadSearchProduit = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{//
ObservableList<Produit> ListProduits = new ProduitDB().SearchProduit(ParmPosition, ParamNbrligne, true, GestionProduitReference.getText(), GestionProduitCategorie.getText(), GestionProduitCodeBarre.getText(), GestionProduitDesignation.getText());
TableViewListeGestionProduit.setItems(ListProduits);
return null;
}
};
}
};
ThreadSearchProduit.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarProduit.setVisible(false);
ButtonSearchProduit.setDisable(false);
}
});
ThreadSearchProduit.start();
}
private void GestionSearchProduit()
{
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;
NextLastSearchProduit(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;
NextLastSearchProduit(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;
NextLastSearchProduit(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;
NextLastSearchProduit(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;
NextLastSearchProduit(position, nbrligne);
actuellepage=actuellepage-3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
}
}
@@ -0,0 +1,297 @@
package Controllers.Produit;
import Controllers.Traitement.contro;
import Models.Categorie.CategorieDB;
import Models.Produit.Produit;
import Models.Produit.ProduitDB;
import java.io.IOException;
import java.math.RoundingMode;
import java.net.URL;
import java.text.DecimalFormat;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.animation.FadeTransition;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ColorPicker;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.util.Duration;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class ModifierProduitController implements Initializable {
/**
* Initializes the controller class.
*/
public String Reference = GestionProduitController.refprod;
//private AnchorPane Content ;
@FXML private AnchorPane AnchorPaneModifierprod ;
@FXML private AnchorPane AnchorPaneModifierProduit ;
@FXML private TextField ModifierProduitReference;
@FXML private TextField ModifierProduitCodeBarre;
@FXML private TextField ModifierProduitdesignation ;
@FXML private TextField ModifierProduitGarantie ;
@FXML private TextField ModifierProduitMarque ;
@FXML private ComboBox ModifierProduitcategorie ;
@FXML private ColorPicker ModifierProduitCouleur ;
@FXML private TextArea ModifierProduitDescription ;
@FXML private TextField ModifierProduitPrixAchatTTC ;
@FXML private TextField ModifierProduittvaAchat ;
@FXML private TextField ModifierProduitPrixAchatHT ;
@FXML private TextField ModifierProduitMarge ;
@FXML private TextField ModifierProduitPrixVenteTTC ;
@FXML private TextField ModifierProduittvaVente ;
@FXML private TextField ModifierProduitPrixVenteHT ;
@FXML private TextField ModifierProduitPoids ;
@FXML private TextField ModifierProduitDimensions;
@FXML private TextField ModifierProduitVitesse;
@FXML private TextField ModifierProduitPuissance;
@FXML private TextField ModifierProduitCapacite;
@FXML private Text ErreurReference ;
@FXML private Text ErreurCodeBarre ;
@FXML private Text ErreurDesignation ;
@FXML private Text ErreurGarantie ;
@FXML private Text Erreurcategorie ;
@FXML private Text ErreurMarque ;
@FXML private Text ErreurPrixAchatHT ;
@FXML private Text ErreurtvaAchat ;
@FXML private Text ErreurPrixAchatTTC ;
@FXML private Text ErreurMarge ;
@FXML private Text ErreurPrixVenteHT ;
@FXML private Text ErreurtvaVente ;
@FXML private Text ErreurPrixVenteTTC ;
contro ctl= new contro() ;
Produit prod = new Produit();
ProduitDB dbproduit = new ProduitDB();
CategorieDB dbcategorie = new CategorieDB();
DecimalFormat df = new DecimalFormat("#.000");
@Override
public void initialize(URL url, ResourceBundle rb) {
//liste categorie
ModifierProduitcategorie.getItems().addAll(dbcategorie.getListCategorie());
prod = dbproduit.getProduit(Reference);
ModifierProduitReference.setText(prod.getReference());
ModifierProduitMarque.setText(prod.getMarque()) ;
ModifierProduitGarantie.setText(String.valueOf(prod.getGarantie())) ;
ModifierProduitdesignation.setText(prod.getDesignation()) ;
ModifierProduitcategorie.setValue(prod.getCategorie()) ;
df.setMaximumFractionDigits(3);
ModifierProduitPrixAchatHT.setText(prod.getPrixachatht());
ModifierProduittvaAchat.setText(prod.getTvaachat()) ;
ModifierProduitPrixAchatTTC.setText(prod.getPrixachatttc());
ModifierProduitMarge.setText(prod.getMarge()) ;
ModifierProduitPrixVenteHT.setText(prod.getPrixventeht()) ;
ModifierProduittvaVente.setText(prod.getTvavente());
ModifierProduitPrixVenteTTC.setText(prod.getPrixventettc()) ;
Color c = Color.web(prod.getCouleur());
ModifierProduitCouleur.setValue(c) ;
ModifierProduitDescription.setText(prod.getDescription()) ;
ModifierProduitCodeBarre.setText(prod.getCodebarre());
ModifierProduitPoids.setText(prod.getPoids()) ;
ModifierProduitDimensions.setText(prod.getDimensions());
ModifierProduitVitesse.setText(prod.getVitesse());
ModifierProduitPuissance.setText(prod.getPuissance());
ModifierProduitCapacite.setText(prod.getCapacite());
ModifierProduittvaAchat.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke){
if(!ctl.isFloatNotnull(ModifierProduitPrixAchatHT.getText()) && !ctl.isFloatNotnull(ModifierProduittvaAchat.getText())){
float prixachatht = Float.parseFloat(ModifierProduitPrixAchatHT.getText().replace(',','.'));
float tvavente = Float.parseFloat(ModifierProduittvaAchat.getText().replace(',','.'));
float prixachatttc = prixachatht + (prixachatht*tvavente)/100 ;
df.setRoundingMode(RoundingMode.DOWN);
ModifierProduitPrixAchatTTC.setText(df.format(prixachatttc).replace(',','.'));
}
}
});
ModifierProduitMarge.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke){
if(!ctl.isFloatNotnull(ModifierProduitPrixAchatTTC.getText()) && !ctl.isFloatNotnull(ModifierProduitMarge.getText()) ){
float marge = Float.parseFloat(ModifierProduitMarge.getText().replace(',','.'));
float prixachatttc = Float.parseFloat(ModifierProduitPrixAchatTTC.getText().replace(',','.'));
float prixventht = prixachatttc + (prixachatttc*marge)/100 ;
df.setRoundingMode(RoundingMode.DOWN);
ModifierProduitPrixVenteHT.setText(df.format(prixventht).replace(',','.'));
}
}
});
ModifierProduittvaVente.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke){
if(!ctl.isFloatNotnull(ModifierProduitPrixVenteHT.getText()) && !ctl.isFloatNotnull(ModifierProduittvaVente.getText())){
float prixventht = Float.parseFloat(ModifierProduitPrixVenteHT.getText().replace(',','.'));
float tvavente = Float.parseFloat(ModifierProduittvaVente.getText().replace(',','.'));
float prixventttc = prixventht + (prixventht*tvavente)/100 ;
df.setRoundingMode(RoundingMode.DOWN);
ModifierProduitPrixVenteTTC.setText(df.format(prixventttc).replace(',','.'));
}
}
});
}
@FXML
private void ModifierProduitButtonAction(ActionEvent event) throws IOException {
if( ctl.ContrNull(ModifierProduitReference,ErreurReference) &&
ctl.ContrNull(ModifierProduitdesignation, ErreurDesignation)&&
ctl.ContrNullValue(ModifierProduitcategorie, Erreurcategorie)&&
ctl.ContrNull(ModifierProduitMarque, ErreurMarque)&&
ctl.ContrNumerique(ModifierProduitGarantie, ErreurGarantie)&&
ctl.ContrNumerique(ModifierProduitCodeBarre, ErreurCodeBarre)&&
ctl.ContrReelNotNull(ModifierProduitPrixAchatHT, ErreurPrixAchatHT)&&
ctl.ContrReelNotNull(ModifierProduittvaAchat, ErreurtvaAchat)&&
ctl.ContrReelNotNull(ModifierProduitPrixAchatTTC, ErreurPrixAchatTTC)&&
ctl.ContrReelNotNull(ModifierProduitMarge, ErreurMarge) &&
ctl.ContrReelNotNull(ModifierProduitPrixVenteHT, ErreurPrixVenteHT)&&
ctl.ContrReelNotNull(ModifierProduittvaVente, ErreurtvaVente)&&
ctl.ContrReelNotNull(ModifierProduitPrixVenteTTC, ErreurPrixVenteTTC) ){
if(dbproduit.UpdateProduit(getProduit(),Reference)==1){
FadeTransition ft = new FadeTransition(Duration.millis(400), AnchorPaneModifierProduit);
ft.setFromValue(1.0);
ft.setToValue(0.0);
ft.play();
ft.setOnFinished(new EventHandler<ActionEvent>() {
//message de succés
@Override
public void handle(ActionEvent event) {
Image success = new Image(getClass().getResourceAsStream("/Public/icon/successfully.png"));
ImageView iv1 = new ImageView();
iv1.setImage(success);
Text text= new Text();
text.setText("La modification a été effectuée avec succès");
text.setFont(Font.loadFont(getClass().getResourceAsStream("/Public/Fonts/Raleway-SemiBold.ttf"), 20));
Button buttonOk = new Button("OK");
buttonOk.getStyleClass().add("btn-primary");
buttonOk.setPrefSize(100, 30);
final StackPane stackpane = new StackPane();
stackpane.setLayoutX(140);
stackpane.setLayoutY(100);
stackpane.setPrefHeight(200);
stackpane.setPrefWidth(200);
stackpane.getChildren().add(iv1);
stackpane.getChildren().add(text);
stackpane.getChildren().add(buttonOk);
StackPane.setAlignment(iv1, Pos.BASELINE_CENTER);
StackPane.setAlignment(text, Pos.TOP_CENTER);
StackPane.setAlignment(buttonOk, Pos.CENTER);
AnchorPaneModifierprod.setLeftAnchor(stackpane, 83.0);
AnchorPaneModifierprod.setRightAnchor(stackpane, 83.0);
AnchorPaneModifierprod.setTopAnchor(stackpane,220.0);
AnchorPaneModifierprod.setBottomAnchor(stackpane,220.0);
AnchorPaneModifierprod.getChildren().add(stackpane);
buttonOk.setOnAction(new EventHandler<ActionEvent>() { //supprimer le message du suucés et reaficher les formulaires
@Override
public void handle(ActionEvent event) {
stackpane.setVisible(false);
try {
AnchorPaneModifierprod.getChildren().clear();
AnchorPaneModifierprod.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Produit/GestionProduit.fxml")));
} catch (IOException ex) {
Logger.getLogger(GestionProduitController.class.getName()).log(Level.SEVERE, null, ex);
}
FadeTransition ft = new FadeTransition(Duration.millis(400), AnchorPaneModifierprod);
ft.setFromValue(0.0);
ft.setToValue(1.0);
ft.play();
}
});
}
});
}
}
}
private Produit getProduit()
{
Produit prodUpdate = new Produit();
prodUpdate.setReference(ModifierProduitReference.getText());
prodUpdate.setCodebarre(ModifierProduitCodeBarre.getText());
prodUpdate.setDesignation(ModifierProduitdesignation.getText());
prodUpdate.setCategorie(ModifierProduitcategorie.getValue().toString());
prodUpdate.setGarantieString(ModifierProduitGarantie.getText());
prodUpdate.setMarque(ModifierProduitMarque.getText());
prodUpdate.setPrixachatttc(ModifierProduitPrixAchatTTC.getText().replace(',','.'));
prodUpdate.setPrixachatht(ModifierProduitPrixAchatHT.getText().replace(',','.'));
prodUpdate.setTvaachat(ModifierProduittvaAchat.getText().replace(',','.'));
prodUpdate.setMarge(ModifierProduitMarge.getText().replace(',','.'));
prodUpdate.setPrixventettc(ModifierProduitPrixVenteTTC.getText().replace(',','.'));
prodUpdate.setPrixventeht(ModifierProduitPrixVenteHT.getText().replace(',','.'));
prodUpdate.setTvavente(ModifierProduittvaVente.getText().replace(',','.'));
prodUpdate.setPoids(ModifierProduitPoids.getText());
prodUpdate.setCapacite(ModifierProduitCapacite.getText());
prodUpdate.setDimensions(ModifierProduitDimensions.getText());
prodUpdate.setVitesse(ModifierProduitVitesse.getText());
prodUpdate.setPuissance(ModifierProduitPuissance.getText());
prodUpdate.setCouleur(ModifierProduitCouleur.getValue().toString());
prodUpdate.setDescription(ModifierProduitDescription.getText());
return prodUpdate ;
}
}
@@ -0,0 +1,470 @@
package Controllers.Produit;
import Models.Produit.Produit;
import Controllers.DevisClt.DevisAjouterController;
import Controllers.Traitement.MyWindow;
import Models.Categorie.CategorieDB;
import Models.Produit.ProduitDB;
import Models.User.User;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
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.scene.Group;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
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.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import org.controlsfx.control.textfield.TextFields;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class RechercherProduitController {
@FXML public AnchorPane anchorpane ;
@FXML private ProgressBar ProgressBarProduit;
@FXML private Button ButtonSearchProduit;
@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 ;
@FXML private TextField GestionProduitReference ;
@FXML private TextField GestionProduitDesignation;
@FXML private TextField GestionProduitCodeBarre;
@FXML private TextField GestionProduitCategorie;
@FXML private TableView<Produit> TableViewListeGestionProduit ;
@FXML private TableColumn<Produit ,String> TabColReference;
@FXML private TableColumn<Produit ,String> TabColDesignaton;
@FXML private TableColumn<Produit ,String> TabColMarque ;
@FXML private TableColumn<Produit ,String> TabColCategorie;
@FXML private TableColumn<Produit ,String> TabColPrixAchatTTC;
@FXML private TableColumn<Produit ,String> TabColPrixVenteTTC;
@FXML private TableColumn<Produit ,String> TabColQuantite;
@FXML public TableColumn<Produit ,String> TabColAction ;
@FXML private AnchorPane PaneStockNegaNon;
@FXML private Text TextEnStock;
@FXML private RadioButton StockNegaOui;
@FXML private RadioButton StockNegaNon;
public Node nodeFxml ;
private Boolean StockNegatif = false;
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;
public static String refprod ;
public Object[] ArrayObjectDataSave = new Object[10];
private Service<Void> ThreadSearchRerchecheProduit;
public RechercherProduitController(Boolean TypePrixTTC) { //TypePrixTTC true Vente | false Achat
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Produit/RechercherProduit.fxml"));
fxmlLoader.setController(this);
nodeFxml = (Node) fxmlLoader.load();
NbrLigne.setItems(cursors);
NbrLigne.getSelectionModel().selectFirst();
TextFields.bindAutoCompletion(GestionProduitCategorie, new CategorieDB().getListCategorie());
TabColReference.setCellValueFactory(new PropertyValueFactory<Produit, String>("reference"));
TabColDesignaton.setCellValueFactory(new PropertyValueFactory<Produit, String>("designation"));
TabColMarque.setCellValueFactory(new PropertyValueFactory<Produit, String>("marque"));
TabColCategorie.setCellValueFactory(new PropertyValueFactory<Produit, String>("categorie"));
TabColPrixAchatTTC.setCellValueFactory(new PropertyValueFactory<Produit, String>("prixachatttc"));
TabColPrixAchatTTC.setStyle( "-fx-alignment: CENTER;");
TabColPrixAchatTTC.getStyleClass().add("Center");
TabColPrixVenteTTC.setCellValueFactory(new PropertyValueFactory<Produit, String>("prixventettc"));
TabColPrixVenteTTC.setStyle( "-fx-alignment: CENTER;");
TabColPrixVenteTTC.getStyleClass().add("Center");
if(TypePrixTTC){
TabColPrixVenteTTC.setVisible(true);
TabColPrixAchatTTC.setVisible(false);
}else{
TabColPrixAchatTTC.setVisible(true);
TabColPrixVenteTTC.setVisible(false);
}
TabColQuantite.setCellValueFactory(new PropertyValueFactory<Produit, String>("quantite"));
TabColQuantite.setStyle( "-fx-alignment: CENTER;");
TabColQuantite.getStyleClass().add("Center");
TabColAction.setStyle( "-fx-alignment: CENTER;");
TabColAction.getStyleClass().add("Center");
if(TypePrixTTC){//Vente Stock peux être négatif table produit
if(User.SotckNegatif){ //L'utilisateur à le droit de vente en négative
PaneStockNegaNon.setVisible(true);
TextEnStock.setVisible(true);
}
}else{ //Achat table produit
PaneStockNegaNon.setVisible(true);
TextEnStock.setVisible(true);
}
//table stock
StockNegaOui.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
StockNegatif = false;
SearchProduit();
}
});
//table produit
StockNegaNon.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
StockNegatif = true;
SearchProduit();
}
});
ButtonSearchProduit.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchProduit();
}
});
anchorpane.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchProduit();
}
}
});
GestionSearchProduit();
} catch (IOException ex) {
Logger.getLogger(RechercherProduitController.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void Show()
{
StackPane Sp = new StackPane();
Scene scene = new Scene(Sp);
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Stage stage = MyWindow.myStage;
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(nodeFxml);
stage.setScene(scene);
stage.show();
}
//Define the button cell
private class ButtonCell extends TableCell<Produit, 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) {
try {
// get Selected ItemButtonCell
Produit currentPerson = (Produit) ButtonCell.this.getTableView().getItems().get(ButtonCell.this.getIndex());
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Devis/DevisAjouter.fxml"));
Parent devis = (Parent) fxmlLoader.load();
DevisAjouterController devisajouter = fxmlLoader.getController();
devisajouter.SetProduit(currentPerson.getReference());
MyWindow mywindows = new MyWindow();
mywindows.Refresh(devis, 3);
} catch (IOException ex) {
Logger.getLogger(RechercherProduitController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
//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 QuiterButtonAction(ActionEvent event) throws IOException {
anchorpane.setVisible(false);
}
/****************************************************************************** *
* *
* Methode last Next TableView *
* * *
******************************************************************************/
private void SearchProduit()
{
ProgressBarProduit.setVisible(true);
ButtonSearchProduit.setDisable(true);
ThreadSearchRerchecheProduit = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
position = 0;
actuellepage = 1;
ObservableList<Produit> ListeCltPersonne = new ProduitDB().SearchProduit(
position,
nbrligne,
StockNegatif,
GestionProduitReference.getText(),
GestionProduitCategorie.getText(),
GestionProduitCodeBarre.getText(),
GestionProduitDesignation.getText());
TableViewListeGestionProduit.setItems(null);
TableViewListeGestionProduit.refresh();
TableViewListeGestionProduit.setItems(ListeCltPersonne);
totalcount = new ProduitDB().nbrSearchProduit(StockNegatif, GestionProduitReference.getText(), GestionProduitCategorie.getText(), GestionProduitCategorie.getText(), GestionProduitDesignation.getText());
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;
}
};
}
};
ThreadSearchRerchecheProduit.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarProduit.setVisible(false);
ButtonSearchProduit.setDisable(false);
LabelCount.setText(totalcount.toString());
}
});
ThreadSearchRerchecheProduit.start();
}
private void NextLastSearchProduit(Integer ParmPosition, Integer ParamNbrligne)
{
ProgressBarProduit.setVisible(true);
ButtonSearchProduit.setDisable(true);
ThreadSearchRerchecheProduit = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
ObservableList<Produit> ListeCltPersonne = new ProduitDB().SearchProduit(
ParmPosition,
ParamNbrligne,
StockNegatif,
GestionProduitReference.getText(),
GestionProduitCategorie.getText(),
GestionProduitCodeBarre.getText(),
GestionProduitDesignation.getText());
TableViewListeGestionProduit.setItems(ListeCltPersonne);
return null;
}
};
}
};
ThreadSearchRerchecheProduit.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarProduit.setVisible(false);
ButtonSearchProduit.setDisable(false);
}
});
ThreadSearchRerchecheProduit.start();
}
private void GestionSearchProduit()
{
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;
NextLastSearchProduit(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;
NextLastSearchProduit(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;
NextLastSearchProduit(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;
NextLastSearchProduit(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;
NextLastSearchProduit(position, nbrligne);
actuellepage=actuellepage-3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
}
}
@@ -0,0 +1,564 @@
package Controllers.Reglement;
import Models.Fournisseur.FournisseurDB;
import Models.Reglement.Reglement;
import Models.Reglement.ReglementDB;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import org.controlsfx.control.textfield.TextFields;
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.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
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.KeyCode;
import javafx.scene.input.KeyEvent;
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;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class GestionReglementController implements Initializable {
@FXML private ProgressBar ProgressBarGestionReglement;
@FXML private Button ButtonSearchGestionReglement;
@FXML private AnchorPane AnchorPaneGestionReglement;
@FXML private TextField TextFieldFournisseur ;
@FXML public TextField TextFieldNumero ;
@FXML public TextField TextFieldMontant ;
@FXML private ComboBox ComboBoxModePaiement;
@FXML private DatePicker DatePickerDatePayer;
@FXML private RadioButton RadioComptant;
@FXML private RadioButton RadioFacilite;
@FXML public TableView<Reglement> TableViewReglementFrs;
@FXML public TableColumn<Reglement ,String> TabColNumero;
@FXML public TableColumn<Reglement ,String> TabColMontant;
@FXML public TableColumn<Reglement ,String> TabColModePaiement;
@FXML public TableColumn<Reglement ,String> TabColFournisseur;
@FXML public TableColumn<Reglement ,String> TabColTypePaiement;
@FXML public TableColumn<Reglement ,String> TabColDatePayement;
@FXML public TableColumn<Reglement ,Boolean> TabColDetail;
@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> ThreadSearchGestionReglement;
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;
public ArrayList<String> ListFournisseur = new ArrayList<>();
ReglementDB reglementDB= new ReglementDB();
DecimalFormat Formatter = new DecimalFormat("##,###.## ");
ObservableList ListPaiement = FXCollections.observableArrayList("Espace", "Chèque", "Carte bancaire", "Traite");
String IdFournisseur = "";
String Paiement = "";
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
setFournisseurFormData();
ComboBoxModePaiement.setItems(ListPaiement);
NbrLigne.setItems(cursors);
NbrLigne.getSelectionModel().selectFirst();
TabColNumero.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColNumero.getStyleClass().add("Center");
TabColNumero.setCellValueFactory(new PropertyValueFactory<Reglement, String>("Numero"));
TabColFournisseur.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColFournisseur.getStyleClass().add("Center");
TabColFournisseur.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Reglement,String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(TableColumn.CellDataFeatures<Reglement, String> data) {
return new SimpleStringProperty(data.getValue().getFournisseur().getNom());
}
});
TabColModePaiement.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColModePaiement.getStyleClass().add("Center");
TabColModePaiement.setCellValueFactory(new PropertyValueFactory<Reglement, String>("ModePaiement"));
TabColModePaiement.setCellFactory(new Callback<TableColumn<Reglement,String>,TableCell<Reglement,String>>(){
@Override
public TableCell<Reglement, String> call(TableColumn<Reglement, String> param) {
TableCell<Reglement, String> cell = new TableCell<Reglement, String>(){
@Override
public void updateItem(String item, boolean empty) {
//0 :espace | 1:Chèque | 2 :carte bancaire | 3: Traite
if(item!= null && item.equals("0")){
Text text = new Text("Espace");
text.setFont(Font.font("Arial", FontWeight.NORMAL, 14));
setGraphic(text);
}else if(item!= null && item.equals("1")){
Text text = new Text("Chèque");
text.setFont(Font.font("Arial", FontWeight.NORMAL, 14));
setGraphic(text);
}else if(item!= null && item.equals("2")){
Text text = new Text("Carte Bancaire");
text.setFont(Font.font("Arial", FontWeight.NORMAL, 14));
setGraphic(text);
}else if(item!= null && item.equals("3")){
Text text = new Text("Traite");
text.setFont(Font.font("Arial", FontWeight.NORMAL, 14));
setGraphic(text);
}else{
setGraphic(null);
}
}
};
return cell;
}
});
TabColMontant.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColMontant.getStyleClass().add("Center");
TabColMontant.setCellValueFactory(new PropertyValueFactory<Reglement, String>("Montant"));
TabColMontant.setCellFactory(new Callback<TableColumn<Reglement,String>,TableCell<Reglement,String>>(){
@Override
public TableCell<Reglement, String> call(TableColumn<Reglement, String> param) {
TableCell<Reglement, String> cell = new TableCell<Reglement, 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;
}
});
TabColTypePaiement.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColTypePaiement.getStyleClass().add("Center");
TabColTypePaiement.setCellValueFactory(new PropertyValueFactory<Reglement, String>("TypePaiement"));
TabColTypePaiement.setCellFactory(new Callback<TableColumn<Reglement,String>,TableCell<Reglement,String>>(){
@Override
public TableCell<Reglement, String> call(TableColumn<Reglement, String> param) {
TableCell<Reglement, String> cell = new TableCell<Reglement, String>(){
@Override
public void updateItem(String item, boolean empty) {
if(item!= null && item.equals("0")){
Text text = new Text("Comptant");
text.setFill(Color.web("#428BCA"));
text.setFont(Font.font("Arial", FontWeight.BOLD, 14));
setGraphic(text);
}else if(item!= null && item.equals("1")){
Text text = new Text("Facilité");
text.setFill(Color.web("#000000"));
text.setFont(Font.font("Arial", FontWeight.BOLD, 14));
setGraphic(text);
}else{
setGraphic(null);
}
}
};
return cell;
}
});
TabColDatePayement.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDatePayement.getStyleClass().add("Center");
TabColDatePayement.setCellValueFactory(new PropertyValueFactory<Reglement, String>("DateTimeCreation"));
TabColDetail.setStyle( "-fx-alignment: CENTER;");TabColDetail.getStyleClass().add("Center");
TabColDetail.setCellFactory(new Callback<TableColumn<Reglement, Boolean>, TableCell<Reglement, Boolean>>() {
@Override
public TableCell<Reglement, Boolean> call(TableColumn<Reglement, 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];
}
}
});
ComboBoxModePaiement.valueProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue ov, String t, String ValLocal) {
//0 :espace | 1:Chèque | 2 :carte bancaire | 3: Traite
if(ValLocal.equals("Espace")){
Paiement = "0";
}else if(ValLocal.equals("Chèque")){
Paiement = "1";
}else if(ValLocal.equals("Carte bancaire")){
Paiement = "2";
}else if(ValLocal.equals("Traite")){
Paiement = "3";
}
}
});
ButtonSearchGestionReglement.setOnMouseClicked(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
SearchGestionReglement();
}
});
AnchorPaneGestionReglement.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchGestionReglement();
}
}
});
GestionSearchGestionReglement();
}
@FXML
private void ReglementAjouterButtonAction(ActionEvent event) throws IOException {
AnchorPaneGestionReglement.getChildren().clear();
AnchorPaneGestionReglement.getChildren().add((Node) FXMLLoader.load(getClass().getResource("/Views/Reglement/ReglementAjouter1.fxml")));
}
private class ButtonCell extends TableCell<Reglement, 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) {
Reglement reglement = ((Reglement)getTableRow().getItem());
ReglementDialogDetailController ReglementDialogDetail = new ReglementDialogDetailController();
ReglementDialogDetail.Show();
ReglementDialogDetail.LanchShowReglement(reglement.getNumero());
}
});
}
//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 setFournisseurFormData()
{
ProgressBarGestionReglement.setVisible(true);
ThreadSearchGestionReglement = 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);
return null;
}
};
}
};
ThreadSearchGestionReglement.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarGestionReglement.setVisible(false);
}
});
ThreadSearchGestionReglement.start();
}
/****************************************************************************** *
* *
* Methode last Next TableView *
* * *
******************************************************************************/
private void SearchGestionReglement()
{
ProgressBarGestionReglement.setVisible(true);
ButtonSearchGestionReglement.setDisable(true);
ThreadSearchGestionReglement = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
position = 0;
actuellepage = 1;
String DatePayer = "";
if(DatePickerDatePayer.getValue() != null){
DatePayer = DatePickerDatePayer.getValue().toString();
}
// 0comptant 1facilité
String TypeRegement = "";
if(RadioComptant.isSelected()){
TypeRegement = "0";
}else if(RadioFacilite.isSelected()){
TypeRegement = "1";
}
ObservableList<Reglement> ListGestionReglements = new ReglementDB().SearchGestionReglementGestion(
position,
nbrligne,
TextFieldNumero.getText(),
IdFournisseur,
TextFieldMontant.getText(),
DatePayer,
TypeRegement,
Paiement);
TableViewReglementFrs.setItems(ListGestionReglements);
totalcount = new ReglementDB().nbrGestionReglementGestion(TextFieldNumero.getText(), IdFournisseur, TextFieldMontant.getText(), DatePayer, TypeRegement, Paiement);
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;
}
};
}
};
ThreadSearchGestionReglement.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarGestionReglement.setVisible(false);
ButtonSearchGestionReglement.setDisable(false);
LabelCount.setText(totalcount.toString());
}
});
ThreadSearchGestionReglement.start();
}
private void NextLastSearchGestionReglement(Integer ParmPosition, Integer ParamNbrligne)
{
ProgressBarGestionReglement.setVisible(true);
ButtonSearchGestionReglement.setDisable(true);
ThreadSearchGestionReglement = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
String DatePayer = "";
if(DatePickerDatePayer.getValue() != null){
DatePayer = DatePickerDatePayer.getValue().toString();
}
// 0comptant 1facilité
String TypeRegement = "";
if(RadioComptant.isSelected()){
TypeRegement = "0";
}else if(RadioFacilite.isSelected()){
TypeRegement = "1";
}
ObservableList<Reglement> ListGestionReglement = new ReglementDB().SearchGestionReglementGestion(ParmPosition, ParamNbrligne, TextFieldNumero.getText(), IdFournisseur, TextFieldMontant.getText(), DatePayer, TypeRegement, Paiement);
TableViewReglementFrs.setItems(ListGestionReglement);
return null;
}
};
}
};
ThreadSearchGestionReglement.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarGestionReglement.setVisible(false);
ButtonSearchGestionReglement.setDisable(false);
}
});
ThreadSearchGestionReglement.start();
}
private void GestionSearchGestionReglement()
{
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;
NextLastSearchGestionReglement(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;
NextLastSearchGestionReglement(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;
NextLastSearchGestionReglement(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;
NextLastSearchGestionReglement(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;
NextLastSearchGestionReglement(position, nbrligne);
actuellepage=actuellepage-3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
}
}
@@ -0,0 +1,418 @@
package Controllers.Reglement;
import Controllers.Dialog.MessageControle;
import Models.FactureFrs.FactureFrs;
import Models.FactureFrs.FactureFrsDB;
import Models.Fournisseur.FournisseurDB;
import Models.Stock.StockDB;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.ResourceBundle;
import javafx.application.Platform;
import javafx.beans.property.SimpleBooleanProperty;
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.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 Ben Tili
*/
public class ReglementAjouter1Controller implements Initializable {
@FXML private AnchorPane AnchorPaneReglementAjouter1;
@FXML private ProgressIndicator ProgressFactureFrs;
@FXML public TableView<FactureFrs> TableViewFactureFrs;
@FXML public TableColumn<FactureFrs ,String> TabColNumero;
@FXML public TableColumn<FactureFrs ,String> TabColFrs;
@FXML public TableColumn<FactureFrs ,String> TabColDate;
@FXML public TableColumn<FactureFrs ,String> TabColLocalReception;
@FXML public TableColumn<FactureFrs ,String> TabColNetPayer;
@FXML public TableColumn<FactureFrs ,Boolean>TabColDetail ;
@FXML public TableView<FactureFrs> TableViewSeleFactureFrs;
@FXML public TableColumn<FactureFrs ,String> TabColSeleNumero;
@FXML public TableColumn<FactureFrs ,String> TabColSeleFrs;
@FXML public TableColumn<FactureFrs ,String> TabColSeleDate;
@FXML public TableColumn<FactureFrs ,String> TabColSeleHeur;
@FXML public TableColumn<FactureFrs ,String> TabColSeleLocalReception;
@FXML public TableColumn<FactureFrs ,String> TabColSeleNetPayer;
@FXML public TableColumn<FactureFrs ,Boolean>TabColSeleSupprimer ;
@FXML public TextField TextFieldNumero ;
@FXML private TextField TextFieldFournisseu ;
@FXML public TextField TextFieldNetAPayer ;
@FXML public DatePicker DatePickerDateReception;
@FXML public ChoiceBox ChoiceBoxLocalReception ;
public ArrayList<String> ListFournisseur = new ArrayList<>();
public ArrayList<String> ListLocale = new ArrayList<>();
ObservableList<FactureFrs> DataSelectFacture = FXCollections.observableArrayList();
public FactureFrsDB FactureDB = new FactureFrsDB();
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
StockDB Stock = new StockDB();
ListLocale = Stock.getAllListLocal();
ChoiceBoxLocalReception.getItems().addAll(ListLocale);
FournisseurDB FrsDB = new FournisseurDB();
ListFournisseur = FrsDB.getAllFournisseur("CONCAT(`id_fourisseur`,' - ',`nom`)");
TextFields.bindAutoCompletion(TextFieldFournisseu, ListFournisseur);
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<TableColumn.CellDataFeatures<FactureFrs,String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(TableColumn.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");
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");
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 ReglementAjouter1Controller.ButtonCell();
}
});
TabColSeleNumero.setCellValueFactory(new PropertyValueFactory<FactureFrs, String>("Numero"));
TabColSeleFrs.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColSeleFrs.getStyleClass().add("Center");
TabColSeleFrs.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<FactureFrs,String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(TableColumn.CellDataFeatures<FactureFrs, String> data) {
return new SimpleStringProperty(data.getValue().getFournisseur().getNom());
}
});
TabColSeleDate.setCellValueFactory(new PropertyValueFactory<FactureFrs, String>("DateCreation"));
TabColSeleDate.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColSeleDate.getStyleClass().add("Center");
TabColSeleHeur.setCellValueFactory(new PropertyValueFactory<FactureFrs, String>("HeurCreation"));
TabColSeleHeur.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColSeleHeur.getStyleClass().add("Center");
TabColSeleLocalReception.setCellValueFactory(new PropertyValueFactory<FactureFrs, String>("Local"));
TabColSeleLocalReception.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColSeleLocalReception.getStyleClass().add("Center");
TabColSeleNetPayer.setCellValueFactory(new PropertyValueFactory<FactureFrs, String>("NetAPayer"));
TabColSeleNetPayer.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColSeleNetPayer.getStyleClass().add("Center");
TabColSeleSupprimer.setStyle( "-fx-alignment: CENTER;");
TabColSeleSupprimer.getStyleClass().add("Center");
TabColSeleSupprimer.setSortable(true);
TabColSeleSupprimer.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<FactureFrs, Boolean>,
ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(TableColumn.CellDataFeatures<FactureFrs, Boolean> p) {
return new SimpleBooleanProperty(p.getValue() != null);
}
});
// create a cell value factory with an add button for each row in the table.
TabColSeleSupprimer.setCellFactory(new Callback<TableColumn<FactureFrs, Boolean>, TableCell<FactureFrs, Boolean>>() {
@Override
public TableCell<FactureFrs, Boolean> call(TableColumn<FactureFrs, Boolean> personBooleanTableColumn) {
return new ReglementAjouter1Controller.ButtonCellRemove();
}
});
getChercherFactureFrs();
}
@FXML
private void DetailReglementButtonAction(ActionEvent event) throws IOException {
if(DataSelectFacture.size()>0){
if(ControleListFacture()){
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Reglement/ReglementAjouter2.fxml"));
Parent NodeReglementAjouter2 = (Parent)fxmlLoader.load();
ReglementAjouter2Controller ReglementAjouter2 = fxmlLoader.getController();
ReglementAjouter2.SetDataFactureFrs(DataSelectFacture);
AnchorPaneReglementAjouter1.getChildren().clear();
AnchorPaneReglementAjouter1.getChildren().add(NodeReglementAjouter2);
}else{
final MessageControle messagecontrol = new MessageControle();
Text text3 = new Text();
text3.setText("Les fournisseurs sélectionnés sont différents");
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();
}
}else{
final MessageControle messagecontrol = new MessageControle();
Text text3 = new Text();
text3.setText("Vous devez ajouter au moin une facture à la liste des factures");
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();
}
}
private void getChercherFactureFrs()
{
TextFieldNumero.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
getDataFactureFrs("numero", " LIKE '"+TextFieldNumero.getText()+"%'");
}
});
DatePickerDateReception.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
try{
getDataFactureFrs("DATE(date_creation)", " = '"+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();
getDataFactureFrs("DATE(date_creation)", " = '"+DateReception+"'");
}catch(Exception ex){}
}
});
ChoiceBoxLocalReception.valueProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue ov, String t, String ValLocal) {
getDataFactureFrs("local_reception", " LIKE '"+ValLocal+"%'");
}
});
TextFieldNetAPayer.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
getDataFactureFrs("net_a_payer", "LIKE '"+TextFieldNetAPayer.getText()+"%'");
}
});
TextFieldFournisseu.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);
getDataFactureFrs("id_fourisseur", " = "+array[0]);
}
}
});
}
public void setDataFactureFrs(ObservableList<FactureFrs> data_facture){
DataSelectFacture = data_facture;
TableViewSeleFactureFrs.setItems(data_facture);
TableViewSeleFactureFrs.refresh();
}
private void getDataFactureFrs(final String tab, final String mot){
ProgressFactureFrs.setVisible(true);
TableViewFactureFrs.setItems(null);
TableViewFactureFrs.setVisible(false);
// Create a Runnable
Runnable task = new Runnable(){
public void run(){
Platform.runLater(new Runnable(){
@Override
public void run(){
try {
ObservableList<FactureFrs> ListFactureFrs = FactureDB.getDataFactureFrs(tab, mot, null, null);
TableViewFactureFrs.setItems(ListFactureFrs);
ProgressFactureFrs.setVisible(false);
TableViewFactureFrs.setVisible(true);
TableViewFactureFrs.refresh();
} catch (Exception ex) {
System.err.println("Erreur SQL ! \n"+ex.getMessage());
}
}
});
}
};
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
}
private boolean ControleListFacture(){
boolean result = true ;
String CodeFirst = DataSelectFacture.get(0).getFournisseur().getCode();
for( FactureFrs FactSele : DataSelectFacture ) {
if(!FactSele.getFournisseur().getCode().equals(CodeFirst)){
result = false ;
break;
}
}
return result;
}
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/iconaffecter.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 {
FactureFrs ListFactureFrs = (FactureFrs) ButtonCell.this.getTableView().getItems().get(ButtonCell.this.getIndex());
//Verifier si la Facture existe déja
boolean result = true ;
for( FactureFrs FactSele : DataSelectFacture ) {
if(FactSele.getNumero().equals(ListFactureFrs.getNumero())){
result = false ;
break;
}
}
if(result){
DataSelectFacture.add(ListFactureFrs);
TableViewSeleFactureFrs.setItems(DataSelectFacture);
TableViewSeleFactureFrs.refresh();
}
} catch (Exception ex) {
System.err.println("ReglementAjouter1Controller 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);
}
}
}
//Define the button cell
private class ButtonCellRemove extends TableCell<FactureFrs, 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();
DataSelectFacture.remove(selectdIndex);
TableViewSeleFactureFrs.setItems(DataSelectFacture);
TableViewSeleFactureFrs.refresh();
}
});
}
//Display button if the row is not empty
@Override
protected void updateItem(Boolean t, boolean empty) {
if(!empty){
setGraphic(cellButton);
} else {
setGraphic(null);
}
}
}
}
@@ -0,0 +1,497 @@
/*
* 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.Reglement;
import Controllers.Traitement.Adaptateur;
import Controllers.Traitement.contro;
import Models.ChequeClt.ChequeList;
import Models.TraiteClt.DatePickerCell;
import Models.ChequeClt.DatePickerCellCheque;
import Models.FactureFrs.FactureFrs;
import Models.Reglement.CarteElectroniqueFrs;
import Models.Reglement.ChequeFrs;
import Models.Reglement.Reglement;
import Models.Reglement.TraiteFrs;
import Models.TraiteClt.TraiteList;
import java.io.IOException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Calendar;
import java.util.Date;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
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.DatePicker;
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.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.util.Callback;
/**
* FXML Controller class
*
* @author Maher
*/
public class ReglementAjouter2Controller implements Initializable {
@FXML private AnchorPane AnchorPaneReglementAjouter2;
@FXML private AnchorPane PaneComptant;
@FXML private AnchorPane PaneFacilite;
@FXML private AnchorPane PaneFaciliteCheque;
@FXML private AnchorPane PaneFaciliteTraite;
@FXML private Text TextNbrFacture;
@FXML private Text TextTotalFacture;
@FXML private GridPane GridPaneCheque;
@FXML private GridPane GridPaneCarte;
@FXML private TextField TextFieldNbrEcheance;
@FXML private Text TextCtlNbrEcheance;
@FXML private Text TotalEcheance;
@FXML private TextField TextFieldChequeNomBanque;
@FXML private TextField TextFieldChequeNumero;
@FXML private TextField TextFieldChequeNomComple;
@FXML private DatePicker DatePickerChequeDate;
@FXML private Text TextCtlChequeNomBanque;
@FXML private Text TextCtlChequeNumero;
@FXML private Text TextCtlChequeNomComple;
@FXML private Text TextCtlChequeDate;
@FXML private TextField TextFieldCarteNomBanque;
@FXML private TextField TextFieldCarteNumeroCart;
@FXML private TextField TextFieldCarteNumeroTransaction;
@FXML private TextField TextFieldCarteHeurTransaction;
@FXML private DatePicker DatePickerCarteDate;
@FXML private Text TextCtlCartNomBanque;
@FXML private Text TextCtlCartNumeroCart;
@FXML private Text TextCtlCartNumeroTransaction;
@FXML private Text TextCtlCartDateHeurTransaction;
@FXML public TableView<TraiteList> TableViewListeTraite ;
@FXML public TableColumn TabColDateTraite;
@FXML public TableColumn<TraiteList ,String> TabColMontantTraite;
@FXML public TableView<ChequeList> TableViewListeCheque ;
@FXML public TableColumn TabColDateCheque;
@FXML public TableColumn<ChequeList ,String> TabColNumeroCheque;
@FXML public TableColumn<ChequeList ,String> TabColBanqueCheque;
@FXML public TableColumn<ChequeList ,String> TabColMontantCheque;
float TotalFact = 0;
boolean clt_total_echeance = true;
private int SelectComptantFacilite ; // 0 Comptant | 1 Facilité
private int PayerEesCheqCar = 0; //Payer en: 0 espèce | 1 Chéque | 2 Carte électronique
private int facilite_traite_cheque = 0; // 0 traite | 1 cheque
ObservableList<FactureFrs> DataFacture = FXCollections.observableArrayList();
public ObservableList<TraiteList> ListT = FXCollections.observableArrayList();
public ObservableList<ChequeList> ListCheque = FXCollections.observableArrayList();
Reglement reglement = new Reglement();
contro clt = new contro();
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
TableViewListeTraite.setEditable(true);
TabColMontantTraite.setStyle( "-fx-alignment: CENTER;");
TabColMontantTraite.getStyleClass().add("Center");
TabColMontantTraite.setCellValueFactory(new PropertyValueFactory<TraiteList, String>("MontantTraite"));
TabColMontantTraite.setCellFactory(TextFieldTableCell.<TraiteList>forTableColumn()); //Ajouter l'option textfield
//Valier l'opertion
TabColMontantTraite.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent<TraiteList, String>>() {
@Override
public void handle(TableColumn.CellEditEvent<TraiteList, String> t) {
String NewMontant = t.getNewValue().replace('.',',');
((TraiteList) t.getTableView().getItems().get(t.getTablePosition().getRow())).setMontantTraite(NewMontant);
CalculeTotalTrait();
}
});
TabColDateTraite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDateTraite.getStyleClass().add("Center");
TabColDateTraite.setCellValueFactory(new PropertyValueFactory<TraiteList, Date>("date"));
TabColDateTraite.setCellFactory(new Callback<TableColumn, TableCell>() {
@Override
public TableCell call(TableColumn p) {
DatePickerCell datePick = new DatePickerCell(ListT);
return datePick;
}
});
TableViewListeTraite.setItems(ListT);
//Cheque
TabColNumeroCheque.setStyle( "-fx-alignment: CENTER;");
TabColNumeroCheque.getStyleClass().add("Center");
TabColNumeroCheque.setCellValueFactory(new PropertyValueFactory<ChequeList, String>("NumeroCheque"));
TabColNumeroCheque.setCellFactory(TextFieldTableCell.<ChequeList>forTableColumn()); //Ajouter l'option textfield
//Valier l'opertion
TabColNumeroCheque.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent<ChequeList, String>>() {
@Override
public void handle(TableColumn.CellEditEvent<ChequeList, String> t) {
String NewNumeroCheque = t.getNewValue();
contro clt = new contro();
if(!clt.isNumeric(NewNumeroCheque)){
if(t.getTablePosition().getRow() == 0){
Integer NumeroCheque = Integer.valueOf(NewNumeroCheque);
int indise = 0;
while(indise<ListCheque.size()){
((ChequeList) t.getTableView().getItems().get(indise)).setNumeroCheque(NumeroCheque.toString());
indise++;NumeroCheque++;
}
}else{
((ChequeList) t.getTableView().getItems().get(t.getTablePosition().getRow())).setNumeroCheque(NewNumeroCheque);
}
}else{
((ChequeList) t.getTableView().getItems().get(t.getTablePosition().getRow())).setNumeroCheque(null);
}
}
});
TabColBanqueCheque.setStyle( "-fx-alignment: CENTER;");
TabColBanqueCheque.getStyleClass().add("Center");
TabColBanqueCheque.setCellValueFactory(new PropertyValueFactory<ChequeList, String>("BanqueCheque"));
TabColBanqueCheque.setCellFactory(TextFieldTableCell.<ChequeList>forTableColumn()); //Ajouter l'option textfield
//Valier l'opertion
TabColBanqueCheque.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent<ChequeList, String>>() {
@Override
public void handle(TableColumn.CellEditEvent<ChequeList, String> t) {
String NewBanque = t.getNewValue();
if(t.getTablePosition().getRow() == 0){
int indise = 0;
while(indise<ListCheque.size()){
((ChequeList) t.getTableView().getItems().get(indise)).setBanqueCheque(NewBanque);
indise++;
}
}else{
((ChequeList) t.getTableView().getItems().get(t.getTablePosition().getRow())).setBanqueCheque(NewBanque);
}
}
});
TabColMontantCheque.setStyle( "-fx-alignment: CENTER;");
TabColMontantCheque.getStyleClass().add("Center");
TabColMontantCheque.setCellValueFactory(new PropertyValueFactory<ChequeList, String>("MontantCheque"));
TabColMontantCheque.setCellFactory(TextFieldTableCell.<ChequeList>forTableColumn()); //Ajouter l'option textfield
//Valier l'opertion
TabColMontantCheque.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent<ChequeList, String>>() {
@Override
public void handle(TableColumn.CellEditEvent<ChequeList, String> t) {
String NewQuantite = t.getNewValue();
((ChequeList) t.getTableView().getItems().get(t.getTablePosition().getRow())).setMontantCheque(NewQuantite);
CalculeTotalCheque();
}
});
TabColDateCheque.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDateCheque.getStyleClass().add("Center");
TabColDateCheque.setCellValueFactory(new PropertyValueFactory<ChequeList, Date>("date"));
TabColDateCheque.setEditable(true);
TabColDateCheque.setCellFactory(new Callback<TableColumn, TableCell>() {
@Override
public TableCell call(TableColumn p) {
DatePickerCellCheque datePick = new DatePickerCellCheque(ListCheque);
return datePick;
}
});
TableViewListeCheque.setItems(ListCheque);
}
@FXML
private void DetailRelementSuitButtonAction(ActionEvent event) throws IOException {
final Reglement reglement = new Reglement();
boolean clt_reglement = true;
if(SelectComptantFacilite == 0){
reglement.setTypePaiement("0");
//0 espèce | 1 Chéque | 2 Carte électronique
if(PayerEesCheqCar == 0){
reglement.setModePaiement("0");
}else if(PayerEesCheqCar == 1){
reglement.setModePaiement("1");
if(clt.ContrNull(TextFieldChequeNomBanque, TextCtlChequeNomBanque) &&
clt.ContrNumeriqueNotnull(TextFieldChequeNumero, TextCtlChequeNumero) &&
clt.ContrNull(TextFieldChequeNomComple, TextCtlChequeNomComple)&&
clt.ContrNullDatePicker(DatePickerChequeDate, TextCtlChequeDate) ){
ChequeFrs Cheque = new ChequeFrs();
Cheque.setBanqueChequeFrs(TextFieldChequeNomBanque.getText());
Cheque.setNumeroChequeFrs(TextFieldChequeNumero.getText());
Cheque.setNomCompletChequeFrs(TextFieldChequeNomComple.getText());
Cheque.setDatePaiement(DatePickerChequeDate.getValue().toString());
Cheque.setMontantChequeFrs(Adaptateur.ArrondFloatToString(TotalFact));
reglement.setCheque(Cheque);
}else{ clt_reglement = false; }
}else if(PayerEesCheqCar == 2){
reglement.setModePaiement("2");
if(clt.ContrNull(TextFieldCarteNomBanque, TextCtlCartNomBanque) &&
clt.ContrNumeriqueNotnull(TextFieldCarteNumeroCart, TextCtlCartNumeroCart) &&
clt.ContrNumeriqueNotnull(TextFieldCarteNumeroTransaction, TextCtlCartNumeroTransaction)&&
clt.ContrNullDatePicker(DatePickerCarteDate, TextCtlCartDateHeurTransaction) &&
clt.ContrHour(TextFieldCarteHeurTransaction, TextCtlCartDateHeurTransaction) ){
CarteElectroniqueFrs CarteElectronique = new CarteElectroniqueFrs();
CarteElectronique.setBanque(TextFieldCarteNomBanque.getText());
CarteElectronique.setNumeroTransaction(TextFieldCarteNumeroTransaction.getText());
CarteElectronique.setCodeCarte(TextFieldCarteNumeroCart.getText());
CarteElectronique.setDateTransaction(DatePickerCarteDate.getValue().toString());
CarteElectronique.setHeurTransaction(TextFieldCarteHeurTransaction.getText());
CarteElectronique.setMantant(Adaptateur.ArrondFloatToString(TotalFact));
reglement.setCarte(CarteElectronique);
}else{ clt_reglement = false; }
}
}else if(SelectComptantFacilite == 1){
reglement.setTypePaiement("1");
//1 Chéque | 3 Traite
if(facilite_traite_cheque == 0){
if(clt_total_echeance){
reglement.setModePaiement("3");
ObservableList<TraiteFrs> TraitFrs = FXCollections.observableArrayList();
for(TraiteList List : ListT ) {
String DatePaiement = new SimpleDateFormat("yyyy-MM-dd").format(List.getDate());
TraitFrs.add(new TraiteFrs("", DatePaiement, null, List.getMontantTraite().replace(",", "."), null));
}
reglement.setListTraite(TraitFrs);
}else{ clt_reglement = false; }
}else if(facilite_traite_cheque == 1){
if(clt_total_echeance){
reglement.setModePaiement("1");
ObservableList<ChequeFrs> CollCheque = FXCollections.observableArrayList();
for(ChequeList List : ListCheque ) {
String CodeChequeFrs = "";
String NumeroChequeFrs = List.getNumeroCheque();
String BanqueChequeFrs = List.getBanqueCheque();
String MontantChequeFrs = List.getMontantCheque();
String DateCreation = LocalDateTime.now().toString();
String DatePaiement = new SimpleDateFormat("yyyy-MM-dd").format(List.getDate());
//controle numero chéque et nom banque
if(NumeroChequeFrs.equals("") || BanqueChequeFrs.equals("")){
clt_reglement = false;
}
CollCheque.add(new ChequeFrs(CodeChequeFrs, NumeroChequeFrs, BanqueChequeFrs, MontantChequeFrs, null, DatePaiement, DateCreation));
}
reglement.setListCheque(CollCheque);
}else{ clt_reglement = false; }
}
}
if(clt_reglement){
reglement.setMontant(Adaptateur.ArrondFloatToString(TotalFact));
reglement.setListFacture(DataFacture);
reglement.setDateTimeCreation(LocalDateTime.now().toString());
reglement.setFournisseur(DataFacture.get(0).getFournisseur());
reglement.setEtatReglement("0");
final ReglementDialogConfirmationController ReglementDialogConfirmation = new ReglementDialogConfirmationController();
ReglementDialogConfirmation.Enregister.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
try {
ReglementDialogConfirmation.AnchorPrincipal.setVisible(false);
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Reglement/ReglementAjouter3.fxml"));
Parent NodeReglementAjouter3 = (Parent)fxmlLoader.load();
ReglementAjouter3Controller ReglementAjouter3 = fxmlLoader.getController();
ReglementAjouter3.setDataReglement(reglement);
AnchorPaneReglementAjouter2.getChildren().clear();
AnchorPaneReglementAjouter2.getChildren().add(NodeReglementAjouter3);
} catch (IOException ex) {
Logger.getLogger(ReglementAjouter2Controller.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
ReglementDialogConfirmation.setReglement(reglement);
ReglementDialogConfirmation.Show();
}
}
@FXML
private void AjouterTraitementButtonAction(ActionEvent event) throws IOException {
Date date= new Date();
Calendar cal = Calendar.getInstance();
if(clt.ContrNumeriqueNotnull(TextFieldNbrEcheance, TextCtlNbrEcheance)){
ListT.clear();
Integer IntegerNbrEcheance = Adaptateur.Diviseur(Adaptateur.StringToFloat(TextFieldNbrEcheance.getText()));
float Value = (float) TotalFact / IntegerNbrEcheance;
Integer div = Adaptateur.Diviseur(Value);
float Somme = 0;
if(facilite_traite_cheque == 0){
PaneFaciliteCheque.setVisible(false);
PaneFaciliteTraite.setVisible(true);
for(int i=0; i<IntegerNbrEcheance; i++){
cal.setTime(date);
cal.add(Calendar.MONTH, i+1);
Somme += div;
if(i == IntegerNbrEcheance-1){
float reste = div + (TotalFact - Somme) ;
ListT.add(new TraiteList(Adaptateur.ArrondFloatToString(reste), cal.getTime()));
}else{
ListT.add(new TraiteList(Adaptateur.floatDeleZero(div), cal.getTime()));
}
}
TableViewListeTraite.setItems(ListT);
CalculeTotalTrait();
}else if(facilite_traite_cheque == 1){
for(int i=0; i<IntegerNbrEcheance; i++){
cal.setTime(date);
cal.add(Calendar.MONTH, i+1);
Somme += div;
if(i == IntegerNbrEcheance-1){
float reste = div + (TotalFact - Somme) ;
ListCheque.add(new ChequeList(cal.getTime(),"","",Adaptateur.ArrondFloatToString(reste)));
}else{
ListCheque.add(new ChequeList(cal.getTime(),"","",Adaptateur.floatDeleZero(div)));
}
}
CalculeTotalCheque();
}
}
}
public void SetDataFactureFrs(ObservableList<FactureFrs> DataFact){
DataFacture = DataFact;
for( FactureFrs Facture : DataFact ) {
TotalFact += Adaptateur.StringToFloat(Facture.getNetAPayer());
}
TextTotalFacture.setText(Adaptateur.FloatToStringEspaceCurrency(TotalFact));
TotalEcheance.setText("0 / "+Adaptateur.ArrondFloatToString(TotalFact));
TotalFact = Adaptateur.ArrondFloatToFloat(TotalFact);
TextNbrFacture.setText(DataFact.size()+"");
}
public void CalculeTotalTrait(){
float Somme = 0;
for(TraiteList List : ListT ) {
Somme += Adaptateur.StringToFloat(List.getMontantTraite());
}
TotalEcheance.setText(Adaptateur.ArrondFloatToString(Somme)+" / "+Adaptateur.ArrondFloatToString(TotalFact));
if(Adaptateur.ArrondFloatToString(Somme).equals(Adaptateur.ArrondFloatToString(TotalFact))){
TotalEcheance.setFill(Color.web("#000000"));
clt_total_echeance = true;
}else{
TotalEcheance.setFill(Color.web("#f20606"));
clt_total_echeance = false;
}
}
public void CalculeTotalCheque(){
float Somme = 0;
for(ChequeList List : ListCheque ) {
Somme += Adaptateur.StringToFloat(List.getMontantCheque());
}
TotalEcheance.setText(Adaptateur.ArrondFloatToString(Somme)+" / "+Adaptateur.ArrondFloatToString(TotalFact));
if(Adaptateur.ArrondFloatToString(Somme).equals(Adaptateur.ArrondFloatToString(TotalFact))){
TotalEcheance.setFill(Color.web("#000000"));
clt_total_echeance = true;
}else{
TotalEcheance.setFill(Color.web("#f20606"));
clt_total_echeance = false;
}
}
@FXML
private void ReglementAjouter1ButtonAction(ActionEvent event) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Reglement/ReglementAjouter1.fxml"));
Parent NodeReglementAjouter1 = (Parent)fxmlLoader.load();
ReglementAjouter1Controller ReglementAjouter1 = fxmlLoader.getController();
ReglementAjouter1.setDataFactureFrs(DataFacture);
AnchorPaneReglementAjouter2.getChildren().clear();
AnchorPaneReglementAjouter2.getChildren().add(NodeReglementAjouter1);
}
@FXML
public void RadioComptantAction(ActionEvent event) throws IOException {
SelectComptantFacilite = 0;
PaneComptant.setVisible(true);
PaneFacilite.setVisible(false);
}
@FXML
public void RadioEspeceAction(ActionEvent event) throws IOException {
PayerEesCheqCar = 0;
GridPaneCheque.setVisible(false);
GridPaneCarte.setVisible(false);
}
@FXML
public void RadioChequeAction(ActionEvent event) throws IOException {
PayerEesCheqCar = 1;
GridPaneCheque.setVisible(true);
GridPaneCarte.setVisible(false);
}
@FXML
public void RadioCarteAction(ActionEvent event) throws IOException {
PayerEesCheqCar = 2;
GridPaneCheque.setVisible(false);
GridPaneCarte.setVisible(true);
}
@FXML
public void RadioFaciliteAction(ActionEvent event) throws IOException {
SelectComptantFacilite = 1;
PaneComptant.setVisible(false);
PaneFacilite.setVisible(true);
}
@FXML
public void RadioFaciliteTraiteAction(ActionEvent event) throws IOException {
facilite_traite_cheque = 0;
PaneFaciliteCheque.setVisible(false);
PaneFaciliteTraite.setVisible(true);
}
@FXML
public void RadioFaciliteChequeAction(ActionEvent event) throws IOException {
facilite_traite_cheque = 1;
PaneFaciliteCheque.setVisible(true);
PaneFaciliteTraite.setVisible(false);
}
}
@@ -0,0 +1,255 @@
/*
* 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.Reglement;
import Controllers.Traitement.Adaptateur;
import Models.FactureFrs.FactureFrs;
import Models.Reglement.ChequeFrs;
import Models.Reglement.Reglement;
import Models.Reglement.ReglementDB;
import Models.Reglement.TraiteFrs;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.beans.property.SimpleStringProperty;
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.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ProgressIndicator;
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.GridPane;
import javafx.scene.text.Text;
import javafx.util.Callback;
/**
* FXML Controller class
* @author Maher
*/
public class ReglementAjouter3Controller implements Initializable {
@FXML public ProgressIndicator ProgressReglement;
@FXML private AnchorPane PaneDetailTraite;
private Service<Void> ThreadReglement;
@FXML private Text TextCodeReglement;
@FXML private Text TextTypePaiement;
@FXML private Text TextModePaiement;
@FXML private Text TextDateCreation;
@FXML private Text TextTotalReglement;
@FXML private Text TextProfile;
@FXML private Text TextCodeFrs;
@FXML private Text TextNomFrs;
@FXML private Text TextTele1Frs;
@FXML private Text TextTele2Frs;
@FXML private GridPane GridPaneCheque;
@FXML private GridPane GridPaneCarte;
@FXML private Text TextCartNomBanque;
@FXML private Text TextCartNumeroCart;
@FXML private Text TextCartNumeroTransaction;
@FXML private Text TextCartDateHeurTransaction;
@FXML private Text TextChequeNomBanque;
@FXML private Text TextChequeNumero;
@FXML private Text TextChequeNomComple;
@FXML private Text TextChequeDate;
@FXML private Button ButtonImprimer;
@FXML private TableView<ChequeFrs> TableViewListeCheque ;
@FXML private TableColumn<ChequeFrs ,String> TabColDateCheque;
@FXML private TableColumn<ChequeFrs ,String> TabColNumeroCheque;
@FXML private TableColumn<ChequeFrs ,String> TabColBanqueCheque;
@FXML private TableColumn<ChequeFrs ,String> TabColMontantCheque;
@FXML private TableView<TraiteFrs> TableViewListeTraite ;
@FXML private TableColumn<TraiteFrs ,String> TabColDateTraite;
@FXML private TableColumn<TraiteFrs ,String> TabColMontantTraite;
@FXML private TableView<FactureFrs> TableViewFactureFrs;
@FXML private TableColumn<FactureFrs ,String> TabColNumeroFact;
@FXML private TableColumn<FactureFrs ,String> TabColProfile;
@FXML private TableColumn<FactureFrs ,String> TabColDate;
@FXML private TableColumn<FactureFrs ,String> TabColHeur;
@FXML private TableColumn<FactureFrs ,String> TabColLocalReception;
@FXML private TableColumn<FactureFrs ,String> TabColNetPayer;
Reglement reglement = new Reglement();
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
TabColMontantTraite.setStyle( "-fx-alignment: CENTER;");
TabColMontantTraite.getStyleClass().add("Center");
TabColMontantTraite.setCellValueFactory(new PropertyValueFactory<TraiteFrs, String>("Montant"));
TabColDateTraite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDateTraite.getStyleClass().add("Center");
TabColDateTraite.setCellValueFactory(new PropertyValueFactory<TraiteFrs, String>("DatePaiement"));
TabColNumeroCheque.setStyle( "-fx-alignment: CENTER;");
TabColNumeroCheque.getStyleClass().add("Center");
TabColNumeroCheque.setCellValueFactory(new PropertyValueFactory<ChequeFrs, String>("NumeroChequeFrs"));
TabColBanqueCheque.setStyle( "-fx-alignment: CENTER;");
TabColBanqueCheque.getStyleClass().add("Center");
TabColBanqueCheque.setCellValueFactory(new PropertyValueFactory<ChequeFrs, String>("BanqueChequeFrs"));
TabColDateCheque.setStyle( "-fx-alignment: CENTER;");
TabColDateCheque.getStyleClass().add("Center");
TabColDateCheque.setCellValueFactory(new PropertyValueFactory<ChequeFrs, String>("DatePaiement"));
TabColMontantCheque.setStyle( "-fx-alignment: CENTER;");
TabColMontantCheque.getStyleClass().add("Center");
TabColMontantCheque.setCellValueFactory(new PropertyValueFactory<ChequeFrs, String>("MontantChequeFrs"));
TabColNumeroFact.setCellValueFactory(new PropertyValueFactory<FactureFrs, String>("Numero"));
TabColProfile.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColProfile.getStyleClass().add("Center");
TabColProfile.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<FactureFrs,String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(TableColumn.CellDataFeatures<FactureFrs, String> data) {
return new SimpleStringProperty(data.getValue().getProfile().getNom()+" "+data.getValue().getProfile().getPrenom());
}
});
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");
}
public void setDataReglement(Reglement regl){
reglement = regl;
LanchSaveReglement();
}
public void setReglement(){
TextCodeReglement.setText(reglement.getNumero());
TextTypePaiement.setText(reglement.getTypePaiementString());
TextModePaiement.setText(reglement.getModePaiementString());
TextDateCreation.setText(reglement.getDateTimeCreationString());
TextTotalReglement.setText(Adaptateur.StringToStringEspaceCurrency(reglement.getMontant()));
TextProfile.setText(reglement.getProfile().getPrenom()+" "+reglement.getProfile().getNom());
TextCodeFrs.setText(reglement.getFournisseur().getCode());
TextNomFrs.setText(reglement.getFournisseur().getNom());
TextTele1Frs.setText(reglement.getFournisseur().getTele1());
TextTele2Frs.setText(reglement.getFournisseur().getTele2());
TableViewFactureFrs.setItems(reglement.getListFacture());
// 0 Comptant
if(reglement.getTypePaiement().equals("0")){
//0 espèce
if(reglement.getModePaiement().equals("0")){
//1 Chéque
}else if(reglement.getModePaiement().equals("1")){
GridPaneCheque.setVisible(true);
TextChequeNomBanque.setText(reglement.getCheque().getBanqueChequeFrs());
TextChequeNumero.setText(reglement.getCheque().getNumeroChequeFrs());
TextChequeNomComple.setText(reglement.getCheque().getNomCompletChequeFrs());
TextChequeDate.setText(reglement.getCheque().getDateCreation());
//2 Carte électronique
}else if(reglement.getModePaiement().equals("2")){
GridPaneCarte.setVisible(true);
TextCartNomBanque.setText(reglement.getCarte().getBanque());
TextCartNumeroCart.setText(reglement.getCarte().getNumeroCarte());
TextCartNumeroTransaction.setText(reglement.getCarte().getNumeroTransaction());
TextCartDateHeurTransaction.setText(reglement.getCarte().getDateTransaction()+" "+reglement.getCarte().getHeurTransaction());
}
//1 Facilité
}else if(reglement.getTypePaiement().equals("1")){
//1 Chéque
if(reglement.getModePaiement().equals("1")){
TableViewListeCheque.setVisible(true);
ObservableList<ChequeFrs> NewListCheque = FXCollections.observableArrayList();
for(ChequeFrs Cheque : reglement.getListCheque()) {
String CodeChequeFrs = Cheque.getCodeChequeFrs();
String NumeroChequeFrs = Cheque.getNumeroChequeFrs();
String BanqueChequeFrs = Cheque.getBanqueChequeFrs();
String MontantChequeFrs = Adaptateur.StringDeleZero(Cheque.getMontantChequeFrs());
String NomCompletChequeFrs = Cheque.getNomCompletChequeFrs();
String DatePaiement = Adaptateur.NormalDateFormat(Cheque.getDatePaiement());
String DateCreation = Adaptateur.NormalDateTimeFormat(Cheque.getDateCreation());
NewListCheque.add(new ChequeFrs(CodeChequeFrs, NumeroChequeFrs, BanqueChequeFrs, MontantChequeFrs, NomCompletChequeFrs, DatePaiement, DateCreation));
}
TableViewListeCheque.setItems(NewListCheque);
//3 Traite
}else if(reglement.getModePaiement().equals("3")){
TableViewListeTraite.setVisible(true);
ButtonImprimer.setVisible(true);
TableViewListeTraite.setItems(reglement.getListTraiteString());
}
}
}
public void LanchSaveReglement(){
ThreadReglement = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
ReglementDB reglementDB = new ReglementDB();
reglement = reglementDB.setReglementDB(reglement);
reglement = reglementDB.getReglementDB(reglement.getNumero());
return null;
}
};
}
};
ThreadReglement.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressReglement.setVisible(false);
setReglement();
PaneDetailTraite.setVisible(true);
}
});
ThreadReglement.start();
}
}
@@ -0,0 +1,230 @@
/*
* 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.Reglement;
import Controllers.CommandeClt.CommandeCltDialogConfirmationController;
import Controllers.Traitement.Adaptateur;
import Controllers.Traitement.MyWindow;
import Controllers.Traitement.ParametreSystem;
import Models.FactureFrs.FactureFrs;
import Models.Reglement.ChequeFrs;
import Models.Reglement.Reglement;
import Models.Reglement.TraiteFrs;
import Models.User.User;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;
/**
* FXML Controller class
*
* @author Maher
*/
public class ReglementDialogConfirmationController implements Initializable {
public Node nodeFxml ;
@FXML public AnchorPane AnchorPrincipal ;
@FXML public Button Enregister ;
@FXML private AnchorPane AnchorDetailReglement;
@FXML private Text TextTypePaiement;
@FXML private Text TextModePaiement;
@FXML private Text TextDateCreation;
@FXML private Text TextNombreFact;
@FXML private Text TextTotalReglement;
@FXML private Text TextProfile;
@FXML private Text TextCodeFrs;
@FXML private Text TextNomFrs;
@FXML private Text TextFormesFrs;
@FXML private Text TextTele1Frs;
@FXML private Text TextTele2Frs;
@FXML private Text TextmailFrs;
@FXML private GridPane GridPaneCheque;
@FXML private GridPane GridPaneCarte;
@FXML private Text TextCartNomBanque;
@FXML private Text TextCartNumeroCart;
@FXML private Text TextCartNumeroTransaction;
@FXML private Text TextCartDateHeurTransaction;
@FXML private Text TextChequeNomBanque;
@FXML private Text TextChequeNumero;
@FXML private Text TextChequeNomComple;
@FXML private Text TextChequeDate;
@FXML private TableView<ChequeFrs> TableViewListeCheque ;
@FXML private TableColumn<ChequeFrs ,String> TabColDateCheque;
@FXML private TableColumn<ChequeFrs ,String> TabColNumeroCheque;
@FXML private TableColumn<ChequeFrs ,String> TabColBanqueCheque;
@FXML private TableColumn<ChequeFrs ,String> TabColMontantCheque;
@FXML private TableView<TraiteFrs> TableViewListeTraite ;
@FXML private TableColumn<TraiteFrs ,String> TabColDateTraite;
@FXML private TableColumn<TraiteFrs ,String> TabColMontantTraite;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
//Cheque
TabColNumeroCheque.setStyle( "-fx-alignment: CENTER;");
TabColNumeroCheque.getStyleClass().add("Center");
TabColNumeroCheque.setCellValueFactory(new PropertyValueFactory<ChequeFrs, String>("NumeroChequeFrs"));
TabColBanqueCheque.setStyle( "-fx-alignment: CENTER;");
TabColBanqueCheque.getStyleClass().add("Center");
TabColBanqueCheque.setCellValueFactory(new PropertyValueFactory<ChequeFrs, String>("BanqueChequeFrs"));
TabColMontantCheque.setStyle( "-fx-alignment: CENTER;");
TabColMontantCheque.getStyleClass().add("Center");
TabColMontantCheque.setCellValueFactory(new PropertyValueFactory<ChequeFrs, String>("MontantChequeFrs"));
TabColDateCheque.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDateCheque.getStyleClass().add("Center");
TabColDateCheque.setCellValueFactory(new PropertyValueFactory<ChequeFrs, String>("DatePaiement"));
TabColDateTraite.setStyle( "-fx-alignment: CENTER;");
TabColDateTraite.getStyleClass().add("Center");
TabColDateTraite.setCellValueFactory(new PropertyValueFactory<TraiteFrs, String>("DatePaiement"));
TabColMontantTraite.setStyle( "-fx-alignment: CENTER;");
TabColMontantTraite.getStyleClass().add("Center");
TabColMontantTraite.setCellValueFactory(new PropertyValueFactory<TraiteFrs, String>("Montant"));
Image coffeeImage = new Image(getClass().getResourceAsStream("/Public/icon/iconsave.png"));
ImageView buttonGraphic = new ImageView();
buttonGraphic.setImage(coffeeImage);
Enregister.setGraphic(buttonGraphic);
}
public void setReglement(Reglement reglement){
TextModePaiement.setText(reglement.getModePaiementString());
TextTypePaiement.setText(reglement.getTypePaiementString());
if(reglement.getTypePaiement().equals("0")){
if(reglement.getModePaiement().equals("0")){
AnchorDetailReglement.setVisible(false);
}else if(reglement.getModePaiement().equals("1")){
GridPaneCheque.setVisible(true);
TextChequeNomBanque.setText(reglement.getCheque().getBanqueChequeFrs());
TextChequeNumero.setText(reglement.getCheque().getNumeroChequeFrs());
TextChequeNomComple.setText(reglement.getCheque().getNomCompletChequeFrs());
TextChequeDate.setText(reglement.getCheque().getDatePaiement());
}else if(reglement.getModePaiement().equals("2")){
GridPaneCarte.setVisible(true);
TextCartNomBanque.setText(reglement.getCarte().getBanque());
TextCartNumeroCart.setText(reglement.getCarte().getCodeCarte());
TextCartNumeroTransaction.setText(reglement.getCarte().getNumeroTransaction());
TextCartDateHeurTransaction.setText(Adaptateur.NormalDateFormat(reglement.getCarte().getDateTransaction())+" "+reglement.getCarte().getHeurTransaction());
}
}
if(reglement.getTypePaiement().equals("1")){
AnchorDetailReglement.setVisible(true);
if(reglement.getListTraite() != null){
TableViewListeTraite.setVisible(true);
TableViewListeTraite.setItems(reglement.getListTraiteString());
}else if(reglement.getListCheque() != null){
TableViewListeCheque.setVisible(true);
ObservableList<ChequeFrs> NewListCheque = FXCollections.observableArrayList();
for(ChequeFrs Cheque : reglement.getListCheque()) {
String CodeChequeFrs = Cheque.getCodeChequeFrs();
String NumeroChequeFrs = Cheque.getNumeroChequeFrs();
String BanqueChequeFrs = Cheque.getBanqueChequeFrs();
String MontantChequeFrs = Adaptateur.StringDeleZero(Cheque.getMontantChequeFrs());
String NomCompletChequeFrs = Cheque.getNomCompletChequeFrs();
String DatePaiement = Adaptateur.NormalDateFormat(Cheque.getDatePaiement());
String DateCreation = Adaptateur.NormalDateTimeFormat(Cheque.getDateCreation());
NewListCheque.add(new ChequeFrs(CodeChequeFrs, NumeroChequeFrs, BanqueChequeFrs, MontantChequeFrs, NomCompletChequeFrs, DatePaiement, DateCreation));
}
TableViewListeCheque.setItems(NewListCheque);
}
}
ObservableList<FactureFrs> ListFacture = reglement.getListFacture();
float Somme = 0;
for(FactureFrs facture : ListFacture ) {
Somme += Adaptateur.StringToFloat(facture.getNetAPayer());
}
TextTotalReglement.setText(Adaptateur.FloatToStringEspaceCurrency(Somme));
TextNombreFact.setText(ListFacture.size()+"");
TextDateCreation.setText(Adaptateur.NormalDateFormat(reglement.getDateTimeCreation()));
TextProfile.setText(User.nom+" "+User.prenom);
TextCodeFrs.setText(reglement.getFournisseur().getCode());
TextNomFrs.setText(reglement.getFournisseur().getNom());
TextFormesFrs.setText(reglement.getFournisseur().getFormes());
TextTele1Frs.setText(reglement.getFournisseur().getTele1());
TextTele2Frs.setText(reglement.getFournisseur().getTele2());
TextmailFrs.setText(reglement.getFournisseur().getMail());
}
public ReglementDialogConfirmationController(){
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Reglement/ReglementDialogConfirmation.fxml"));
fxmlLoader.setController(this);
nodeFxml = (Node) fxmlLoader.load();
} catch (IOException ex) {
Logger.getLogger(CommandeCltDialogConfirmationController.class.getName()).log(Level.SEVERE, null, ex);
}
}
@FXML
private void ExitButtonAction(ActionEvent event) throws IOException {
AnchorPrincipal.setVisible(false);
}
public void Show()
{
StackPane Sp = new StackPane();
Scene scene = new Scene(Sp);
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(nodeFxml);
Stage stage = MyWindow.myStage;
stage.setScene(scene);
stage.show();
}
}
@@ -0,0 +1,313 @@
/*
* 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.Reglement;
import Controllers.CommandeClt.CommandeCltDialogConfirmationController;
import Controllers.Traitement.Adaptateur;
import Controllers.Traitement.MyWindow;
import Controllers.Traitement.ParametreSystem;
import Models.FactureFrs.FactureFrs;
import Models.Reglement.ChequeFrs;
import Models.Reglement.Reglement;
import Models.Reglement.ReglementDB;
import Models.Reglement.TraiteFrs;
import java.io.IOException;
import java.net.URL;
import java.text.DecimalFormat;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.beans.property.SimpleStringProperty;
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.Node;
import javafx.scene.Scene;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.TableCell;
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.GridPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.util.Callback;
/**
* FXML Controller class
*
* @author Maher
*/
public class ReglementDialogDetailController implements Initializable {
public Node nodeFxml ;
@FXML public AnchorPane AnchorPrincipal ;
@FXML public ProgressIndicator ProgressReglement;
@FXML public AnchorPane PaneDetailReglement;
@FXML private Text TextCodeReglement;
@FXML private Text TextTypePaiement;
@FXML private Text TextModePaiement;
@FXML private Text TextDateCreation;
@FXML private Text TextTotalReglement;
@FXML private Text TextProfile;
@FXML private Text TextCodeFrs;
@FXML private Text TextNomFrs;
@FXML private Text TextTele1Frs;
@FXML private Text TextTele2Frs;
@FXML private GridPane GridPaneCheque;
@FXML private GridPane GridPaneCarte;
@FXML private Text TextCartNomBanque;
@FXML private Text TextCartNumeroCart;
@FXML private Text TextCartNumeroTransaction;
@FXML private Text TextCartDateHeurTransaction;
@FXML private Text TextChequeNomBanque;
@FXML private Text TextChequeNumero;
@FXML private Text TextChequeNomComple;
@FXML private Text TextChequeDate;
@FXML private TableView<ChequeFrs> TableViewListeCheque ;
@FXML private TableColumn<ChequeFrs ,String> TabColDateCheque;
@FXML private TableColumn<ChequeFrs ,String> TabColNumeroCheque;
@FXML private TableColumn<ChequeFrs ,String> TabColBanqueCheque;
@FXML private TableColumn<ChequeFrs ,String> TabColMontantCheque;
@FXML private TableView<TraiteFrs> TableViewListeTraite ;
@FXML private TableColumn<TraiteFrs ,String> TabColDateTraite;
@FXML private TableColumn<TraiteFrs ,String> TabColMontantTraite;
@FXML private TableView<FactureFrs> TableViewFactureFrs;
@FXML private TableColumn<FactureFrs ,String> TabColNumeroFact;
@FXML private TableColumn<FactureFrs ,String> TabColProfile;
@FXML private TableColumn<FactureFrs ,String> TabColDate;
@FXML private TableColumn<FactureFrs ,String> TabColHeur;
@FXML private TableColumn<FactureFrs ,String> TabColLocalReception;
@FXML private TableColumn<FactureFrs ,String> TabColNetPayer;
private Service<Void> ThreadReglement;
DecimalFormat Formatter = new DecimalFormat("##,###.## ");
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
TabColMontantTraite.setStyle( "-fx-alignment: CENTER;");
TabColMontantTraite.getStyleClass().add("Center");
TabColMontantTraite.setCellValueFactory(new PropertyValueFactory<TraiteFrs, String>("Montant"));
TabColDateTraite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDateTraite.getStyleClass().add("Center");
TabColDateTraite.setCellValueFactory(new PropertyValueFactory<TraiteFrs, String>("DatePaiement"));
TabColNumeroCheque.setStyle( "-fx-alignment: CENTER;");
TabColNumeroCheque.getStyleClass().add("Center");
TabColNumeroCheque.setCellValueFactory(new PropertyValueFactory<ChequeFrs, String>("NumeroChequeFrs"));
TabColBanqueCheque.setStyle( "-fx-alignment: CENTER;");
TabColBanqueCheque.getStyleClass().add("Center");
TabColBanqueCheque.setCellValueFactory(new PropertyValueFactory<ChequeFrs, String>("BanqueChequeFrs"));
TabColDateCheque.setStyle( "-fx-alignment: CENTER;");
TabColDateCheque.getStyleClass().add("Center");
TabColDateCheque.setCellValueFactory(new PropertyValueFactory<ChequeFrs, String>("DatePaiement"));
TabColMontantCheque.setStyle( "-fx-alignment: CENTER;");
TabColMontantCheque.getStyleClass().add("Center");
TabColMontantCheque.setCellValueFactory(new PropertyValueFactory<ChequeFrs, String>("MontantChequeFrs"));
TabColNumeroFact.setCellValueFactory(new PropertyValueFactory<FactureFrs, String>("Numero"));
TabColProfile.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColProfile.getStyleClass().add("Center");
TabColProfile.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<FactureFrs,String>, ObservableValue<String>>() {
@Override
public ObservableValue<String> call(TableColumn.CellDataFeatures<FactureFrs, String> data) {
return new SimpleStringProperty(data.getValue().getProfile().getNom()+" "+data.getValue().getProfile().getPrenom());
}
});
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;
}
});
}
public void LanchShowReglement(final String IdReglement){
ThreadReglement = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
Reglement reglement = new ReglementDB().getReglementDB(IdReglement);
setReglement(reglement);
return null;
}
};
}
};
ThreadReglement.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressReglement.setVisible(false);
PaneDetailReglement.setVisible(true);
}
});
ThreadReglement.start();
}
public void setReglement(Reglement reglement){
TextCodeReglement.setText(reglement.getNumero());
TextTypePaiement.setText(reglement.getTypePaiementString());
TextModePaiement.setText(reglement.getModePaiementString());
TextDateCreation.setText(reglement.getDateTimeCreationString());
TextTotalReglement.setText(Formatter.format(Float.parseFloat(reglement.getMontant()))+" "+ParametreSystem.CurrencySign);
TextProfile.setText(reglement.getProfile().getPrenom()+" "+reglement.getProfile().getNom());
TextCodeFrs.setText(reglement.getFournisseur().getCode());
TextNomFrs.setText(reglement.getFournisseur().getNom());
TextTele1Frs.setText(reglement.getFournisseur().getTele1());
TextTele2Frs.setText(reglement.getFournisseur().getTele2());
TableViewFactureFrs.setItems(reglement.getListFacture());
// 0 Comptant
if(reglement.getTypePaiement().equals("0")){
//0 espèce
if(reglement.getModePaiement().equals("0")){
//1 Chéque
}else if(reglement.getModePaiement().equals("1")){
GridPaneCheque.setVisible(true);
TextChequeNomBanque.setText(reglement.getCheque().getBanqueChequeFrs());
TextChequeNumero.setText(reglement.getCheque().getNumeroChequeFrs());
TextChequeNomComple.setText(reglement.getCheque().getNomCompletChequeFrs());
TextChequeDate.setText(reglement.getCheque().getDateCreation());
//2 Carte électronique
}else if(reglement.getModePaiement().equals("2")){
GridPaneCarte.setVisible(true);
TextCartNomBanque.setText(reglement.getCarte().getBanque());
TextCartNumeroCart.setText(reglement.getCarte().getNumeroCarte());
TextCartNumeroTransaction.setText(reglement.getCarte().getNumeroTransaction());
TextCartDateHeurTransaction.setText(reglement.getCarte().getDateTransaction()+" "+reglement.getCarte().getHeurTransaction());
}
//1 Facilité
}else if(reglement.getTypePaiement().equals("1")){
//1 Chéque
if(reglement.getModePaiement().equals("1")){
TableViewListeCheque.setVisible(true);
ObservableList<ChequeFrs> NewListCheque = FXCollections.observableArrayList();
for(ChequeFrs Cheque : reglement.getListCheque()) {
String CodeChequeFrs = Cheque.getCodeChequeFrs();
String NumeroChequeFrs = Cheque.getNumeroChequeFrs();
String BanqueChequeFrs = Cheque.getBanqueChequeFrs();
String MontantChequeFrs = Adaptateur.StringDeleZero(Cheque.getMontantChequeFrs());
String NomCompletChequeFrs = Cheque.getNomCompletChequeFrs();
String DatePaiement = Adaptateur.NormalDateFormat(Cheque.getDatePaiement());
String DateCreation = Adaptateur.NormalDateTimeFormat(Cheque.getDateCreation());
NewListCheque.add(new ChequeFrs(CodeChequeFrs, NumeroChequeFrs, BanqueChequeFrs, MontantChequeFrs, NomCompletChequeFrs, DatePaiement, DateCreation));
}
TableViewListeCheque.setItems(NewListCheque);
//3 Traite
}else if(reglement.getModePaiement().equals("3")){
TableViewListeTraite.setVisible(true);
TableViewListeTraite.setItems(reglement.getListTraiteString());
}
}
}
public ReglementDialogDetailController(){
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Reglement/ReglementDialogDetail.fxml"));
fxmlLoader.setController(this);
nodeFxml = (Node) fxmlLoader.load();
} catch (IOException ex) {
Logger.getLogger(CommandeCltDialogConfirmationController.class.getName()).log(Level.SEVERE, null, ex);
}
}
@FXML
private void ExitButtonAction(ActionEvent event) throws IOException {
AnchorPrincipal.setVisible(false);
}
public void Show()
{
StackPane Sp = new StackPane();
Scene scene = new Scene(Sp);
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(nodeFxml);
Stage stage = MyWindow.myStage;
stage.setScene(scene);
stage.show();
}
}
@@ -0,0 +1,34 @@
package Controllers.Reglement;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.text.Text;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class TraiteFrsPrintController implements Initializable {
@FXML private Text TextCompanyName;
@FXML private Text TextCompanyPlace;
@FXML private Text TextCompanyAddress;
@FXML private Text TextBank;
@FXML private Text TextRIP;
@FXML private Text TextRIB;
@FXML private Text TextAmountLetter;
@FXML private Text TextAmountFigures;
@FXML private Text TextDateDeadline;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
}
@@ -0,0 +1,76 @@
package Controllers.Stock;
import Controllers.Traitement.Adaptateur;
import Models.User.User;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.text.Text;
/**
* FXML Controller class
* @author Maher
*/
public class BondeEnterPrintController implements Initializable {
@FXML private Text TextLocale;
@FXML private Text TextCode;
@FXML private Text TextTitreBon; //Bon d'entrée pour | Bon de sortie à
@FXML private Text TextTypeSource; //Emetteur | Récepteur
@FXML private Text TextValSource;
@FXML private Text TextDate;
@FXML private Text TextUser;
@FXML private Text TextTransporteur;
@FXML private Text TextPagination;
@FXML private TableView<ListProduitBon> TableViewProduit ;
@FXML private TableColumn<ListProduitBon, String> TabColReference;
@FXML private TableColumn<ListProduitBon, String> TabColDesignation;
@FXML private TableColumn<ListProduitBon ,String> TabColTVA;
@FXML private TableColumn<ListProduitBon ,String> TabColTotalTTC;
@FXML private TableColumn<ListProduitBon, String> TabColQuantite;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
TabColReference.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("reference"));
TabColDesignation.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("designaton"));
TabColTVA.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("tva"));
TabColTVA.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColTVA.getStyleClass().add("Center");
TabColTotalTTC.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("prixttc"));
TabColTotalTTC.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColTotalTTC.getStyleClass().add("Center");
TabColQuantite.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("quantite"));
TabColQuantite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColQuantite.getStyleClass().add("Center");
}
public void setDataBonEnter(ObservableList<ListProduitBon> listProduits, String TitreBon, String Local, String TypeSource, String ValSource, String Code, String Date, String Heur, String Transporteur, String Pagination){
TableViewProduit.setItems(null);
TableViewProduit.setItems(listProduits);
TextTitreBon.setText(TitreBon);
TextLocale.setText(Local);
TextCode.setText(Code);
TextTypeSource.setText(TypeSource);
TextValSource.setText(ValSource);
TextDate.setText(Adaptateur.NormalDateFormat(Date)+" "+Heur);
TextUser.setText(User.nom+" "+User.prenom);
TextTransporteur.setText(Transporteur);
TextPagination.setText(Pagination);
}
}
@@ -0,0 +1,546 @@
/*
* 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.Stock;
import Controllers.Dialog.MessageControle;
import Controllers.Dialog.ShowDialog;
import Controllers.Traitement.Adaptateur;
import Controllers.Traitement.ParametreSystem;
import Controllers.Traitement.contro;
import Models.Categorie.CategorieDB;
import Models.Stock.BonEntree;
import Models.Stock.BondeEntrerDB;
import Models.Stock.StockDB;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.sql.Date;
import java.time.LocalDate;
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.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.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableColumn.CellEditEvent;
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.KeyCode;
import javafx.scene.input.KeyEvent;
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 Ben Tili
*/
public class BondeEntrerController implements Initializable {
@FXML private AnchorPane AnchorPaneBondentree;
@FXML private ProgressBar ProgressBarStockBonEnter;
@FXML private Text LocalRecepteur ;
@FXML private ComboBox ComboLocale;
@FXML private DatePicker DateBE;
@FXML private TextField TextFieldCategorie;
@FXML private TextField CodeBE;
@FXML private TextField BonEnteeTransporteur;
@FXML private TextField ReferenceBE;
@FXML private TextField DesignatonBE;
@FXML private TextField TextFieldCodeBarre;
@FXML private TableView<ListProduitRech> TableViewListeProduitRechercher ;
@FXML private TableColumn<ListProduitRech ,String> TabColRechReference;
@FXML private TableColumn<ListProduitRech ,String> TabColRechDesignaton;
@FXML private TableColumn<ListProduitRech ,String> TabColRechMarque ;
@FXML private TableColumn<ListProduitRech ,String> TabColRechCategorie;
@FXML private TableColumn<ListProduitRech ,String> TabColRechPrixTTC;
@FXML private TableColumn<ListProduitRech ,String> TabColRechTVA;
@FXML private TableColumn<ListProduitRech, Boolean> TabColRechAddAction ;
@FXML private TableView<ListProduitBon> TableViewListeProduitBE ;
@FXML private TableColumn<ListProduitBon ,String> TabColBEReference;
@FXML private TableColumn<ListProduitBon ,String> TabColBEDesignaton;
@FXML private TableColumn<ListProduitBon ,String> TabColBEMarque ;
@FXML private TableColumn<ListProduitBon ,String> TabColBECategorie;
@FXML private TableColumn<ListProduitBon ,String> TabColBEPrixTTC;
@FXML private TableColumn<ListProduitBon ,String> TabColBEQuantiteTTC;
@FXML private TableColumn<ListProduitBon ,String> TabColBETVA;
@FXML private TableColumn<ListProduitBon, Boolean> TabColBEAddAction ;
private Service<Void> ThreadSearchCategorie;
ObservableList<ListProduitBon> data=FXCollections.observableArrayList();
BondeEntrerDB bonentrer = new BondeEntrerDB();
StockDB stockdb = new StockDB();
String categorie="" ;
String Reference="" ;
String designaton="" ;
String Codebarre="" ;
@Override
public void initialize(URL url, ResourceBundle rb) {
LocalRecepteur.setText(ParametreSystem.NomLocalPC);
DateBE.setValue(LocalDate.now());
//Liste des Locales
ComboLocale.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent t) {
ComboLocale.setStyle("-fx-border-color:#cfcfcf;");
ComboLocale.getItems().clear();
ComboLocale.getItems().addAll(stockdb.getListLocal());
}
});
//List des Categories
setCategorie();
TableViewListeProduitBE.setEditable(true);
//Pour la premiére table View rechercher un produit
TabColRechReference.setCellValueFactory(new PropertyValueFactory<ListProduitRech, String>("reference"));
TabColRechDesignaton.setCellValueFactory(new PropertyValueFactory<ListProduitRech, String>("designaton"));
TabColRechMarque.setCellValueFactory(new PropertyValueFactory<ListProduitRech, String>("marque"));
TabColRechCategorie.setCellValueFactory(new PropertyValueFactory<ListProduitRech, String>("categorie"));
TabColRechPrixTTC.setCellValueFactory(new PropertyValueFactory<ListProduitRech, String>("prixttc"));
TabColRechPrixTTC.setStyle( "-fx-alignment: CENTER_RIGHT; -fx-font-weight:bold;");
TabColRechTVA.setCellValueFactory(new PropertyValueFactory<ListProduitRech, String>("TVA"));
TabColRechTVA.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold;");
TabColRechAddAction.setSortable(true);
TabColRechAddAction.setStyle( "-fx-alignment: CENTER;");
TabColRechAddAction.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<ListProduitRech, Boolean>,
ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(TableColumn.CellDataFeatures<ListProduitRech, 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<ListProduitRech, Boolean>, TableCell<ListProduitRech, Boolean>>() {
@Override
public TableCell<ListProduitRech, Boolean> call(TableColumn<ListProduitRech, Boolean> personBooleanTableColumn) {
return new ButtonCell();
}
});
//Pour la deuxèmé table View rechercher un produit
TabColBEReference.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("reference"));
TabColBEDesignaton.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("designaton"));
TabColBEMarque.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("marque"));
TabColBECategorie.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("categorie"));
TabColBEPrixTTC.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("prixttc"));
TabColBEPrixTTC.setStyle( "-fx-alignment: CENTER_RIGHT; -fx-font-weight:bold; -fx-font-size: 9pt;");
TabColBETVA.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("tva"));
TabColBETVA.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColBEQuantiteTTC.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("quantite"));
TabColBEQuantiteTTC.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
//Ajouter l'option textfield
TabColBEQuantiteTTC.setCellFactory(TextFieldTableCell.<ListProduitBon>forTableColumn());
//Valier l'opertion de modification de la quantite par la sourie
TabColBEQuantiteTTC.setOnEditCommit(new EventHandler<CellEditEvent<ListProduitBon, String>>() {
@Override
public void handle(CellEditEvent<ListProduitBon, String> t) {
String NewQuantite = t.getNewValue();
String OldQuantite = t.getOldValue();
try{
double d = Double.parseDouble(NewQuantite);
//le cas ou il tape un zéro 0
if(d<=0){
((ListProduitBon) t.getTableView().getItems().get(t.getTablePosition().getRow())).setQuantite(OldQuantite);
}
else{
((ListProduitBon) t.getTableView().getItems().get(t.getTablePosition().getRow())).setQuantite(NewQuantite);
}
}
//le cas ou la nouvelle quantité n'est pas un entier
catch(NumberFormatException nfe){
//inséré l'ancienne valeur de quantité
((ListProduitBon) t.getTableView().getItems().get(t.getTablePosition().getRow())).setQuantite(OldQuantite);
}
//actualiser la ligne
TableViewListeProduitBE.getColumns().get(t.getTablePosition().getRow()).setVisible(false);
TableViewListeProduitBE.getColumns().get(t.getTablePosition().getRow()).setVisible(true);
}
});
final TextField TextQuantiteTTC = new TextField();
TextQuantiteTTC.setPromptText("quantite");
TextQuantiteTTC.setMaxWidth(TabColBEQuantiteTTC.getPrefWidth());
TabColBEAddAction.setSortable(true);
TabColBEAddAction.setStyle( "-fx-alignment: CENTER;");
TabColBEAddAction.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<ListProduitBon, Boolean>,
ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(TableColumn.CellDataFeatures<ListProduitBon, Boolean> p) {
return new SimpleBooleanProperty(p.getValue() != null);
}
});
// create a cell value factory with an add button for each row in the table.
TabColBEAddAction.setCellFactory(new Callback<TableColumn<ListProduitBon, Boolean>, TableCell<ListProduitBon, Boolean>>() {
@Override
public TableCell<ListProduitBon, Boolean> call(TableColumn<ListProduitBon, Boolean> personBooleanTableColumn) {
return new ButtonCellBE();
}
});
//get recheche produit
this.KeyEventProduit();
}
private void SearchProduit()
{
ProgressBarStockBonEnter.setVisible(true);
ThreadSearchCategorie = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
TableViewListeProduitRechercher.setItems(bonentrer.getdataProdBE(Reference, designaton, Codebarre, categorie));
return null;
}
};
}
};
ThreadSearchCategorie.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarStockBonEnter.setVisible(false);
}
});
ThreadSearchCategorie.start();
}
private void setCategorie()
{
ProgressBarStockBonEnter.setVisible(true);
ThreadSearchCategorie = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
TextFields.bindAutoCompletion(TextFieldCategorie, new CategorieDB().getListCategorie());
return null;
}
};
}
};
ThreadSearchCategorie.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarStockBonEnter.setVisible(false);
}
});
ThreadSearchCategorie.start();
}
//Define the button cell
private class ButtonCell extends TableCell<ListProduitRech, 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) {
ListProduitRech ListProRech = (ListProduitRech) ButtonCell.this.getTableView().getItems().get(ButtonCell.this.getIndex());
ListProduitBon listbrodbe = new ListProduitBon(ListProRech.getReference(), ListProRech.getDesignaton(), ListProRech.getMarque(), ListProRech.getCategorie(), ListProRech.getPrixttc(), "1", ListProRech.getTVA());
//lorce qu'il y a plus que ligne
if(data.size()>0){
boolean result = false ;
int indise = 1;
//Verifier si la produit exsiste déja
while(indise<=data.size() && !result){
result = data.get(indise-1).getReference().equals(ListProRech.getReference());
//si il le produit exisite déja on ajoute 1 a la quantité
if(result){
Integer quantite=Integer.parseInt(data.get(indise-1).getQuantite())+1;
data.get(indise-1).setQuantite(Integer.toString(quantite));
TableViewListeProduitBE.refresh();
}
indise++;
}
//si le produit n'exsiste pas on la joute à la table view
if(!result){
data.add(listbrodbe);
}
}
else{
data.add(listbrodbe);
}
TableViewListeProduitBE.setItems(data);
}
});
}
//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 ButtonCellBE extends TableCell<ListProduitBon, Boolean> {
final Button cellButton = new Button();
ButtonCellBE(){
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();
data.remove(selectdIndex);
}
});
}
//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 KeyEventProduit(){
ReferenceBE.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
Reference=ReferenceBE.getText();
designaton=DesignatonBE.getText();
Codebarre=TextFieldCodeBarre.getText();
if(Reference.isEmpty() && designaton.isEmpty() && Codebarre.isEmpty()){
TableViewListeProduitRechercher.setItems(null);
}
else{
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchProduit();
}
}
}
});
DesignatonBE.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
Reference=ReferenceBE.getText();
designaton=DesignatonBE.getText();
Codebarre=TextFieldCodeBarre.getText();
if(Reference.isEmpty() && designaton.isEmpty() && Codebarre.isEmpty()){
TableViewListeProduitRechercher.setItems(null);
}
else{
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchProduit();
}
}
}
});
TextFieldCodeBarre.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
Reference=ReferenceBE.getText();
designaton=DesignatonBE.getText();
Codebarre=TextFieldCodeBarre.getText();
if(Reference.isEmpty() && designaton.isEmpty() && Codebarre.isEmpty()){
TableViewListeProduitRechercher.setItems(null);
}
else{
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchProduit();
}
}
}
});
TextFieldCategorie.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
Reference=ReferenceBE.getText();
designaton=DesignatonBE.getText();
Codebarre = TextFieldCodeBarre.getText();
categorie = TextFieldCategorie.getText();
SearchProduit();
}
}
});
}
//Créer la bon d'entére
@FXML
private void CreerBonEnterButtonAction(ActionEvent event) throws IOException {
final BondeEntrerDialogConfirmation notification = new BondeEntrerDialogConfirmation();
contro ctl= new contro() ;
if(ComboLocale.getValue()==null){
ComboLocale.setStyle("-fx-border-color:#f20606;");
}
else if(ctl.isNumericNotnull(CodeBE.getText())){
CodeBE.setStyle("-fx-border-color:#f20606;");
}
else if(data.isEmpty()){
ComboLocale.setStyle("-fx-border-color:#cfcfcf;");
CodeBE.setStyle("-fx-border-color:#cfcfcf;");
final MessageControle messagecontrol = new MessageControle();
Text text3 = new Text();
text3.setText("Vous devez ajouter au moin un produit à la liste des produits (entrée)");
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();
}
else{
ComboLocale.setStyle("-fx-border-color:#cfcfcf;");
notification.Code.setText(CodeBE.getText());
notification.Source.setText(ComboLocale.getValue().toString());
notification.Date.setText(Adaptateur.NormalDateFormat(DateBE.getValue()));
notification.Tranporteur.setText(BonEnteeTransporteur.getText());
notification.Confdata= data;
notification.bouttonOK.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
BonEntree bonentree = new BonEntree();
bonentree.setLocal_emetteur(ComboLocale.getValue().toString());
bonentree.setLocal_recepteur(ParametreSystem.NomLocalPC);
bonentree.setId(CodeBE.getText());
//date bon d'entrée
Date Datebe = java.sql.Date.valueOf(DateBE.getValue());
bonentree.setDate(Datebe);
bonentree.setTransporteur(BonEnteeTransporteur.getText());
if(bonentrer.addBonEntrer(bonentree,data)){
notification.stackpane.setVisible(false);
AnchorPaneBondentree.getChildren().clear();
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Stock/BondeEntrerDetail.fxml"));
Parent root = (Parent)fxmlLoader.load();
AnchorPaneBondentree.getChildren().add(root);
} catch (IOException ex) {
Logger.getLogger(BondeEntrerController.class.getName()).log(Level.SEVERE, null, ex);
}
}
else{
ShowDialog SD = new ShowDialog();
SD.ShowAletDialog();
}
}
});
notification.ShowDialg();
}
}
}
@@ -0,0 +1,177 @@
/*
* 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.Stock;
import Controllers.Traitement.Adaptateur;
import Models.Stock.BonEntree;
import Models.Stock.BondeEntrerDB;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.print.JobSettings;
import javafx.print.PageRange;
import javafx.print.PrinterJob;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Text;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class BondeEntrerDetailController implements Initializable {
@FXML private AnchorPane BondeEntrerDetail;
@FXML private Button RecreerBD ;
@FXML private Text source ;
@FXML private Text id ;
@FXML private Text Textdate ;
@FXML private Text heur ;
@FXML private Text transporteur ;
@FXML private TableView<ListProduitBon> TableViewListeProduitBE ;
@FXML private TableColumn<ListProduitBon ,String> TabColBEReference;
@FXML private TableColumn<ListProduitBon ,String> TabColBEDesignation;
@FXML private TableColumn<ListProduitBon ,String> TabColBEMarque ;
@FXML private TableColumn<ListProduitBon ,String> TabColBECategorie;
@FXML private TableColumn<ListProduitBon ,String> TabColBEPrixTTC;
@FXML private TableColumn<ListProduitBon ,String> TabColBEQuantiteTTC;
@FXML private TableColumn<ListProduitBon ,String> TabColBETVA;
public static String id_bondentree ;
BondeEntrerDB MyBonEntreeDB = new BondeEntrerDB();
BonEntree MyBonEntree = new BonEntree();
@Override
public void initialize(URL url, ResourceBundle rb) {
Image coffeeImage = new Image(getClass().getResourceAsStream("/Public/icon/icon-relogin.png"));
ImageView buttonGraphic = new ImageView();
buttonGraphic.setImage(coffeeImage);
RecreerBD.setGraphic(buttonGraphic);
TabColBEReference.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("reference"));
TabColBEDesignation.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("designaton"));
TabColBEMarque.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("marque"));
TabColBECategorie.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("categorie"));
TabColBEPrixTTC.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("prixttc"));
TabColBEPrixTTC.setStyle( "-fx-alignment: CENTER_RIGHT;");
TabColBETVA.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("tva"));
TabColBETVA.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColBEQuantiteTTC.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("quantite"));
TabColBEQuantiteTTC.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
MyBonEntree = MyBonEntreeDB.getBonEntree(id_bondentree);
id.setText(MyBonEntree.getId());
source.setText(MyBonEntree.getLocal_emetteur());
Textdate.setText(Adaptateur.NormalDateFormat(MyBonEntree.getDate().toString()));
heur.setText(MyBonEntree.getHeur().toString());
transporteur.setText(MyBonEntree.getTransporteur());
TableViewListeProduitBE.setItems(MyBonEntree.getListe_prod());
}
@FXML
private void PDFBonEntreButtonAction(ActionEvent event) throws IOException {
try {
ObservableList<ListProduitBon> ListProd = MyBonEntree.getListe_prod();
PrinterJob jobExportPDF = PrinterJob.createPrinterJob();
int SizelistMouvement = ListProd.size();
int total = SizelistMouvement / 20 + 1 ;
int page = 0;
for (int i=0; i<SizelistMouvement; i+=20){
ObservableList<ListProduitBon> listProdTemp = FXCollections.observableArrayList();
for (int j=i; (j<(i+20)) && (j<SizelistMouvement); j++){
listProdTemp.add(ListProd.get(j));
}
FXMLLoader fxmlLoaderPrintBonEnter = new FXMLLoader(getClass().getResource("/Views/Stock/PrintBon.fxml"));
final Node ParentFxmlPrintBonEnter = (Node)fxmlLoaderPrintBonEnter.load();
BondeEnterPrintController PrintBonEnter = fxmlLoaderPrintBonEnter.getController();
page++;
PrintBonEnter.setDataBonEnter(listProdTemp, "Bon d'entrée dépuis ", MyBonEntree.getLocal_emetteur(), "Récepteur", MyBonEntree.getLocal_recepteur(), MyBonEntree.getId(), MyBonEntree.getDate().toString(), MyBonEntree.getHeur().toString(), MyBonEntree.getTransporteur(), page+"/"+total);
jobExportPDF.printPage(ParentFxmlPrintBonEnter);
}
jobExportPDF.endJob();
} catch (IOException ex) {
System.err.println("BondeEntrerDetailController PDFBonEntreButtonAction ! \n"+ex.getMessage());
}
}
@FXML
private void PrintBonEntreButtonAction(ActionEvent event) throws IOException {
try {
ObservableList<ListProduitBon> ListProd = MyBonEntree.getListe_prod();
int SizelistMouvement = ListProd.size();
int total = SizelistMouvement / 20 + 1 ;
int page = 0;
PrinterJob jobPrint = PrinterJob.createPrinterJob();
jobPrint.getJobSettings().setPageRanges(new PageRange(1, total));
if (jobPrint.showPrintDialog(null)) {
JobSettings jsPrint = jobPrint.getJobSettings();
for (int i=0; i<SizelistMouvement; i+=20){
ObservableList<ListProduitBon> listProdTemp = FXCollections.observableArrayList();
for (int j=i; (j<(i+20)) && (j<SizelistMouvement); j++){
listProdTemp.add(ListProd.get(j));
}
FXMLLoader fxmlLoaderPrintBonEnter = new FXMLLoader(getClass().getResource("/Views/Stock/BondeEnterPrint.fxml"));
final Node ParentFxmlPrintBonEnter = (Node)fxmlLoaderPrintBonEnter.load();
BondeEnterPrintController PrintBonEnter = fxmlLoaderPrintBonEnter.getController();
page++;
PrintBonEnter.setDataBonEnter(listProdTemp, "Bon d'entrée dépuis ", MyBonEntree.getLocal_emetteur(), "Récepteur", MyBonEntree.getLocal_recepteur(), MyBonEntree.getId(), MyBonEntree.getDate().toString(), MyBonEntree.getHeur().toString(), MyBonEntree.getTransporteur(), page+"/"+total);
jobPrint.printPage(ParentFxmlPrintBonEnter);
}
jobPrint.endJob();
}
} catch (IOException ex) {
System.err.println("BondeEntrerDetailController PrintBonEntreButtonAction ! \n"+ex.getMessage());
}
}
@FXML
private void NewBonEnterButtonAction(ActionEvent event) throws IOException {
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Stock/BondeEntrer.fxml"));
Parent root = (Parent)fxmlLoader.load();
BondeEntrerDetail.getChildren().clear();
BondeEntrerDetail.getChildren().add(root);
} catch (IOException ex) {
Logger.getLogger(BondeEntrerController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
@@ -0,0 +1,247 @@
/*
* 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.Stock;
import Controllers.Traitement.MyWindow;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import javafx.stage.Stage;
/**
*
* @author Maher
*/
public class BondeEntrerDialogConfirmation extends BondeEntrerController{
public double Height = MyWindow.myStage.getHeight() ;
public double Width = MyWindow.myStage.getWidth() ;
public ObservableList<ListProduitBon> Confdata=FXCollections.observableArrayList();
public Button bouttonNo = new Button();
public Button bouttonOK = new Button("Enregistrer");
public TableView ConfBondEnter = new TableView();
public Text titre = new Text();
public Text Source = new Text();
public Text Code = new Text();
public Text Tranporteur = new Text();
public Text Date = new Text();
public Text titreMSG = new Text();
public Text detail = new Text();
public StackPane stackpane = new StackPane();
public Node Setnotification(){
Group group = new Group();
AnchorPane Ap = new AnchorPane();
Ap.setStyle("-fx-background-color: rgba(0,0,0,0.6);");
Pane pa1 = new Pane();
pa1.setStyle("-fx-background-color:#ffffff; -fx-border-color: #212121; -fx-border-radius: 10 10 0 0; -fx-background-radius: 10 10 0 0;");
pa1.setPrefHeight(550);
pa1.setPrefWidth(750);
Pane pa2 = new Pane();
pa2.setStyle("-fx-background-color:linear-gradient(to bottom, #585858, #333333); -fx-background-radius: 10 10 0 0;");
pa2.setPrefHeight(30);
pa2.setPrefWidth(750);
TableColumn TabColBEReference = new TableColumn("Référence");
TabColBEReference.setMinWidth(125);
TabColBEReference.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("reference"));
TableColumn TabColBEDesignaton = new TableColumn("Désignation");
TabColBEDesignaton.setMinWidth(155);
TabColBEDesignaton.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("designaton"));
TableColumn TabColBEMarque = new TableColumn("Marque");
TabColBEMarque.setMinWidth(100);
TabColBEMarque.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("marque"));
TableColumn TabColBECategorie = new TableColumn("Catégorie");
TabColBECategorie.setMinWidth(100);
TabColBECategorie.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("categorie"));
TableColumn TabColBETVA = new TableColumn("TVA");
TabColBETVA.setMinWidth(70);
TabColBETVA.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("tva"));
TableColumn TabColBEPrixTTC = new TableColumn("Prix TTC");
TabColBEPrixTTC.setMinWidth(70);
TabColBEPrixTTC.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("prixttc"));
TabColBEPrixTTC.setStyle( "-fx-alignment: CENTER_RIGHT;");
TableColumn TabColBEQuantite = new TableColumn("Quantité");
TabColBEQuantite.setMinWidth(70);
TabColBEQuantite.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("quantite"));
TabColBEQuantite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TableView<ListProduitBon> ConfBonEnter = new TableView<ListProduitBon>();
ConfBonEnter.getColumns().addAll(TabColBEReference, TabColBEDesignaton, TabColBEMarque, TabColBECategorie, TabColBETVA, TabColBEPrixTTC, TabColBEQuantite);
ConfBonEnter.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
ConfBonEnter.setLayoutX(12);
ConfBonEnter.setLayoutY(130);
ConfBonEnter.setPrefHeight(350);
ConfBonEnter.setItems(Confdata);
titre.setText("Dialog de confirmation");
titre.setFont(Font.font("System", FontWeight.BOLD, 14));
titre.setFill(Color.web("#ffffff"));
titre.setLayoutX(17);
titre.setLayoutY(22);
Image imgicon = new Image(getClass().getResourceAsStream("/Public/icon/dialoginform.png"));
ImageView icon = new ImageView(imgicon);
icon.setLayoutX(20);
icon.setLayoutY(60);
icon.setFitWidth(46);
icon.setFitHeight(50);
TextFlow DetailMSG = new TextFlow();
DetailMSG.setPrefHeight(120);
DetailMSG.setPrefWidth(400);
DetailMSG.setLayoutX(80);
DetailMSG.setLayoutY(55);
Text text1 = new Text("Bon d'entrée \n");
text1.setFont(Font.font("Arial", FontWeight.BOLD, 15));
text1.setFill(Color.web("#363a38"));
DetailMSG.getChildren().add(text1);
Text text2 = new Text("Êtes-vous sûr de vouloir enregistrer la bon d'entrée");
text2.setFont(Font.font("Arial", FontWeight.NORMAL, 15));
text2.setFill(Color.web("#363a38"));
DetailMSG.getChildren().add(text2);
Text code = new Text("Code:");
code.setFont(Font.font("Arial", FontWeight.BOLD, 15));
code.setFill(Color.web("#363a38"));
code.setLayoutX(80);
code.setLayoutY(115);
Code.setFont(Font.font("Arial", FontWeight.NORMAL, 15));
Code.setFill(Color.web("#363a38"));
Code.setLayoutX(130);
Code.setLayoutY(115);
Text source = new Text("Source:");
source.setFont(Font.font("Arial", FontWeight.BOLD, 15));
source.setFill(Color.web("#363a38"));
source.setLayoutX(180);
source.setLayoutY(115);
Source.setFont(Font.font("Arial", FontWeight.NORMAL, 15));
Source.setFill(Color.web("#363a38"));
Source.setLayoutX(240);
Source.setLayoutY(115);
Text date = new Text("Date:");
date.setFont(Font.font("Arial", FontWeight.BOLD, 15));
date.setFill(Color.web("#363a38"));
date.setLayoutX(350);
date.setLayoutY(115);
Date.setFont(Font.font("Arial", FontWeight.NORMAL, 15));
Date.setFill(Color.web("#363a38"));
Date.setLayoutX(390);
Date.setLayoutY(115);
Text tranporteur = new Text("Tranporteur:");
tranporteur.setFont(Font.font("Arial", FontWeight.BOLD, 15));
tranporteur.setFill(Color.web("#363a38"));
tranporteur.setLayoutX(500);
tranporteur.setLayoutY(115);
Tranporteur.setFont(Font.font("Arial", FontWeight.NORMAL, 15));
Tranporteur.setFill(Color.web("#363a38"));
Tranporteur.setLayoutX(600);
Tranporteur.setLayoutY(115);
bouttonOK.setFont(Font.font ("Arial", FontWeight.BOLD, 14));
bouttonOK.setStyle("-fx-background-color:#4DAE4D; -fx-text-fill: white; -fx-border-radius: 5 5 5 5;");
Image coffeeImage = new Image(getClass().getResourceAsStream("/Public/icon/iconsave.png"));
ImageView buttonGraphic = new ImageView();
buttonGraphic.setImage(coffeeImage);
bouttonOK.setGraphic(buttonGraphic);
bouttonOK.setPrefWidth(140);
bouttonOK.setPrefHeight(35);
bouttonOK.setLayoutX(600);
bouttonOK.setLayoutY(500);
bouttonNo.setText("Annuler");
bouttonNo.setFont(Font.font ("System", FontWeight.BOLD, 12));
bouttonNo.setStyle("{-fx-background-color:#EFEFEF; -fx-border-color: #959595; -fx-border-radius: 5 5 5 5;} hover:{-fx-background-color:#E6E6E6;}");
bouttonNo.setPrefWidth(73);
bouttonNo.setPrefHeight(30);
bouttonNo.setLayoutX(500);
bouttonNo.setLayoutY(503);
bouttonNo.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
stackpane.setVisible(false);
}
});
group.getChildren().addAll(pa1, pa2, titre, icon, code, Code, source, Source, date, Date, tranporteur, Tranporteur, ConfBonEnter, DetailMSG, bouttonOK, bouttonNo);
stackpane.setVisible(true);
stackpane.getChildren().add(Ap);
stackpane.getChildren().add(group);
return stackpane;
}
public void ShowDialg()
{
Node node = this.Setnotification();
StackPane Sp = new StackPane();
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(node);
Scene scene = new Scene(Sp);
Stage stage = MyWindow.myStage;
stage.setScene(scene);
stage.show();
}
}
@@ -0,0 +1,605 @@
/*
* 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.Stock;
import Controllers.Dialog.MessageControle;
import Controllers.Dialog.ShowDialog;
import Controllers.Traitement.Adaptateur;
import Controllers.Traitement.ParametreSystem;
import Models.Categorie.CategorieDB;
import Models.Stock.BonSortie;
import Models.Stock.BondeSortieDB;
import Models.Stock.StockDB;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.time.LocalDate;
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.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.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleButton;
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.KeyCode;
import javafx.scene.input.KeyEvent;
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 Ben Tili
*/
public class BondeSortieController implements Initializable {
@FXML private AnchorPane AnchorPaneBonSortie;
@FXML private ProgressBar ProgressBarStockBonSortie;
@FXML private Text LocalEmetteur ;
@FXML private ComboBox ComboLocale;
@FXML private ToggleButton Activate ; //permet d'activer la l'option de rechercher dans la table produit (Stock négative)
@FXML private DatePicker DateBS;
@FXML private TextField TextFieldCategorie;
@FXML private TextField SortieTransporteur;
@FXML private TextField ReferenceBE;
@FXML private TextField DesignatonBE;
@FXML private TextField TextFieldCodeBarre;
@FXML private TableView<ListProduitRech> TableViewListeProduitRechercher ;
@FXML private TableColumn<ListProduitRech ,String> TabColRechReference;
@FXML private TableColumn<ListProduitRech ,String> TabColRechDesignaton;
@FXML private TableColumn<ListProduitRech ,String> TabColRechMarque ;
@FXML private TableColumn<ListProduitRech ,String> TabColRechCategorie;
@FXML private TableColumn<ListProduitRech ,String> TabColRechPrixTTC;
@FXML private TableColumn<ListProduitRech ,String> TabColRechTVA;
@FXML private TableColumn<ListProduitRech ,String> TabColRechQuantite;
@FXML private TableColumn<ListProduitRech, Boolean> TabColRechAddAction ;
@FXML private TableView<ListProduitBon> TableViewListeProduitBE ;
@FXML private TableColumn<ListProduitBon ,String> TabColBEReference;
@FXML private TableColumn<ListProduitBon ,String> TabColBEDesignaton;
@FXML private TableColumn<ListProduitBon ,String> TabColBEMarque ;
@FXML private TableColumn<ListProduitBon ,String> TabColBECategorie;
@FXML private TableColumn<ListProduitBon ,String> TabColBEPrixTTC;
@FXML private TableColumn<ListProduitBon ,String> TabColBEQuantiteTTC;
@FXML private TableColumn<ListProduitBon ,String> TabColBETVA;
@FXML private TableColumn<ListProduitBon, Boolean> TabColBEAddAction ;
private Service<Void> ThreadSearchCategorieSortie;
ObservableList<ListProduitBon> data=FXCollections.observableArrayList();
BondeSortieDB bonsortiedb = new BondeSortieDB();
StockDB stockdb = new StockDB();
Boolean StockNegative = false; //option de ToggleGroup Activate ;
String categorie="" ;
String Reference="" ;
String designaton="" ;
String codeBarre="" ;
@Override
public void initialize(URL url, ResourceBundle rb) {
LocalEmetteur.setText(ParametreSystem.NomLocalPC);
DateBS.setValue(LocalDate.now());
Activate.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent t) {
StockNegative = Activate.selectedProperty().getValue();
}
});
//Liste des Locales
ComboLocale.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent t) {
ComboLocale.setStyle("-fx-border-color:#cfcfcf;");
ComboLocale.getItems().clear();
ComboLocale.getItems().addAll(stockdb.getListLocal());
}
});
TableViewListeProduitBE.setEditable(true);
//Pour la premiére table View rechercher un produit
TabColRechReference.setCellValueFactory(new PropertyValueFactory<ListProduitRech, String>("reference"));
TabColRechDesignaton.setCellValueFactory(new PropertyValueFactory<ListProduitRech, String>("designaton"));
TabColRechMarque.setCellValueFactory(new PropertyValueFactory<ListProduitRech, String>("marque"));
TabColRechCategorie.setCellValueFactory(new PropertyValueFactory<ListProduitRech, String>("categorie"));
TabColRechPrixTTC.setCellValueFactory(new PropertyValueFactory<ListProduitRech, String>("prixttc"));
TabColRechPrixTTC.setStyle( "-fx-alignment: CENTER_RIGHT; -fx-font-weight:bold;");
TabColRechTVA.setCellValueFactory(new PropertyValueFactory<ListProduitRech, String>("TVA"));
TabColRechTVA.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold;");
TabColRechQuantite.setCellValueFactory(new PropertyValueFactory<ListProduitRech, String>("quantite"));
TabColRechQuantite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold;");
TabColRechAddAction.setSortable(true);
TabColRechAddAction.setStyle( "-fx-alignment: CENTER;");
TabColRechAddAction.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<ListProduitRech, Boolean>,
ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(TableColumn.CellDataFeatures<ListProduitRech, 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<ListProduitRech, Boolean>, TableCell<ListProduitRech, Boolean>>() {
@Override
public TableCell<ListProduitRech, Boolean> call(TableColumn<ListProduitRech, Boolean> personBooleanTableColumn) {
return new BondeSortieController.ButtonCell();
}
});
//Pour la deuxèmé table View rechercher un produit
TabColBEReference.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("reference"));
TabColBEDesignaton.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("designaton"));
TabColBEMarque.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("marque"));
TabColBECategorie.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("categorie"));
TabColBEPrixTTC.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("prixttc"));
TabColBEPrixTTC.setStyle( "-fx-alignment: CENTER_RIGHT; -fx-font-weight:bold; -fx-font-size: 9pt;");
TabColBETVA.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("tva"));
TabColBETVA.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColBEQuantiteTTC.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("quantite"));
TabColBEQuantiteTTC.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
//Ajouter l'option textfield
TabColBEQuantiteTTC.setCellFactory(TextFieldTableCell.<ListProduitBon>forTableColumn());
//Valier l'opertion de modification de la quantite par la sourie
TabColBEQuantiteTTC.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent<ListProduitBon, String>>() {
@Override
public void handle(TableColumn.CellEditEvent<ListProduitBon, String> t) {
String NewQuantite = t.getNewValue();
String OldQuantite = t.getOldValue();
try{
double d = Double.parseDouble(NewQuantite);
String ref =t.getTableView().getItems().get(t.getTablePosition().getRow()).getReference();
Integer quantStock = bonsortiedb.GetQuantiteStock(ref);
//le cas ou il tape un zéro 0
if(d<=0){
((ListProduitBon) t.getTableView().getItems().get(t.getTablePosition().getRow())).setQuantite(OldQuantite);
}
// le ca ou la quantité BS ne doit pas dépassé la quantité en stock
else if(!StockNegative && quantStock<d){
final MessageControle messagecontrol = new MessageControle();
Text text3 = new Text();
text3.setText("La quantité en bon de sortie ne doit pas dépassé la quantité en stock");
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();
}
else{
((ListProduitBon) t.getTableView().getItems().get(t.getTablePosition().getRow())).setQuantite(NewQuantite);
}
}
//le cas ou la nouvelle quantité n'est pas un entier
catch(NumberFormatException nfe){
//inséré l'ancienne valeur de quantité
((ListProduitBon) t.getTableView().getItems().get(t.getTablePosition().getRow())).setQuantite(OldQuantite);
}
//actualiser la ligne
TableViewListeProduitBE.getColumns().get(t.getTablePosition().getRow()).setVisible(false);
TableViewListeProduitBE.getColumns().get(t.getTablePosition().getRow()).setVisible(true);
}
});
final TextField TextQuantiteTTC = new TextField();
TextQuantiteTTC.setPromptText("quantite");
TextQuantiteTTC.setMaxWidth(TabColBEQuantiteTTC.getPrefWidth());
TabColBEAddAction.setSortable(true);
TabColBEAddAction.setStyle( "-fx-alignment: CENTER;");
TabColBEAddAction.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<ListProduitBon, Boolean>,
ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(TableColumn.CellDataFeatures<ListProduitBon, Boolean> p) {
return new SimpleBooleanProperty(p.getValue() != null);
}
});
// create a cell value factory with an add button for each row in the table.
TabColBEAddAction.setCellFactory(new Callback<TableColumn<ListProduitBon, Boolean>, TableCell<ListProduitBon, Boolean>>() {
@Override
public TableCell<ListProduitBon, Boolean> call(TableColumn<ListProduitBon, Boolean> personBooleanTableColumn) {
return new BondeSortieController.ButtonCellBE();
}
});
//get recheche produit
this.KeyEventProduit();
this.setCategorie();
}
//Methode pour récupéré la selection du catégorie
private void setCategorie()
{
ProgressBarStockBonSortie.setVisible(true);
ThreadSearchCategorieSortie = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
TextFields.bindAutoCompletion(TextFieldCategorie, new CategorieDB().getListCategorie());
return null;
}
};
}
};
ThreadSearchCategorieSortie.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarStockBonSortie.setVisible(false);
}
});
ThreadSearchCategorieSortie.start();
}
//Define the button cell
private class ButtonCell extends TableCell<ListProduitRech, 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) {
ListProduitRech ListProRech = (ListProduitRech) ButtonCell.this.getTableView().getItems().get(ButtonCell.this.getIndex());
ListProduitBon listbrodbe = new ListProduitBon(ListProRech.getReference(), ListProRech.getDesignaton(), ListProRech.getMarque(), ListProRech.getCategorie(), ListProRech.getPrixttc(), "1", ListProRech.getTVA());
//lorce qu'il y a plus que ligne
if(data.size()>0){
boolean result = false ;
int indise = 1;
//Verifier si la produit exsiste déja
while(indise<=data.size() && !result){
result = data.get(indise-1).getReference().equals(ListProRech.getReference());
//si il le produit exisite déja on ajoute 1 a la quantité
if(result){
//quantité disponible en stock
Integer QuantiteStock = Integer.valueOf(ListProRech.getQuantite());
Integer quantiteBS=Integer.parseInt(data.get(indise-1).getQuantite())+1;
//le cas ou quantité en bon de sortie ne doit pas dépassé la quantité en stock
if(!StockNegative){
if(quantiteBS<=QuantiteStock){
data.get(indise-1).setQuantite(Integer.toString(quantiteBS));
}
else{
//le ca ou la quantité en bon de sortie dépasse la quntité en stock
final MessageControle messagecontrol = new MessageControle();
Text text3 = new Text();
text3.setText("La quantité en bon de sortie ne doit pas dépassé la quantité en stock");
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();
}
}
// le ca ou on la la possibilité de stock négative
else{
data.get(indise-1).setQuantite(Integer.toString(quantiteBS));
}
TableViewListeProduitBE.getColumns().get(indise-1).setVisible(false);
TableViewListeProduitBE.getColumns().get(indise-1).setVisible(true);
}
indise++;
}
//si le produit n'exsiste pas on la joute à la table view
if(!result){
data.add(listbrodbe);
}
}
else{
data.add(listbrodbe);
}
TableViewListeProduitBE.setItems(data);
}
});
}
//Display button if the row is not empty
@Override
protected void updateItem(Boolean t, boolean empty) {
if(!empty){
setGraphic(cellButton);
} else {
setGraphic(null);
}
}
}
//methode pour céer la bon de sortie
@FXML
private void CreerBonSortieButtonAction(ActionEvent event) throws IOException {
if(ComboLocale.getValue()==null){
ComboLocale.setStyle("-fx-border-color:#f20606;");
}
else if(data.isEmpty()){
ComboLocale.setStyle("-fx-border-color:#cfcfcf;");
final MessageControle messagecontrol = new MessageControle();
Text text3 = new Text();
text3.setText("Vous devez ajouter au moin un produit à la liste des produits (Sortie)");
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();
}
else{
final BondeSortieDialogConfirmation notification = new BondeSortieDialogConfirmation();
notification.Date.setText(Adaptateur.NormalDateFormat(DateBS.getValue()));
notification.Tranporteur.setText(SortieTransporteur.getText());
notification.Affecter.setText(ComboLocale.getValue().toString());
notification.Confdata= data;
notification.bouttonOK.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
//date bon de sortie
BonSortie bonsortie = new BonSortie();
bonsortie.setDate(java.sql.Date.valueOf(DateBS.getValue()));
bonsortie.setTransporteur(SortieTransporteur.getText());
bonsortie.setLocal_emetteur(ParametreSystem.NomLocalPC);
bonsortie.setLocal_recepteur(ComboLocale.getValue().toString());
bonsortie.setListe_prod(data);
if(bonsortiedb.addBonSortie(bonsortie)){
notification.stackpane.setVisible(false);
AnchorPaneBonSortie.getChildren().clear();
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Stock/BondeSortieDetail.fxml"));
Parent root = (Parent)fxmlLoader.load();
AnchorPaneBonSortie.getChildren().add(root);
} catch (IOException ex) {
Logger.getLogger(BondeEntrerController.class.getName()).log(Level.SEVERE, null, ex);
}
}
else{
ShowDialog SD = new ShowDialog();
ShowDialog.titre="Erreur Système";
ShowDialog.detail="Models/Stock/BonSortieController.java";
SD.ShowAletDialog();
}
}
});
notification.ShowDialg();
}
}
//Define the button cell
private class ButtonCellBE extends TableCell<ListProduitBon, Boolean> {
final Button cellButton = new Button();
ButtonCellBE(){
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();
data.remove(selectdIndex);
}
});
}
//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 SearchProduit()
{
ProgressBarStockBonSortie.setVisible(true);
ThreadSearchCategorieSortie = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
TableViewListeProduitRechercher.setItems(bonsortiedb.getdataProdBS(Reference, designaton, codeBarre, categorie,StockNegative));
return null;
}
};
}
};
ThreadSearchCategorieSortie.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
ProgressBarStockBonSortie.setVisible(false);
}
});
ThreadSearchCategorieSortie.start();
}
private void KeyEventProduit(){
ReferenceBE.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
Reference=ReferenceBE.getText();
designaton=DesignatonBE.getText();
codeBarre = TextFieldCodeBarre.getText();
if(Reference.isEmpty() && designaton.isEmpty() && codeBarre.isEmpty()){
TableViewListeProduitRechercher.setItems(null);
}
else{
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchProduit();
}
}
}
});
DesignatonBE.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
Reference=ReferenceBE.getText();
designaton=DesignatonBE.getText();
codeBarre = TextFieldCodeBarre.getText();
if(Reference.isEmpty() && designaton.isEmpty() && codeBarre.isEmpty()){
TableViewListeProduitRechercher.setItems(null);
}
else{
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchProduit();
}
}
}
});
TextFieldCodeBarre.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
Reference=ReferenceBE.getText();
designaton=DesignatonBE.getText();
codeBarre = TextFieldCodeBarre.getText();
if(Reference.isEmpty() && designaton.isEmpty() && codeBarre.isEmpty()){
TableViewListeProduitRechercher.setItems(null);
}
else{
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchProduit();
}
}
}
});
TextFieldCategorie.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
Reference=ReferenceBE.getText();
designaton=DesignatonBE.getText();
codeBarre = TextFieldCodeBarre.getText();
categorie = TextFieldCategorie.getText();
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchProduit();
}
}
}
});
}
}
@@ -0,0 +1,173 @@
/*
* 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.Stock;
import Controllers.Traitement.Adaptateur;
import Models.Stock.BonSortie;
import Models.Stock.BondeSortieDB;
import Models.Stock.StockDB;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.print.JobSettings;
import javafx.print.PageRange;
import javafx.print.PrinterJob;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Text;
/**
* FXML Controller class
*
* @author PC-Maher
*/
public class BondeSortieDetailController implements Initializable {
@FXML private AnchorPane BonSortieDetail;
@FXML private Button RecreerBD ;
@FXML private Text recepteur ;
@FXML private Text id ;
@FXML private Text date ;
@FXML private Text heur ;
@FXML private Text transporteur ;
@FXML private TableView<ListProduitBon> TableViewListeProduitBon ;
@FXML private TableColumn<ListProduitBon ,String> TabColBonReference;
@FXML private TableColumn<ListProduitBon ,String> TabColBonDesignaton;
@FXML private TableColumn<ListProduitBon ,String> TabColBonMarque ;
@FXML private TableColumn<ListProduitBon ,String> TabColBonCategorie;
@FXML private TableColumn<ListProduitBon ,String> TabColBonPrixTTC;
@FXML private TableColumn<ListProduitBon ,String> TabColBonQuantiteTTC;
@FXML private TableColumn<ListProduitBon ,String> TabColBonTVA;
public static String id_bonsortie ;
BondeSortieDB MyBondeSortieDB = new BondeSortieDB();
BonSortie MyBonSortie = new BonSortie();
@Override
public void initialize(URL url, ResourceBundle rb) {
Image coffeeImage = new Image(getClass().getResourceAsStream("/Public/icon/icon-relogin.png"));
ImageView buttonGraphic = new ImageView();
buttonGraphic.setImage(coffeeImage);
RecreerBD.setGraphic(buttonGraphic);
TabColBonReference.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("reference"));
TabColBonDesignaton.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("designaton"));
TabColBonMarque.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("marque"));
TabColBonCategorie.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("categorie"));
TabColBonPrixTTC.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("prixttc"));
TabColBonPrixTTC.setStyle( "-fx-alignment: CENTER_RIGHT;");
TabColBonTVA.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("tva"));
TabColBonTVA.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColBonQuantiteTTC.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("quantite"));
TabColBonQuantiteTTC.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
MyBonSortie = MyBondeSortieDB.getBonSortie(id_bonsortie);
id.setText(MyBonSortie.getId());
recepteur.setText(MyBonSortie.getLocal_recepteur());
date.setText(Adaptateur.NormalDateFormat(MyBonSortie.getDate().toString()));
heur.setText(MyBonSortie.getHeur().toString());
transporteur.setText(MyBonSortie.getTransporteur());
TableViewListeProduitBon.setItems(MyBonSortie.getListe_prod());
//Methode qui supprime les produit qont la quantité est égale à 0
StockDB MyStock = new StockDB();
MyStock.DeleteProdStock();
}
@FXML
private void PDFBonSortieButtonAction(ActionEvent event) throws IOException {
try {
ObservableList<ListProduitBon> ListProd = MyBonSortie.getListe_prod();
PrinterJob jobExportPDF = PrinterJob.createPrinterJob();
int SizelistMouvement = ListProd.size();
int total = SizelistMouvement / 20 + 1 ;
int page = 0;
for (int i=0; i<SizelistMouvement; i+=20){
ObservableList<ListProduitBon> listProdTemp = FXCollections.observableArrayList();
for (int j=i; (j<(i+20)) && (j<SizelistMouvement); j++){
listProdTemp.add(ListProd.get(j));
}
FXMLLoader fxmlLoaderPrintBonSortie = new FXMLLoader(getClass().getResource("/Views/Stock/PrintBon.fxml"));
final Node ParentFxmlPrintBonSortie = (Node)fxmlLoaderPrintBonSortie.load();
BondeEnterPrintController PrintBonSortie = fxmlLoaderPrintBonSortie.getController();
page++;
PrintBonSortie.setDataBonEnter(listProdTemp, "Bon de sortie à ", MyBonSortie.getLocal_recepteur(), "Emetteur: ", MyBonSortie.getLocal_emetteur(), MyBonSortie.getId(), MyBonSortie.getDate().toString(), MyBonSortie.getHeur().toString(), MyBonSortie.getTransporteur(), page+"/"+total);
jobExportPDF.printPage(ParentFxmlPrintBonSortie);
}
jobExportPDF.endJob();
} catch (IOException ex) {
System.err.println("BondeSortierDetailController PDFBonSortieButtonAction ! \n"+ex.getMessage());
}
}
@FXML
private void PrintBonSortieButtonAction(ActionEvent event) throws IOException {
try {
ObservableList<ListProduitBon> ListProd = MyBonSortie.getListe_prod();
int SizelistMouvement = ListProd.size();
int total = SizelistMouvement / 20 + 1 ;
int page = 0;
PrinterJob jobPrint = PrinterJob.createPrinterJob();
jobPrint.getJobSettings().setPageRanges(new PageRange(1, total));
if (jobPrint.showPrintDialog(null)) {
JobSettings jsPrint = jobPrint.getJobSettings();
for (int i=0; i<SizelistMouvement; i+=20){
ObservableList<ListProduitBon> listProdTemp = FXCollections.observableArrayList();
for (int j=i; (j<(i+20)) && (j<SizelistMouvement); j++){
listProdTemp.add(ListProd.get(j));
}
FXMLLoader fxmlLoaderPrintBonSortie = new FXMLLoader(getClass().getResource("/Views/Stock/PrintBon.fxml"));
final Node ParentFxmlPrintBonSortie = (Node)fxmlLoaderPrintBonSortie.load();
BondeEnterPrintController PrintBonSortie = fxmlLoaderPrintBonSortie.getController();
page++;
PrintBonSortie.setDataBonEnter(listProdTemp, "Bon de sortie à ", MyBonSortie.getLocal_recepteur(), "Emetteur: ", MyBonSortie.getLocal_emetteur(), MyBonSortie.getId(), MyBonSortie.getDate().toString(), MyBonSortie.getHeur().toString(), MyBonSortie.getTransporteur(), page+"/"+total);
jobPrint.printPage(ParentFxmlPrintBonSortie);
}
jobPrint.endJob();
}
} catch (IOException ex) {
System.err.println("BondeSortierDetailController PrintBonSortieButtonAction ! \n"+ex.getMessage());
}
}
@FXML
private void NewBonSortieButtonAction(ActionEvent event) throws IOException {
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Stock/BondeSortie.fxml"));
Parent root = (Parent)fxmlLoader.load();
BonSortieDetail.getChildren().clear();
BonSortieDetail.getChildren().add(root);
} catch (IOException ex) {
Logger.getLogger(BondeEntrerController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
@@ -0,0 +1,235 @@
/*
* 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.Stock;
import Controllers.Traitement.MyWindow;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import javafx.stage.Stage;
/**
*
* @author PC-Maher
*/
public class BondeSortieDialogConfirmation extends BondeSortieController {
public double Height = MyWindow.myStage.getHeight() ;
public double Width = MyWindow.myStage.getWidth() ;
public ObservableList<ListProduitBon> Confdata=FXCollections.observableArrayList();
public Button bouttonNo = new Button();
public Button bouttonOK = new Button("Enregistrer");
public TableView ConfBondEnter = new TableView();
public Text titre = new Text();
public Text Affecter = new Text();
public Text Tranporteur = new Text();
public Text Date = new Text();
public Text titreMSG = new Text();
public Text detail = new Text();
public StackPane stackpane = new StackPane();
public Node Setnotification(){
Group group = new Group();
AnchorPane Ap = new AnchorPane();
Ap.setStyle("-fx-background-color: rgba(0,0,0,0.6);");
Pane pa1 = new Pane();
pa1.setStyle("-fx-background-color:#ffffff; -fx-border-color: #212121; -fx-border-radius: 10 10 0 0; -fx-background-radius: 10 10 0 0;");
pa1.setPrefHeight(550);
pa1.setPrefWidth(750);
Pane pa2 = new Pane();
pa2.setStyle("-fx-background-color:linear-gradient(to bottom, #585858, #333333); -fx-background-radius: 10 10 0 0;");
pa2.setPrefHeight(30);
pa2.setPrefWidth(750);
TableColumn TabColBEReference = new TableColumn("Référence");
TabColBEReference.setMinWidth(125);
TabColBEReference.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("reference"));
TableColumn TabColBEDesignaton = new TableColumn("Désignation");
TabColBEDesignaton.setMinWidth(155);
TabColBEDesignaton.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("designaton"));
TableColumn TabColBEMarque = new TableColumn("Marque");
TabColBEMarque.setMinWidth(100);
TabColBEMarque.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("marque"));
TableColumn TabColBECategorie = new TableColumn("Catégorie");
TabColBECategorie.setMinWidth(100);
TabColBECategorie.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("categorie"));
TableColumn TabColBETVA = new TableColumn("TVA");
TabColBETVA.setMinWidth(70);
TabColBETVA.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("tva"));
TabColBETVA.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TableColumn TabColBEPrixTTC = new TableColumn("Prix TTC");
TabColBEPrixTTC.setMinWidth(70);
TabColBEPrixTTC.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("prixttc"));
TabColBEPrixTTC.setStyle( "-fx-alignment: CENTER_RIGHT;");
TableColumn TabColBEQuantite = new TableColumn("Quantité");
TabColBEQuantite.setMinWidth(70);
TabColBEQuantite.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("quantite"));
TabColBEQuantite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TableView<ListProduitBon> ConfBonEnter = new TableView<ListProduitBon>();
ConfBonEnter.getColumns().addAll(TabColBEReference, TabColBEDesignaton, TabColBEMarque, TabColBECategorie, TabColBETVA, TabColBEPrixTTC, TabColBEQuantite);
ConfBonEnter.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
ConfBonEnter.setLayoutX(12);
ConfBonEnter.setLayoutY(130);
ConfBonEnter.setPrefHeight(350);
ConfBonEnter.setItems(Confdata);
titre.setText("Dialog de confirmation");
titre.setFont(Font.font("System", FontWeight.BOLD, 14));
titre.setFill(Color.web("#ffffff"));
titre.setLayoutX(17);
titre.setLayoutY(22);
Image imgicon = new Image(getClass().getResourceAsStream("/Public/icon/dialoginform.png"));
ImageView icon = new ImageView(imgicon);
icon.setLayoutX(20);
icon.setLayoutY(60);
icon.setFitWidth(46);
icon.setFitHeight(50);
TextFlow DetailMSG = new TextFlow();
DetailMSG.setPrefHeight(120);
DetailMSG.setPrefWidth(400);
DetailMSG.setLayoutX(80);
DetailMSG.setLayoutY(55);
Text text1 = new Text("Bon de Sortie \n");
text1.setFont(Font.font("Arial", FontWeight.BOLD, 15));
text1.setFill(Color.web("#363a38"));
DetailMSG.getChildren().add(text1);
Text text2 = new Text("Êtes-vous sûr de vouloir enregistrer la bon de sortie");
text2.setFont(Font.font("Arial", FontWeight.NORMAL, 15));
text2.setFill(Color.web("#363a38"));
DetailMSG.getChildren().add(text2);
Text affecter = new Text("Affecté:");
affecter.setFont(Font.font("Arial", FontWeight.BOLD, 15));
affecter.setFill(Color.web("#363a38"));
affecter.setLayoutX(80);
affecter.setLayoutY(115);
Affecter.setFont(Font.font("Arial", FontWeight.NORMAL, 15));
Affecter.setFill(Color.web("#363a38"));
Affecter.setLayoutX(140);
Affecter.setLayoutY(115);
Text date = new Text("Date:");
date.setFont(Font.font("Arial", FontWeight.BOLD, 15));
date.setFill(Color.web("#363a38"));
date.setLayoutX(280);
date.setLayoutY(115);
Date.setFont(Font.font("Arial", FontWeight.NORMAL, 15));
Date.setFill(Color.web("#363a38"));
Date.setLayoutX(320);
Date.setLayoutY(115);
Text tranporteur = new Text("Tranporteur:");
tranporteur.setFont(Font.font("Arial", FontWeight.BOLD, 15));
tranporteur.setFill(Color.web("#363a38"));
tranporteur.setLayoutX(500);
tranporteur.setLayoutY(115);
Tranporteur.setFont(Font.font("Arial", FontWeight.NORMAL, 15));
Tranporteur.setFill(Color.web("#363a38"));
Tranporteur.setLayoutX(600);
Tranporteur.setLayoutY(115);
bouttonOK.setFont(Font.font ("Arial", FontWeight.BOLD, 14));
bouttonOK.setStyle("-fx-background-color:#4DAE4D; -fx-text-fill: white; -fx-border-radius: 5 5 5 5;");
Image coffeeImage = new Image(getClass().getResourceAsStream("/Public/icon/iconsave.png"));
ImageView buttonGraphic = new ImageView();
buttonGraphic.setImage(coffeeImage);
bouttonOK.setGraphic(buttonGraphic);
bouttonOK.setPrefWidth(140);
bouttonOK.setPrefHeight(35);
bouttonOK.setLayoutX(600);
bouttonOK.setLayoutY(500);
bouttonNo.setText("Annuler");
bouttonNo.setFont(Font.font ("System", FontWeight.BOLD, 12));
bouttonNo.setStyle("{-fx-background-color:#EFEFEF; -fx-border-color: #959595; -fx-border-radius: 5 5 5 5;} hover:{-fx-background-color:#E6E6E6;}");
bouttonNo.setPrefWidth(73);
bouttonNo.setPrefHeight(30);
bouttonNo.setLayoutX(500);
bouttonNo.setLayoutY(503);
bouttonNo.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
stackpane.setVisible(false);
}
});
group.getChildren().addAll(pa1, pa2, titre, icon, affecter, Affecter, date, Date, tranporteur, Tranporteur, ConfBonEnter, DetailMSG, bouttonOK, bouttonNo);
stackpane.setVisible(true);
stackpane.getChildren().add(Ap);
stackpane.getChildren().add(group);
return stackpane;
}
public void ShowDialg()
{
Node node = this.Setnotification();
StackPane Sp = new StackPane();
Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
Sp.getChildren().add(MyWindow.myParent);
Sp.getChildren().add(node);
Scene scene = new Scene(Sp);
Stage stage = MyWindow.myStage;
stage.setScene(scene);
stage.show();
}
}
@@ -0,0 +1,439 @@
package Controllers.Stock;
import Controllers.Traitement.ParametreSystem;
import Controllers.Traitement.contro;
import Models.Categorie.CategorieDB;
import Models.Categorie.CategorieListe;
import Models.Produit.ListeProduit;
import Models.Stock.StockDB;
import com.gluonhq.charm.glisten.control.ProgressBar;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.application.Platform;
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.print.PrinterJob;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
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.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.AnchorPane;
import javafx.util.Callback;
/**
* FXML Controller class
* @author Maher
*/
public class EtatStockCategorieController implements Initializable {
@FXML private AnchorPane AnchorPaneEtatStockCategorie;
@FXML private ProgressBar BarLoading;
@FXML private ComboBox ComboLocale;
@FXML private TextField TextFieldCategory;
@FXML private TextField TextFieldReference;
@FXML private TextField TextFieldDesignation;
@FXML private TableView<CategorieListe> TableViewCategorie ;
@FXML private TableColumn<CategorieListe, String> TabColNomCategorie;
@FXML private TableColumn<CategorieListe, String> TabColQuantiteCategorie;
@FXML private TableColumn<CategorieListe, Boolean> TabColDetailAction ;
@FXML private TableView<ListeProduit> TableViewProduit ;
@FXML private TableColumn<ListeProduit, String> TabColProduitReference;
@FXML private TableColumn<ListeProduit, String> TabColProduitDesignation;
@FXML private TableColumn<ListeProduit, String> TabColProduitQuantite;
@FXML private TableColumn<ListeProduit, Boolean> TabColProduitDetailAction ;
@FXML private Button BtnPrintAllProduit;
@FXML private Button BtnPrintAllCategory;
@FXML private Button BtnPrintSelectProduit;
String StringLocale = ParametreSystem.NomLocalPC;
String StrSeleCategory = "";
private Service<Void> ThreadEtatStockCategorie;
@Override
public void initialize(URL url, ResourceBundle rb) {
TabColNomCategorie.setCellValueFactory(new PropertyValueFactory<CategorieListe, String>("Nom"));
TabColQuantiteCategorie.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColQuantiteCategorie.getStyleClass().add("Center");
TabColQuantiteCategorie.setCellValueFactory(new PropertyValueFactory<CategorieListe, String>("Quantite"));
TabColDetailAction.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDetailAction.getStyleClass().add("Center");
TabColDetailAction.setCellFactory(new Callback<TableColumn<CategorieListe, Boolean>, TableCell<CategorieListe, Boolean>>() {
@Override
public TableCell<CategorieListe, Boolean> call(TableColumn<CategorieListe, Boolean> personBooleanTableColumn) {
return new ButtonCellCategorie();
}
});
//Liste des Locales
ComboLocale.getItems().addAll(new StockDB().getAllListLocal());
ComboLocale.getSelectionModel().select(ParametreSystem.NomLocalPC);
ComboLocale.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
StringLocale = ComboLocale.getValue().toString();
SearchCategorie(StringLocale, TextFieldCategory.getText());
TableViewProduit.setItems(null);
}
});
TextFieldCategory.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchCategorie(StringLocale, TextFieldCategory.getText());
}
}
});
SearchCategorie(StringLocale, "");
/******************* List des Produits******************************/
TabColProduitReference.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("reference"));
TabColProduitDesignation.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("designation"));
TabColProduitQuantite.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("quantite"));
TabColProduitQuantite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColProduitQuantite.getStyleClass().add("Center");
TabColProduitDetailAction.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColProduitDetailAction.getStyleClass().add("Center");
TabColProduitDetailAction.setCellFactory(new Callback<TableColumn<ListeProduit, Boolean>, TableCell<ListeProduit, Boolean>>() {
@Override
public TableCell<ListeProduit, Boolean> call(TableColumn<ListeProduit, Boolean> personBooleanTableColumn) {
return new ButtonCellProduit();
}
});
TextFieldReference.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchProduits("", TextFieldReference.getText(), "");
}
}
});
TextFieldDesignation.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
if (ke.getCode().equals(KeyCode.ENTER)) {
SearchProduits("", "", TextFieldDesignation.getText());
}
}
});
BtnPrintAllProduit.setOnAction(new EventHandler<ActionEvent>(){ //Action when the button is pressed
@Override
public void handle(ActionEvent t) {
PrintAllProduit();
}
});
BtnPrintAllCategory.setOnAction(new EventHandler<ActionEvent>(){ //Action when the button is pressed
@Override
public void handle(ActionEvent t) {
PrintAllCategorie();
}
});
BtnPrintSelectProduit.setOnAction(new EventHandler<ActionEvent>(){ //Action when the button is pressed
@Override
public void handle(ActionEvent t) {
PrintSelectProduit();
}
});
}
/**
* Print All Produit
*/
private void PrintAllProduit() {
try {
ObservableList<ListeProduit> listProduits = new StockDB().getProduitInStock(StringLocale, "", "", "");
PrinterJob job = PrinterJob.createPrinterJob();
int SizeListProduit = listProduits.size();
int total = SizeListProduit / 25 + 1 ;
int page = 0;
for (int i=0; i<SizeListProduit; i+=25){
ObservableList<ListeProduit> listProdTemp = FXCollections.observableArrayList();
for (int j=i; (j<(i+25)) && (j<SizeListProduit); j++){
listProdTemp.add(listProduits.get(j));
}
FXMLLoader fxmlLoaderAllProduit = new FXMLLoader(getClass().getResource("/Views/Stock/PrintAllProduit.fxml"));
final Node ParentFxmlAllProduit = (Node)fxmlLoaderAllProduit.load();
PrintAllProduitController PrintStockProduit = fxmlLoaderAllProduit.getController();
page++;
PrintStockProduit.setProduits(listProdTemp, StringLocale, page+"/"+total);
job.printPage(ParentFxmlAllProduit);
}
job.endJob();
} catch (IOException ex) {
System.err.println("FactureFrsGestionController PrintAllProduit ! \n"+ex.getMessage());
}
}
/**
* Print tous Categories
*/
private void PrintAllCategorie() {
try {
ObservableList<CategorieListe> listCategorie = new CategorieDB().GetCategorie(StringLocale, "");
PrinterJob jobCate = PrinterJob.createPrinterJob();
int SizeListCategory = listCategorie.size();
int total = SizeListCategory / 25 + 1 ;
int page = 0;
for (int i=0; i<SizeListCategory; i+=25){
ObservableList<CategorieListe> listCateTemp = FXCollections.observableArrayList();
for (int j=i; (j<(i+25)) && (j<SizeListCategory); j++){
listCateTemp.add(listCategorie.get(j));
}
FXMLLoader fxmlLoaderAllCategory = new FXMLLoader(getClass().getResource("/Views/Stock/PrintAllCategorie.fxml"));
final Node ParentFxmlAllCategory = (Node)fxmlLoaderAllCategory.load();
PrintAllCategorieController PrintStockAllCategory = fxmlLoaderAllCategory.getController();
page++;
PrintStockAllCategory.setCategories(listCateTemp, StringLocale, page+"/"+total);
jobCate.printPage(ParentFxmlAllCategory);
}
jobCate.endJob();
} catch (IOException ex) {
System.err.println("FactureFrsGestionController PrintAllProduit ! \n"+ex.getMessage());
}
}
/**
* Print Select Produit
*/
private void PrintSelectProduit() {
try {
ObservableList<ListeProduit> listSeleProduits = null;
contro clt = new contro();
int SizeListSeleProduit = 0;
int total = 0;
if(!clt.isStringNull(StrSeleCategory)){
listSeleProduits = new StockDB().getProduitInStock(StringLocale, StrSeleCategory, "", "");
SizeListSeleProduit = listSeleProduits.size();
total = SizeListSeleProduit / 25 + 1 ;
}
PrinterJob job = PrinterJob.createPrinterJob();
int page = 0;
for (int i=0; i<SizeListSeleProduit; i+=25){
ObservableList<ListeProduit> listProdTemp = FXCollections.observableArrayList();
for (int j=i; (j<(i+25)) && (j<SizeListSeleProduit); j++){
listProdTemp.add(listSeleProduits.get(j));
}
FXMLLoader fxmlLoaderAllProduit = new FXMLLoader(getClass().getResource("/Views/Stock/PrintSelProduit.fxml"));
final Node ParentFxmlAllProduit = (Node)fxmlLoaderAllProduit.load();
PrintSelProduitController PrintStockProduit = fxmlLoaderAllProduit.getController();
page++;
PrintStockProduit.setProduits(listProdTemp, StringLocale, StrSeleCategory, page+"/"+total);
job.printPage(ParentFxmlAllProduit);
}
job.endJob();
} catch (IOException ex) {
System.err.println("FactureFrsGestionController PrintAllProduit ! \n"+ex.getMessage());
}
}
/*private void SearchCategorie(final String Local, final String NomCategory){
BarLoading.setVisible(true);
TableViewCategorie.setItems(null);
// Create a Runnable
Runnable task = new Runnable(){
public void run(){
Platform.runLater(new Runnable(){
@Override
public void run(){
TableViewCategorie.setItems(new CategorieDB().GetCategorie(Local, NomCategory));
BarLoading.setVisible(false);
}
});
}
};
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
}*/
private void SearchCategorie(final String Local, final String NomCategory){
BarLoading.setVisible(true);
TableViewCategorie.setItems(null);
ThreadEtatStockCategorie = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
TableViewCategorie.setItems(new CategorieDB().GetCategorie(Local, NomCategory));
return null;
}
};
}
};
ThreadEtatStockCategorie.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
BarLoading.setVisible(false);
}
});
ThreadEtatStockCategorie.start();
}
private void SearchProduits(final String Categorie, final String Reference, final String Designation)
{
BarLoading.setVisible(true);
TableViewProduit.setItems(null);
ThreadEtatStockCategorie = new Service<Void>(){
@Override
protected Task<Void> createTask(){
return new Task<Void>(){
@Override
protected Void call() throws Exception{
TableViewProduit.setItems(new StockDB().getProduitInStock(StringLocale, Categorie, Reference, Designation));
return null;
}
};
}
};
ThreadEtatStockCategorie.setOnSucceeded(new EventHandler<WorkerStateEvent>(){
@Override
public void handle(WorkerStateEvent event){
BarLoading.setVisible(false);
}
});
ThreadEtatStockCategorie.start();
}
private class ButtonCellCategorie extends TableCell<CategorieListe, Boolean> {
final Button cellButton = new Button();
ButtonCellCategorie(){
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);
//Action when the button is pressed
cellButton.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
CategorieListe ListCategorie = (CategorieListe)getTableRow().getItem();
StrSeleCategory = ListCategorie.getNom();
SearchProduits(ListCategorie.getNom(), "", "");
}
});
}
//Display button if the row is not empty
@Override
protected void updateItem(Boolean t, boolean empty) {
if(!empty){
setGraphic(cellButton);
} else {
setGraphic(null);
}
}
}
private class ButtonCellProduit extends TableCell<ListeProduit, Boolean> {
final Button cellButton = new Button();
ButtonCellProduit(){
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);
//Action when the button is pressed
cellButton.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
ListeProduit produit = (ListeProduit)getTableRow().getItem();
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/Views/Stock/MouvementStock.fxml"));
Parent NodeMouvementStock = (Parent)fxmlLoader.load();
MouvementStockController MouvementStock = fxmlLoader.getController();
MouvementStock.SetData(produit.getReference(), produit.getDesignation(), StringLocale);
AnchorPaneEtatStockCategorie.getChildren().clear();
AnchorPaneEtatStockCategorie.getChildren().add(NodeMouvementStock);
} catch (Exception ex) {
System.err.println(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);
}
}
}
}
@@ -0,0 +1,65 @@
/*
* 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.Stock;
import javafx.beans.property.SimpleStringProperty;
/**
*
* @author PC-Maher
*/
public class ListProduitBon {
private final SimpleStringProperty reference;
private final SimpleStringProperty designaton;
private final SimpleStringProperty marque;
private final SimpleStringProperty categorie;
private final SimpleStringProperty prixttc;
private final SimpleStringProperty quantite;
private final SimpleStringProperty tva;
public ListProduitBon(String reference, String designaton, String marque, String categorie, String prix, String qte,String tva) {
this.reference = new SimpleStringProperty(reference);
this.designaton = new SimpleStringProperty(designaton);
this.marque = new SimpleStringProperty(marque);
this.categorie = new SimpleStringProperty(categorie);
this.prixttc = new SimpleStringProperty(prix);
this.quantite = new SimpleStringProperty(qte);
this.tva = new SimpleStringProperty(tva);
}
public String getReference() {
return reference.get();
}
public String getDesignaton() {
return designaton.get();
}
public String getTva() {
return tva.get();
}
public String getMarque() {
return marque.get();
}
public String getCategorie() {
return categorie.get();
}
public String getPrixttc() {
return prixttc.get();
}
public String getQuantite() {
return quantite.get();
}
public void setQuantite(String fQte) {
quantite.set(fQte);
}
}
@@ -0,0 +1,61 @@
/*
* 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.Stock;
import javafx.beans.property.SimpleStringProperty;
/**
*
* @author SYSTEM
*/
public class ListProduitRech {
private final SimpleStringProperty reference;
private final SimpleStringProperty designaton;
private final SimpleStringProperty marque;
private final SimpleStringProperty categorie;
private final SimpleStringProperty prixttc;
private final SimpleStringProperty TVA;
private final SimpleStringProperty quantite;
public ListProduitRech(String reference, String designaton, String marque, String categorie, String prix, String tva, String quantite) {
this.reference = new SimpleStringProperty(reference);
this.designaton = new SimpleStringProperty(designaton);
this.marque = new SimpleStringProperty(marque);
this.categorie = new SimpleStringProperty(categorie);
this.prixttc = new SimpleStringProperty(prix);
this.TVA = new SimpleStringProperty(tva);
this.quantite = new SimpleStringProperty(quantite);
}
public String getReference() {
return reference.get();
}
public String getDesignaton() {
return designaton.get();
}
public String getMarque() {
return marque.get();
}
public String getCategorie() {
return categorie.get();
}
public String getPrixttc() {
return prixttc.get();
}
public String getTVA() {
return TVA.get();
}
public String getQuantite() {
return quantite.get();
}
}
@@ -0,0 +1,361 @@
/*
* 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.Stock;
import Models.Stock.ListeMouvement;
import Models.Stock.StockDB;
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.application.Platform;
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.print.JobSettings;
import javafx.print.PageRange;
import javafx.print.PrinterJob;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
/**
* FXML Controller class
*
* @author Maher
*/
public class MouvementStockController implements Initializable {
@FXML private ProgressIndicator ProgressLoading;
@FXML private Text TextReference ;
@FXML private Text TextDesignation ;
@FXML private TableView<ListeMouvement> TableViewMouvement ;
@FXML private TableColumn<ListeMouvement, String> TabColCode;
@FXML private TableColumn<ListeMouvement, String> TabColType;
@FXML private TableColumn<ListeMouvement, String> TabColMouvement;
@FXML private TableColumn<ListeMouvement, String> TabColQuantite;
@FXML private TableColumn<ListeMouvement, String> TabColDate;
@FXML private DatePicker DatePickerDebut;
@FXML private Button BtnPrintMouvement;
@FXML private Button BtnExportPDFMouvement;
@FXML private StackPane ListerPages;
@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 count ;
@FXML private ChoiceBox NbrLigne ;
ObservableList cursors = FXCollections.observableArrayList("10","15","20");
private Integer nbrligne = 10 ;
private Integer totalcount ;
private Integer nbrpage = 0;
private Integer actuellepage;
Integer position ;
private String StringLocal;
private String StringReference;
private String StringDateDebut = "";
@Override
public void initialize(URL url, ResourceBundle rb) {
NbrLigne.setItems(cursors);
NbrLigne.getSelectionModel().selectFirst();
TabColCode.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColCode.getStyleClass().add("Center");
TabColCode.setCellValueFactory(new PropertyValueFactory<ListeMouvement, String>("Code"));
TabColType.setCellValueFactory(new PropertyValueFactory<ListeMouvement, String>("Type"));
TabColMouvement.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColMouvement.getStyleClass().add("Center");
TabColMouvement.setCellValueFactory(new PropertyValueFactory<ListeMouvement, String>("Mouvement"));
TabColQuantite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColQuantite.getStyleClass().add("Center");
TabColQuantite.setCellValueFactory(new PropertyValueFactory<ListeMouvement, String>("Quantite"));
TabColDate.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDate.getStyleClass().add("Center");
TabColDate.setCellValueFactory(new PropertyValueFactory<ListeMouvement, String>("Date"));
DatePickerDebut.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
try{
StringDateDebut = DatePickerDebut.getValue().toString();
MouvementStockGestion("Models.Stock.StockDB", "getDataStockDetail", "getNbrStockDetail", StringDateDebut);
}catch(Exception ex){}
}
});
DatePickerDebut.setOnKeyReleased(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent ke) {
try{
StringDateDebut = DatePickerDebut.getConverter().fromString(DatePickerDebut.getEditor().getText()).toString();
MouvementStockGestion("Models.Stock.StockDB", "getDataStockDetail", "getNbrStockDetail", StringDateDebut);
}catch(Exception ex){}
}
});
BtnPrintMouvement.setOnAction(new EventHandler<ActionEvent>(){ //Action when the button is pressed
@Override
public void handle(ActionEvent t) {
PrintMouvement();
}
});
BtnExportPDFMouvement.setOnAction(new EventHandler<ActionEvent>(){ //Action when the button is pressed
@Override
public void handle(ActionEvent t) {
ExportPDFMouvement();
}
});
}
public void SetData(String Reference, String Designation, String Local) {
TextReference.setText(Reference);
TextDesignation.setText(Designation);
StringLocal = Local;
StringReference = Reference;
MouvementStockGestion("Models.Stock.StockDB", "getDataStockDetail", "getNbrStockDetail", "");
}
/**
* Print Mouvement
*/
private void PrintMouvement() {
try {
ObservableList<ListeMouvement> listMouvement = new StockDB().getDataStockDetail(StringLocal, StringReference, "", null, null);
int SizelistMouvement = listMouvement.size();
int total = SizelistMouvement / 25 + 1 ;
int page = 0;
PrinterJob jobPrint = PrinterJob.createPrinterJob();
jobPrint.getJobSettings().setPageRanges(new PageRange(1, total));
if (jobPrint.showPrintDialog(null)) {
JobSettings jsPrint = jobPrint.getJobSettings();
for (int i=0; i<SizelistMouvement; i+=25){
ObservableList<ListeMouvement> listMouvTemp = FXCollections.observableArrayList();
for (int j=i; (j<(i+25)) && (j<SizelistMouvement); j++){
listMouvTemp.add(listMouvement.get(j));
}
FXMLLoader fxmlLoaderMouvement = new FXMLLoader(getClass().getResource("/Views/Stock/PrintMouvementProduit.fxml"));
final Node ParentFxmlMouvement = (Node)fxmlLoaderMouvement.load();
PrintMouvementProduitController PrintMouvementProd = fxmlLoaderMouvement.getController();
page++;
PrintMouvementProd.setMouvements(listMouvTemp, StringLocal, StringDateDebut, StringReference, TextDesignation.getText(), page+"/"+total);
jobPrint.printPage(ParentFxmlMouvement);
}
jobPrint.endJob();
}
} catch (IOException ex) {
System.err.println("FactureFrsGestionController PrintAllProduit ! \n"+ex.getMessage());
}
}
/**
* Export PDF Mouvement
*/
private void ExportPDFMouvement() {
try {
ObservableList<ListeMouvement> listMouvement = new StockDB().getDataStockDetail(StringLocal, StringReference, "", null, null);
PrinterJob jobExportPDF = PrinterJob.createPrinterJob();
int SizelistMouvement = listMouvement.size();
int total = SizelistMouvement / 25 + 1 ;
int page = 0;
for (int i=0; i<SizelistMouvement; i+=25){
ObservableList<ListeMouvement> listMouvTemp = FXCollections.observableArrayList();
for (int j=i; (j<(i+25)) && (j<SizelistMouvement); j++){
listMouvTemp.add(listMouvement.get(j));
}
FXMLLoader fxmlLoaderMouvement = new FXMLLoader(getClass().getResource("/Views/Stock/PrintMouvementProduit.fxml"));
final Node ParentFxmlMouvement = (Node)fxmlLoaderMouvement.load();
PrintMouvementProduitController PrintMouvementProd = fxmlLoaderMouvement.getController();
page++;
PrintMouvementProd.setMouvements(listMouvTemp, StringLocal, StringDateDebut, StringReference, TextDesignation.getText(), page+"/"+total);
jobExportPDF.printPage(ParentFxmlMouvement);
}
jobExportPDF.endJob();
} catch (IOException ex) {
System.err.println("FactureFrsGestionController PrintAllProduit ! \n"+ex.getMessage());
}
}
/***************************************************************************** *
* *
* Methode last Next TableView client Entreprise *
* *
******************************************************************************/
//une methode qui permet modifier le nom et methode d'une classe
private void setFunctiongetDetailStock(final String NomClass, final String NomMethode, final String DateDebut, final Integer Position, final Integer Nbrligne){
try {
ProgressLoading.setVisible(true);
TableViewMouvement.setVisible(false);
// Create a Runnable
Runnable task = new Runnable(){
public void run(){
Platform.runLater(new Runnable(){
@Override
public void run(){
try {
Class c = Class.forName(NomClass);
Object o = c.newInstance();
Class[] paramTypes = {String.class, String.class, String.class, Integer.class, Integer.class};
Method m = c.getDeclaredMethod(NomMethode, paramTypes);
TableViewMouvement.setItems((ObservableList<ListeMouvement>) (m.invoke(o, StringLocal, StringReference, DateDebut, Position, Nbrligne)));
ProgressLoading.setVisible(false);
TableViewMouvement.setVisible(true);
} catch (Exception ex) {
System.err.println("Erreur SQL ! \n"+ex.getMessage());
}
}
});
}
};
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(ex.getMessage());
}
}
private void MouvementStockGestion(final String NomClass, final String NomMethode, String NomMethodeCount, final String DateDebut){
try {
Class c = Class.forName(NomClass);
Object o = c.newInstance();
Class[] paramTypes = {String.class, String.class, String.class};
Method m = c.getDeclaredMethod(NomMethodeCount, paramTypes);
//System.out.println("method = " + m.toString());
String nbr = (String) m.invoke(o, StringLocal, StringReference, DateDebut);
count.setText(nbr);
totalcount = Integer.parseInt(nbr) ;
} catch (Exception ex) {
System.err.println("Exception MouvementStockGestion "+ex.getMessage());
}
ActuellePage.setText("1");
actuellepage=1;
position = 0;
setFunctiongetDetailStock(NomClass, NomMethode, DateDebut, position, nbrligne);
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;
setFunctiongetDetailStock(NomClass, NomMethode, DateDebut, 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;
setFunctiongetDetailStock(NomClass, NomMethode, DateDebut, position, nbrligne);
actuellepage=actuellepage+1 ;
ActuellePage.setText(Integer.toString(actuellepage));
//System.out.println("position "+position+" "+"nbrligne "+nbrligne);
}
}
});
//last page
lastgroupe.setOnMousePressed(new EventHandler<MouseEvent>(){
@Override
public void handle(MouseEvent event) {
if(actuellepage>1){
position=position-nbrligne;
setFunctiongetDetailStock(NomClass, NomMethode, DateDebut, 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;
setFunctiongetDetailStock(NomClass, NomMethode, DateDebut, position, nbrligne);
actuellepage=actuellepage+3 ;
ActuellePage.setText(Integer.toString(actuellepage));
//System.out.println("position "+position+" "+"nbrligne "+nbrligne);
}
}
});
//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;
setFunctiongetDetailStock(NomClass, NomMethode, DateDebut, position, nbrligne);
actuellepage=actuellepage-3 ;
ActuellePage.setText(Integer.toString(actuellepage));
}
}
});
}
}
@@ -0,0 +1,48 @@
package Controllers.Stock;
import Controllers.Traitement.Adaptateur;
import Models.Categorie.CategorieListe;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.text.Text;
/**
* FXML Controller class
* @author Maher
*/
public class PrintAllCategorieController implements Initializable {
@FXML private Text TextLocale;
@FXML private Text TextDateCreate;
@FXML private Text TextPagination;
@FXML private TableView<CategorieListe> TableViewCategorie ;
@FXML private TableColumn<CategorieListe, String> TabColCategorie;
@FXML private TableColumn<CategorieListe, String> TabColQuantite;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
TabColCategorie.setCellValueFactory(new PropertyValueFactory<CategorieListe, String>("Nom"));
TabColQuantite.setCellValueFactory(new PropertyValueFactory<CategorieListe, String>("Quantite"));
TabColQuantite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColQuantite.getStyleClass().add("Center");
}
public void setCategories(ObservableList<CategorieListe> listCateg, String Local, String Pagination){
TableViewCategorie.setItems(null);
TableViewCategorie.setItems(listCateg);
TextLocale.setText(Local);
TextPagination.setText(Pagination);
TextDateCreate.setText(Adaptateur.getDefaultCurrentDate("dd/MM/yyyy HH:mm"));
}
}
@@ -0,0 +1,58 @@
/*
* 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.Stock;
import Controllers.Traitement.Adaptateur;
import Models.Produit.ListeProduit;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.text.Text;
/**
* FXML Controller class
*
* @author Maher
*/
public class PrintAllProduitController implements Initializable {
@FXML private Text TextLocale;
@FXML private Text TextDateCreate;
@FXML private Text TextPagination;
@FXML private TableView<ListeProduit> TableViewProduit ;
@FXML private TableColumn<ListeProduit, String> TabColProduitReference;
@FXML private TableColumn<ListeProduit, String> TabColProduitDesignation;
@FXML private TableColumn<ListeProduit, String> TabColProduitQuantite;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
TabColProduitReference.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("reference"));
TabColProduitDesignation.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("designation"));
TabColProduitQuantite.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("quantite"));
TabColProduitQuantite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColProduitQuantite.getStyleClass().add("Center");
}
public void setProduits(ObservableList<ListeProduit> listProduits, String Local, String Pagination){
TableViewProduit.setItems(null);
TableViewProduit.setItems(listProduits);
TextLocale.setText(Local);
TextPagination.setText(Pagination);
TextDateCreate.setText(Adaptateur.getDefaultCurrentDate("dd/MM/yyyy HH:mm"));
}
}
@@ -0,0 +1,73 @@
package Controllers.Stock;
import Models.Stock.ListeMouvement;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.text.Text;
/**
* FXML Controller class
* @author Maher Ben Tili
*/
public class PrintMouvementProduitController implements Initializable {
@FXML private Text TextLocale;
@FXML private Text TextDateDebut;
@FXML private Text TextReference ;
@FXML private Text TextDesignation ;
@FXML private Text TextPagination;
@FXML private TableView<ListeMouvement> TableViewMouvement ;
@FXML private TableColumn<ListeMouvement, String> TabColCode;
@FXML private TableColumn<ListeMouvement, String> TabColType;
@FXML private TableColumn<ListeMouvement, String> TabColMouvement;
@FXML private TableColumn<ListeMouvement, String> TabColQuantite;
@FXML private TableColumn<ListeMouvement, String> TabColDate;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
TabColCode.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColCode.getStyleClass().add("Center");
TabColCode.setCellValueFactory(new PropertyValueFactory<ListeMouvement, String>("Code"));
TabColType.setCellValueFactory(new PropertyValueFactory<ListeMouvement, String>("Type"));
TabColMouvement.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColMouvement.getStyleClass().add("Center");
TabColMouvement.setCellValueFactory(new PropertyValueFactory<ListeMouvement, String>("Mouvement"));
TabColQuantite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColQuantite.getStyleClass().add("Center");
TabColQuantite.setCellValueFactory(new PropertyValueFactory<ListeMouvement, String>("Quantite"));
TabColDate.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColDate.getStyleClass().add("Center");
TabColDate.setCellValueFactory(new PropertyValueFactory<ListeMouvement, String>("Date"));
}
public void setMouvements(ObservableList<ListeMouvement> listMouvements, String Local, String DateDebut, String Reference, String Designation, String Pagination){
TableViewMouvement.setItems(null);
TableViewMouvement.setItems(listMouvements);
TextLocale.setText(Local);
TextDateDebut.setText(DateDebut);
TextReference.setText(Reference);
TextDesignation.setText(Designation);
TextPagination.setText(Pagination);
}
}
@@ -0,0 +1,57 @@
/*
* 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.Stock;
import Controllers.Traitement.Adaptateur;
import Models.Produit.ListeProduit;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.text.Text;
/**
* FXML Controller class
* @author Maher
*/
public class PrintSelProduitController implements Initializable {
@FXML private Text TextLocale;
@FXML private Text TextDateCreate;
@FXML private Text TextCategory;
@FXML private Text TextPagination;
@FXML private TableView<ListeProduit> TableViewProduit ;
@FXML private TableColumn<ListeProduit, String> TabColProduitReference;
@FXML private TableColumn<ListeProduit, String> TabColProduitDesignation;
@FXML private TableColumn<ListeProduit, String> TabColProduitQuantite;
/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
TabColProduitReference.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("reference"));
TabColProduitDesignation.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("designation"));
TabColProduitQuantite.setCellValueFactory(new PropertyValueFactory<ListeProduit, String>("quantite"));
TabColProduitQuantite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
TabColProduitQuantite.getStyleClass().add("Center");
}
public void setProduits(ObservableList<ListeProduit> listProduits, String Local, String Category, String Pagination){
TableViewProduit.setItems(null);
TableViewProduit.setItems(listProduits);
TextLocale.setText(Local);
TextCategory.setText(Category);
TextPagination.setText(Pagination);
TextDateCreate.setText(Adaptateur.getDefaultCurrentDate("dd/MM/yyyy HH:mm"));
}
}

Some files were not shown because too many files have changed in this diff Show More