Exemplo n.º 1
0
 @Override
 public boolean setcost(double cost) {
   // TODO Auto-generated method stub
   try {
     mysqlimp = new MySqlImp();
     String insert = "INSERT INTO 利润表" + " (支出)" + " VALUES(" + cost + ")";
     mysqlimp.update(insert);
     return true;
   } catch (ClassNotFoundException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
     return false;
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
     return false;
   }
 }
Exemplo n.º 2
0
 @Override
 public double getcosttotal() {
   // TODO Auto-generated method stub
   try {
     mysqlimp = new MySqlImp();
     String getsum = "SELECT SUM(支出) FROM 利润表";
     ResultSet rs = mysqlimp.query(getsum);
     rs.next();
     double result = rs.getDouble(1);
     rs.close();
     return result;
   } catch (ClassNotFoundException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
     return 0;
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
     return 0;
   }
 }