📄 employer.java
字号:
while(sd.next()){
if(sd.getInt(7)==1) cardState="可用";
else cardState="冻结";
s+="第"+i+"个客户 卡号:"+sd.getString(1)+" ,卡内余额:"+sd.getFloat(3)+"\n"
+" 身份证号:"+sd.getString(4)+" ,姓名:"+sd.getString(5)+" ,电话:"+sd.getString(6)+"\n"
+" 卡的状态:"+cardType+" ,开帐时间:"+sd.getString(8)+ " ,卡的种类:"+cardType+"\n";
i++;
}
}catch(SQLException e1){
System.out.println("SQLException:"+e1.getMessage());
}finally{
breakConnect();
return s+"显示完毕";
}
}
/**--以下showAllDisableAccounts()函数输出银行内所有被冻结帐号的客户的基本信息,无参数---
------------返回值s为String类型,s记录了所有信息---------------------
*/
public String showAllDisableAccounts(){
connectData();
String s=new String("以下输出所有被冻结帐号的客户的基本信息:"+"\n");
String cardState=new String("冻结");
String cardType;
try{
ResultSet sd=stmt.executeQuery("select * from AccountTab where cardState=0");
int i=1;
while(sd.next()){
if(sd.getInt(9)==1) cardType="信用卡";
else cardType="存储卡";
s+="第"+i+"个客户 卡号:"+sd.getString(1)+" ,卡内余额:"+sd.getFloat(3)+"\n"
+" 身份证号:"+sd.getString(4)+" ,姓名:"+sd.getString(5)+" ,电话:"+sd.getString(6)+"\n"
+" 卡的状态:"+cardType+" ,开帐时间:"+sd.getString(8)+ " ,卡的种类:"+cardType+"\n";
i++;
}
}catch(SQLException e1){
System.out.println("SQLException:"+e1.getMessage());
}finally{
breakConnect();
return s+"显示完毕";
}
}
/**------以下showAllOperateInAccount()函数输出银行内某一帐户的使用情况记录--------
--------------参数ID为String类型,代表客户的身份证号----------------
------------返回值s为String类型,s记录了所有信息---------------------
--------------------若身份证号不对,则返回null------------------------
--------------------否则返回具体的记录-------------------------------
*/
public String showAllOperateInAccount(String ID){
String s=null;
if(customerID.equals(ID)){
connectData();
s=new String("以下输出帐号为"+customerCardNo+"的客户的帐户使用情况:"+"\n");
try{
ResultSet sd=stmt.executeQuery("select * from AccountRecord where cardNo='"
+customerCardNo+"'");
int i=1;
while(sd.next()){
s+="第"+i+"次 操作:"+sd.getString(5)+" ,银行操作员职员号:"+sd.getString(3)
+" ,操作时间:"+sd.getString(6)+"\n";
i++;
}
}catch(SQLException e1){
System.out.println("SQLException:"+e1.getMessage());
}finally{
breakConnect();
s+="显示完毕";
}
}
return s;
}
/**----writeElectricFeeRecord()填写客户缴电费的日志,有6个参数--------
-customerID为客户身份证号,customerName为客户姓名,customerTel为客户电话-
--electricFee为缴的电费,timeOfFee表明缴的是什么时候的费,time为缴费时间--
*/
public void writeElectricFeeRecord(String customerID,String customerName,
String customerTel,float electricFee,String timeOfFee,String time){
connectData();
setTime();
try{
stmt.executeUpdate("insert into ElectricFeeRecord values('"+customerID+"','"
+customerName+"','"+customerTel+"','"+electricFee+"','"
+timeOfFee+"','"+time+"')");
breakConnect();
}catch(SQLException e1){
System.out.println("SQLException:"+e1.getMessage());
breakConnect();
}
}
/**----writeWaterFeeRecord()填写客户缴水费的日志,有6个参数--------
-customerID为客户身份证号,customerName为客户姓名,customerTel为客户电话-
--electricFee为缴的水费,timeOfFee表明缴的是什么时候的费,time为缴费时间--
*/
public void writeWaterFeeRecord(String customerID,String customerName,
String customerTel,float electricFee,String timeOfFee,String time){
connectData();
setTime();
try{
stmt.executeUpdate("insert into WaterFeeRecord values('"+customerID+"','"
+customerName+"','"+customerTel+"','"+electricFee+"','"
+timeOfFee+"','"+time+"')");
breakConnect();
}catch(SQLException e1){
System.out.println("SQLException:"+e1.getMessage());
breakConnect();
}
}
/**-----------payWaterFee()实现客户缴水费的功能,有2个参数-------------
------------money为缴的水费,timeOfFee表明缴的是什么时候的费----------
------------------缴费成功返回true,否则false-----------------
*/
public boolean payWaterFee(float money,String timeOfFee){
setTime();
int we=super.moveMoney("1000",money);
if(we==1){
write(customerCardNo,customerID,operaterID,money,"缴"+timeOfFee+"水费",time);
writeWaterFeeRecord(customerID,customerName,customerTel,money,
timeOfFee,time);
return true;
}
else return false;//-------卡内钱不够缴款.
}
/**-----------payElectricFee()实现客户缴电费的功能,有2个参数-------------
------------money为缴的水费,timeOfFee表明缴的是什么时候的费----------
------------------缴费成功返回true,否则false-----------------
*/
public boolean payElectricFee(float money,String timeOfFee){
setTime();
int we=super.moveMoney("1001",money);
if(we==1){
write(customerCardNo,customerID,operaterID,money,"缴"+timeOfFee+"电费",time);
writeElectricFeeRecord(customerID,customerName,customerTel,money,
timeOfFee,time);
return true;
}
else return false;//-------卡内钱不够缴款.
}
public String showWater(){
String s;
connectData();
s=new String("以下输出帐号为"+customerCardNo+"的客户的缴水费情况:"+"\n");
try{
ResultSet sd=stmt.executeQuery("select * from WaterFeeRecord where customerID='"
+customerID+"'");
int i=1;
while(sd.next()){
s+="第"+i+"次 缴水费: 身份证 "+sd.getString(1)+" ,姓名:"+sd.getString(2)
+" ,电话 " +sd.getString(3)+"\n"
+" 在"+sd.getString(6)+"缴"+sd.getString(5)+"水费:"+sd.getFloat(4)+"\n";
i++;
}
}catch(SQLException e1){
System.out.println("SQLException:"+e1.getMessage());
}finally{
breakConnect();
s+="显示完毕";
}
return s;
}
public String showElectricity(){
String s;
connectData();
s=new String("以下输出帐号为"+customerCardNo+"的客户的缴电费情况:"+"\n");
try{
ResultSet sd=stmt.executeQuery("select * from ElectricFeeRecord where customerID='"
+customerID+"'");
int i=1;
while(sd.next()){
s+="第"+i+"次 缴电费: 身份证 "+sd.getString(1)+" ,姓名:"+sd.getString(2)
+" ,电话 " +sd.getString(3)+"\n"
+" 在"+sd.getString(6)+"缴"+sd.getString(5)+"电费:"+sd.getFloat(4)+"\n";
i++;
}
}catch(SQLException e1){
System.out.println("SQLException:"+e1.getMessage());
}finally{
breakConnect();
s+="显示完毕";
}
return s;
}
public void delAccountRecord(){
connectData();
try{
stmt.executeUpdate("delete AccountRecord");
}catch(SQLException e1){
System.out.println("SQLException:"+e1.getMessage());
}finally{
breakConnect();
}
}
public void delAccountTab(){
connectData();
try{
stmt.executeUpdate("delete AccountTab");
}catch(SQLException e1){
System.out.println("SQLException:"+e1.getMessage());
}finally{
breakConnect();
}
}
public void delElectricFeeRecord(){
connectData();
try{
stmt.executeUpdate("delete ElectricFeeRecord");
}catch(SQLException e1){
System.out.println("SQLException:"+e1.getMessage());
}finally{
breakConnect();
}
}
public void delWaterFeeRecord(){
connectData();
try{
stmt.executeUpdate("delete WaterFeeRecord");
}catch(SQLException e1){
System.out.println("SQLException:"+e1.getMessage());
}finally{
breakConnect();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -