Package sn.unitech.stock.bean

Source Code of sn.unitech.stock.bean.ClientBean$CMessages

package sn.unitech.stock.bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ActionEvent;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;

import sn.unitech.common.dao.ReadProperties;
import sn.unitech.stock.entity.Client;
import sn.unitech.stock.entity.SysAdherent;
import sn.unitech.stock.entity.SysPiece;
import sn.unitech.stock.entity.SysTypcli;
import sn.unitech.stock.metier.ClientM;
import sn.unitech.stock.metier.SysPieceM;
import sn.unitech.stock.metier.iface.IClientM;
import sn.unitech.stock.metier.iface.ISysPieceM;

@ManagedBean
@ViewScoped
public class ClientBean implements Serializable{
  private static final long serialVersionUID = -5810158795333135968L;
  private ReadProperties readProperties=ReadProperties.getReadProperties();
  private IClientM<Client> clientM= new ClientM();
  private ISysPieceM<SysPiece> iSysPieceM=new SysPieceM<SysPiece>();
  private  Client client=new Client();
  private CMessages cmessages =new CMessages();
  private Cproperties cproperties=new Cproperties();
  private CItems citems=new CItems();
 
  public ParamsUser getParamsUser(){
    return   ((ParamsUser)ToolsBean.getToolsBean().getAttribute(ToolsBean.idParamUser));
  }
 
  public void clickPersitClient(ActionEvent e){
    ParamsUser paramUser=getParamsUser();
    SysAdherent adherent=paramUser.getAdherent();
    this.client.setSysAdherent(adherent);
    this.client.setSysPiece(new SysPiece(this.cproperties.getTypePiece()));
    this.client.setSysTypcli(new SysTypcli(this.cproperties.getTypeClient(),adherent.getIdAdherent()));
    if(clientM.persistClient(client)){
      this.cmessages.setSaveMessage(ToolsBean.getToolsBean().getBundleMessage("msgSucces"));
      this.client=new Client();
    }else{
      this.cmessages.setSaveMessage(ToolsBean.getToolsBean().getBundleMessage("msgEchec"));
    }
  }
 
  public void clickPrepareUpdateClient(ActionEvent e){
    this.client=this.citems.dataListClient.getRowData();
    this.cmessages.saveMessage="";
  }
 
  public void clickCancelClient(ActionEvent e){
    this.client=new Client();
    this.cmessages.saveMessage="";
  }
 
  public Client getClient() {
    return client;
  }
  public void setClient(Client client) {
    this.client = client;
  }

  
  public CMessages getCmessages() {
    return cmessages;
  }
  public void setCmessages(CMessages cmessages) {
    this.cmessages = cmessages;
  }
  public Cproperties getCproperties() {
    return cproperties;
  }
  public void setCproperties(Cproperties cproperties) {
    this.cproperties = cproperties;
  }
  public CItems getCitems() {
    return citems;
  }
  public void setCitems(CItems citems) {
    this.citems = citems;
  }

  public class AllRefs{
   
  }
    public class CMessages{
    public String saveMessage;
    public String getSaveMessage() {
      return saveMessage;
    }

    public void setSaveMessage(String saveMessage) {
      this.saveMessage = saveMessage;
    }
  }
    public class Cproperties implements Serializable{
    private static final long serialVersionUID = 6754029429673393815L;
    public Integer typeClient;
      public Integer typePiece;
    public Integer getTypeClient() {
      return typeClient;
    }
    public void setTypeClient(Integer typeClient) {
      this.typeClient = typeClient;
    }
    public Integer getTypePiece() {
      return typePiece;
    }
    public void setTypePiece(Integer typePiece) {
      this.typePiece = typePiece;
    }
    }
  public class CItems extends Cproperties implements Serializable{
    private static final long serialVersionUID = 2712784365909846245L;
    public Map<String, Integer>itemsTypeClient;
    public Map<String, Integer>itemsAllTypeService;
    public Map<String, Integer>itemsTypePiece;
        DataModel<Client>   dataListClient=new ListDataModel<Client>(new ArrayList<Client>());
   
       
       
    public Map<String, Integer> getItemsAllTypeService() {
      Map<Integer,String> param =new HashMap<Integer,String>();
      param.put(0,getParamsUser().adherent.getIdAdherent());
      param.put(1,"True");
      return itemsAllTypeService==null?clientM.findAllTypeClient(readProperties.read("Client.jpqlTypeClient"),param):itemsAllTypeService;
    }

    public void setItemsAllTypeService(Map<String, Integer> itemsAllTypeService) {
      this.itemsAllTypeService = itemsAllTypeService;
    }

    public Map<String, Integer> getItemsTypeClient() {
      Map<Integer,String> param =new HashMap<Integer,String>();
      param.put(0,getParamsUser().adherent.getIdAdherent());
      param.put(1,"False");
      return itemsTypeClient==null?clientM.findAllTypeClient(readProperties.read("Client.jpqlTypeClient"),param):itemsTypeClient;
    }

    public void setItemsTypeClient(Map<String, Integer> itemsTypeClient) {
      this.itemsTypeClient = itemsTypeClient;
    }

    public Map<String, Integer> getItemsTypePiece() {
      return itemsTypePiece==null?iSysPieceM.findAllTypePiece(readProperties.read("Piece.jpqlAllTypePiece")):itemsTypePiece;
    }

    public void setItemsTypePiece(Map<String, Integer> itemsTypePiece) {
      this.itemsTypePiece = itemsTypePiece;
    }

    public DataModel<Client> getDataListClient() {
      Map<Integer,String> param=new HashMap<Integer,String>();
      param.put(0,getParamsUser().adherent.getIdAdherent());
      dataListClient.setWrappedData((List<Client>) clientM.listClient(readProperties.read("Client.jpqlListClient"), param));
      return dataListClient;
    }
    public void setDataListClient(DataModel<Client> dataListClient) {
      this.dataListClient = dataListClient;
    }
   
   
  }
}
 
TOP

Related Classes of sn.unitech.stock.bean.ClientBean$CMessages

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.