📄 user.java
字号:
//User.java
package AccountsPack;
import java.sql.Date;
import java.sql.Time;
import DataCenterPackage.DataCenter;
import DataCenterPackage.OrderCondition;
import DataCenterPackage.Condition;
import OrderPack.Order;
import RoomPackage.Room;
public class User
{
public final static int GRP_CUSTOMER = 0;
public final static int GRP_OPERATOR = 1;
public final static int GRP_ADMINISTRATOR = 2;
private String _userName;
private String _password;
private String _lastLoginIP;
private String _address;
private String _email;
private String _mobile;
private String _phone;
private String _name;
private Date _birthday;
private String _description;
private String _habit;
private boolean _vip;
private int _point;
private int _type;
private boolean _sex;
private String _fromCity;
private String _ICQ;
private String _fax;
private int _identity;
private String _card;
private DataCenter _dataCenter;
public User()
{
_dataCenter = DataCenter.get_INSTANCE();
}
public String get_userName(){return _userName;}
public void set_userName(String a_userName){_userName = a_userName;}
public int get_type(){return _type;}
public void set_type(int type){_type = type;}
public String get_password(){return _password; }
public void set_password(String a_password) {_password = a_password;}
public String get_lastLoginIP()
{
return _lastLoginIP;
}
public void set_lastLoginIP(String a_lastLoginIP)
{
_lastLoginIP = a_lastLoginIP;
}
public String get_address()
{
return _address;
}
public void set_address(String a_address)
{
_address = a_address;
}
public String get_email()
{
return _email;
}
public void set_email(String a_email)
{
_email = a_email;
}
public String get_mobile()
{
return _mobile;
}
public void set_mobile(String a_mobile)
{
_mobile = a_mobile;
}
public String get_phone()
{
return _phone;
}
public void set_phone(String a_phone)
{
_phone = a_phone;
}
public String get_name()
{
return _name;
}
public void set_name(String a_name)
{
_name = a_name;
}
public Date get_birthday()
{
return _birthday;
}
public void set_birthday(Date a_birthday)
{
_birthday = a_birthday;
}
public String get_description()
{
return _description;
}
public void set_description(String a_description)
{
_description = a_description;
}
public String get_habit()
{
return _habit;
}
public void set_habit(String a_habit)
{
_habit = a_habit;
}
public boolean get_vip()
{
return _vip;
}
public void set_vip(boolean a_vip)
{
_vip = a_vip;
}
public int get_point()
{
return _point;
}
public void set_point(int a_point)
{
_point = a_point;
}
public boolean get_sex()
{
return _sex;
}
public void set_sex(boolean a_sex)
{
_sex = a_sex;
}
public String get_fromCity()
{
return _fromCity;
}
public void set_fromCity(String a_fromCity)
{
_fromCity = a_fromCity;
}
public String get_ICQ()
{
return _ICQ;
}
public void set_ICQ(String a_ICQ)
{
_ICQ = a_ICQ;
}
public String get_fax()
{
return _fax;
}
public void set_fax(String a_fax)
{
_fax = a_fax;
}
public int get_identity()
{
return _identity;
}
public void set_identity(int a_identity)
{
_identity = a_identity;
}
public DataCenter get_dataCenter()
{
return _dataCenter;
}
public void set_dataCenter(DataCenter a_dataCenter)
{
_dataCenter = a_dataCenter;
}
public String get_card()
{
return _card;
}
public void set_card(String a_card)
{
_card = a_card;
}
public boolean Login()
{
if(_userName ==null && _password ==null)
return false;
User tmpUser = _dataCenter.QueryUser(_userName);
if(tmpUser == null)
return false;
if ( tmpUser.get_password().equals(_password) )
{
Copy(tmpUser);
return true;
}
return false;
}
public boolean Logout()
{
_userName = null;
return true;
}
public void GetInfo()
{
User tmpUser = _dataCenter.QueryUser(_userName);
Copy(tmpUser);
}
public void Copy(User user)
{
_address = user.get_address();
_birthday = user.get_birthday();
_card = user.get_card();
_description = user.get_description();
_email = user.get_email();
_fax = user.get_fax();
_fromCity = user.get_fromCity();
_habit = user.get_habit();
_ICQ = user.get_ICQ();
_identity = user.get_identity();
_lastLoginIP = user.get_lastLoginIP();
_mobile = user.get_mobile();
_name = user.get_name();
_password = user.get_password();
_phone = user.get_phone();
_point = user.get_point();
_sex = user.get_sex();
_type = user.get_type();
_userName = user.get_userName();
_vip = user.get_vip();
}
public boolean ModifyInfo()
{
if(null == _userName)
return false;
return _dataCenter.ModifyUser(this)>0?true:false;
}
public Room [] SearchRoom(String condition)
{
return _dataCenter.SearchRooms(condition);
}
public Room [] SearchRoom(Condition []conditions)
{
return _dataCenter.SearchRooms(conditions);
}
public Room QueryRoom(int roomID)
{
return _dataCenter.QueryRoom(roomID);
}
public boolean OrderRoom(int roomType, int roomCount, Time startTime, Time endTime)
{
Order tmpOrder = new Order();
java.util.Date now = new java.util.Date();
tmpOrder.set_dataCenter(_dataCenter);
tmpOrder.set_endTime(endTime);
tmpOrder.set_orderTime(new Time(now.getTime()));
tmpOrder.set_roomType(roomType);
tmpOrder.set_roomCount(roomCount);
tmpOrder.set_startTime(startTime);
tmpOrder.set_userName(_userName);
return tmpOrder.Submit();
}
public Order [] QueryOrders(OrderCondition []condition)
{
return _dataCenter.SearchOrders(condition);
}
public boolean AddToDataCenter()
{
return _dataCenter.AddUser(this)>0?true:false;
}
public boolean DeleteFromDataCenter()
{
if(_userName == null)
return false;
Condition condition = new OrderCondition(OrderCondition.RP_ORDERUSERNAME, OrderCondition.CO_EQUAL, this.get_userName());
int [] os = get_dataCenter().SearchOrderIDs(new Condition []{condition});
if(null != os && os.length >=1)
return false;
_dataCenter.DeleteUser(this);
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -