📄 account.java
字号:
//Source file: D:\work\五洋\javaBean\src\Account.java
package src.wuyang;
import src.com.*;
import java.sql.*;
import java.io.*;
public class Account extends ShangObject
{
/**
用户帐号
*/
private String accountId;
/**
对应的职员信息
*/
private String employeeId;
/**
帐号密码
*/
private String password;
/**
对应的角色号
(控制权限)
*/
private int roleId;
private String empName;
private String position;
private String empIdNumber;
private String deptId;
private String companyId;
public Account()
{
primarykey1Name = "accountId";
primarykey1Type = 1;
tableName = "Account";
viewName = "V_Account";
numInOnePager = 10;
}
public int loadAttr() {
try {
accountId = getRsString(rs,"accountId");
employeeId = getRsString(rs,"employeeId");
password = getRsString(rs, "password");
roleId = rs.getInt("roleId");
empName = getRsString(rs,"empName");
position = getRsString(rs,"position");
empIdNumber = getRsString(rs,"empIdNumber");
deptId = getRsString(rs,"deptId");
companyId = getRsString(rs,"companyId");
} catch(SQLException e) {
e.printStackTrace();
System.out.println("query failed!");
return -1;
}
return 1;
}
public int Login(String aLoginName,String aPassword)
{
int rtInfo;
String sql = "{?=call sp_Login(?,?,?,?)}";
try
{
CallableStatement updStmt=conn.prepareCall(sql);
updStmt.registerOutParameter(1, java.sql.Types.INTEGER);/** 注册OUT参数 */
setStmtString(updStmt, 2, aLoginName);
setStmtString(updStmt, 3, theGlobal.ip);
setStmtString(updStmt, 4, theGlobal.machineName);
setStmtString(updStmt, 5, aPassword);
updStmt.executeUpdate();
rtInfo=updStmt.getInt(1);
updStmt.close();
return rtInfo;
} catch(SQLException e)
{
e.printStackTrace();
return -102;
}
}
/*
@loginName varchar(30)
,@ip varchar(20)
,@machineName varchar(30)
,@accountId varchar(10)
,@employeeId varchar(10)
,@password varchar(10)
,@roleId int
,@deptId varchar(10)
*/
public int insert() {
String sql= "{?=call sp_InsertAccount(?,?,?,?,?,?,?)}";
try{
CallableStatement updStmt=conn.prepareCall(sql);
updStmt.registerOutParameter(1, java.sql.Types.INTEGER);
setStmtString(updStmt, 2, theGlobal.loginName);
setStmtString(updStmt, 3, theGlobal.ip);
setStmtString(updStmt, 4, theGlobal.machineName);
setStmtString(updStmt,5,accountId);
setStmtString(updStmt,6,employeeId);
setStmtString(updStmt,7,password);
updStmt.setInt(8,roleId);
updStmt.executeUpdate();
int rtcode = updStmt.getInt(1);
updStmt.close();
return rtcode;
}catch(SQLException e){
System.out.println(e.getMessage());
e.printStackTrace();
return -1;
}
}
/*
@loginName varchar(30)
,@ip varchar(20)
,@machineName varchar(30)
,@accountId varchar(10)
,@password varchar(10)
,@roleId int
,@deptId varchar(10)
*/
public int update(){
String sql= "{?=call sp_UpdateAccount(?,?,?,?,?,?)}";
try{
CallableStatement updStmt=conn.prepareCall(sql);
updStmt.registerOutParameter(1, java.sql.Types.INTEGER);
setStmtString(updStmt, 2, theGlobal.loginName);
setStmtString(updStmt, 3, theGlobal.ip);
setStmtString(updStmt, 4, theGlobal.machineName);
setStmtString(updStmt,5,accountId);
setStmtString(updStmt,6,password);
updStmt.setInt(7,roleId);
updStmt.executeUpdate();
int rtcode = updStmt.getInt(1);
updStmt.close();
return rtcode;
}catch(SQLException e){
System.out.println(e.getMessage());
e.printStackTrace();
return -1;
}
}
public String getWhereClause(javax.servlet.ServletRequest request) {
String whereClause = "";
String str;
int queryMode = (new Integer(request.getParameter("queryMode"))).intValue();
switch(queryMode)
{
case 1: // 综合查询
whereClause = addWhereClause(whereClause, "accountId", "=", "'", request.getParameter("accountId"));
whereClause = addWhereClause(whereClause, "employeeId", "=", "'", request.getParameter("employeeId"));
whereClause = addWhereClause(whereClause, "roleId", "=", "", request.getParameter("roleId"));
whereClause = addWhereClause(whereClause, "deptId", "=", "'", request.getParameter("deptId"));
break;
case 2:
whereClause = addWhereClause(whereClause,"accountId","=","'",request.getParameter("accountId"));
break;
}
return whereClause;
}
/**
* Access method for the accountId property.
*
* @return the current value of the accountId property
*/
public String getAccountId() {
return accountId;}
/**
* Sets the value of the accountId property.
*
* @param aAccountId the new value of the accountId property
*/
public void setAccountId(String aAccountId) {
try{
accountId = new String(aAccountId.getBytes("8859_1"));
}catch(UnsupportedEncodingException e) {
System.out.println("error in getbytes");
}
}
/**
* Access method for the employeeId property.
*
* @return the current value of the employeeId property
*/
public String getEmployeeId() {
return employeeId;}
/**
* Sets the value of the employeeId property.
*
* @param aEmployeeId the new value of the employeeId property
*/
public void setEmployeeId(String aEmployeeId) {
try{
employeeId = new String(aEmployeeId.getBytes("8859_1"));
}catch(UnsupportedEncodingException e) {
System.out.println("error in getbytes");
}
}
/**
* Access method for the password property.
*
* @return the current value of the password property
*/
public String getPassword() {
return password;}
/**
* Sets the value of the password property.
*
* @param aPassword the new value of the password property
*/
public void setPassword(String aPassword) {
try{
password = new String(aPassword.getBytes("8859_1"));
}catch(UnsupportedEncodingException e) {
System.out.println("error in getbytes");
}
}
/**
* Access method for the roleId property.
*
* @return the current value of the roleId property
*/
public int getRoleId() {
return roleId;}
/**
* Sets the value of the roleId property.
*
* @param aRoleId the new value of the roleId property
*/
public void setRoleId(int aRoleId) {
roleId = aRoleId;}
/**
* Access method for the deptId property.
*
* @return the current value of the deptId property
*/
public String getDeptId() {
return deptId;}
public String getEmpName() {
return empName;}
public String getPosition() {
return position;}
public String getEmpIdNumber() {
return empIdNumber;}
public String getCompanyId() {
return companyId;}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -