/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package beanMember;
import Business.business;
import EntityBean.Users;
import helper.messages;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import helper.operationSession;
import java.util.Date;
import javax.faces.application.FacesMessage;
/**
*
* @author Huynh Kim Toan
*/
@ManagedBean(name = "ViewINFO")
@RequestScoped
public final class viewInfo {
private Users login = new Users();
private String fullname, gender, city, address, email,variableEmail;
private int card, telephone;
private Date birth;
private String username;
public viewInfo() {
xuly();
}
public void xuly() {
this.login = new business().getLoginFacade().getUserID(getUsername());
fullname = login.getFullname();
gender = login.getGender();
city = login.getCity();
address = login.getAddress();
email = login.getEmail();
card = login.getCardnumber();
telephone = login.getTelephone();
birth = login.getDayofbirth();
}
public void updateInformation() {
this.login = new business().getLoginFacade().getUserID(getUsername());
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(card);
login.setTelephone(telephone);
login.setEmail(mail);
new business().getLoginFacade().edit(login);
messages.taoTB(FacesMessage.SEVERITY_INFO, "Update Successfull !", "Successfull");
}
}
}
public String getUsername() {
return username = (String) operationSession.layGTSession("user");
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public Date getBirth() {
return birth;
}
public void setBirth(Date birth) {
this.birth = birth;
}
public int getCard() {
return card;
}
public void setCard(int card) {
this.card = card;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
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 int getTelephone() {
return telephone;
}
public String getVariableEmail() {
return variableEmail;
}
public void setVariableEmail(String variableEmail) {
this.variableEmail = variableEmail;
}
public void setTelephone(int telephone) {
this.telephone = telephone;
}
/**
* @return the login
*/
public Users getLogin() {
return login;
}
public void setLogin(Users login) {
this.login = login;
}
}