Package beanStaff

Source Code of beanStaff.viewInfoMember

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package beanStaff;

import Business.business;
import EntityBean.Users;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import helper.messages;
import helper.operationSession;
import java.util.Date;
import java.util.List;
import javax.faces.application.FacesMessage;

/**
*
* @author Huynh Kim Toan
*/
@ManagedBean(name = "viewInfo")
@RequestScoped
public final class viewInfoMember {

    private String UserName;
    private Users login = new Users();
    private String pass;
    private String fullname;
    private String gender;
    private String city;
    private String address;
    private int cardnumber;
    private int telephone;
    private String email;
     private  String variableEmail;
    private Date birth;
   
    public viewInfoMember() {
    }

    public void viewInfoMember() {
        if (UserName.length() == 0) {
            messages.taoTB(FacesMessage.SEVERITY_ERROR, "User not null", "Error");
        } else {
            this.login = new business().getLoginFacade().getUserID(UserName);
            if (login == null) {
                messages.taoTB(FacesMessage.SEVERITY_ERROR, "User not Exist", "Error");
            } else {
                if (login.getRoles().equals("staff") || login.getRoles().equals("admin")) {
                    messages.taoTB(FacesMessage.SEVERITY_ERROR, "Unable to see the profile of this account", "Error");
                } else {
                    int userID = login.getUserID();
                }
            }
        }
    }
    
    public List<Users> getLists() {
        return new business().getLoginFacade().findAll();
    }
   
    public String viewDetails(int user) {
        operationSession.ganGiaTriChoSession("userid", user);
        setLogin(new business().getLoginFacade().find(user));
       
        UserName = this.login.getUsername();
        fullname = this.login.getFullname();
        birth = this.login.getDayofbirth();
        gender = this.login.getGender();
        city = this.login.getCity();
        cardnumber = this.login.getCardnumber();
        telephone = this.login.getTelephone();
        email = this.login.getEmail();
        pass = this.login.getPassword();
        address = this.login.getAddress();
      
       return "/admin/ViewInfomation";
       
    }
    public void updateInformation() {
        this.login = new business().getLoginFacade().find(operationSession.layGTSession("userid"));
        int userID = login.getUserID();
        if(fullname.length() < 6)
        {
              messages.taoTB(FacesMessage.SEVERITY_ERROR, "Full Name must be greater than 6 characters", "error");
        }else if(city.length() < 6)
        {
            messages.taoTB(FacesMessage.SEVERITY_ERROR, "City must be greater than 6 characters", "error");
        }else if(address.length()<6)
        {
              messages.taoTB(FacesMessage.SEVERITY_ERROR, "Address must be greater than 6 characters", "error");
        }else if(email.length()<6)
        {
            messages.taoTB(FacesMessage.SEVERITY_ERROR, "Email must be greater than 6 characters !", "error");
        }else{
        if(login != null)
        {
            String mail=email+variableEmail;
        login.setFullname(fullname);
        login.setDayofbirth(birth);
        login.setGender(gender);
        login.setCity(city);
        login.setAddress(address);
        login.setCardnumber(cardnumber);
        login.setTelephone(telephone);
        login.setEmail(mail);
            new business().getLoginFacade().edit(login);
              messages.taoTB(FacesMessage.SEVERITY_INFO, "Update Successfull !", "Successfull");
        }
      }
    }
    public Users getLogin() {
        return login;
    }

    /**
     * @param login the login to set
     */
    public void setLogin(Users login) {
        this.login = login;
    }

    public String getPass() {
        return pass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

    public String getFullname() {
        return fullname;
    }

    public void setFullname(String fullname) {
        this.fullname = fullname;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public int getCardnumber() {
        return cardnumber;
    }

    public void setCardnumber(int cardnumber) {
        this.cardnumber = cardnumber;
    }

    public int getTelephone() {
        return telephone;
    }

    public void setTelephone(int telephone) {
        this.telephone = telephone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getVariableEmail() {
        return variableEmail;
    }

    public void setVariableEmail(String variableEmail) {
        this.variableEmail = variableEmail;
    }

    public Date getBirth() {
        return birth;
    }

    public void setBirth(Date birth) {
        this.birth = birth;
    }


 
    public String getUserName() {
        return UserName = (String) operationSession.layGTSession("user");
    }

    public void setUserName(String UserName) {
        this.UserName = UserName;
    }
}
TOP

Related Classes of beanStaff.viewInfoMember

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.