zoukankan      html  css  js  c++  java
  • 每日日报2021.2.7

    今天完成内容:

    开发家庭小账本:选择项

    1.编写代码

    public User ResearchId(int id) {
    Connection conn = DbHelper.getConnection();
    String sql = "select * from userno where id = ?";
    ResultSet rst = null; 

    User user = new User();
    try {
    PreparedStatement pst = conn.prepareStatement(sql);
    pst.setInt(1, id);
    rst = pst.executeQuery();
    while(rst.next()) {
    user.setId(rst.getInt("id"));
    user.setUsername(rst.getString("username"));
    user.setUserused(rst.getString("userused"));
    user.setUsermoney(rst.getString("usermoney"));
    user.setUsedate(rst.getDate("usedate"));
    user.setUsed(rst.getString("used"));
    }
    rst.close();
    pst.close();
    } catch (SQLException e) {
    // TODO 自动生成的 catch 块
    e.printStackTrace();
    }
    // TODO 自动生成的方法存根
    return user;
    }
    public int IncomeSum(){
    Connection conn = DbHelper.getConnection();
    String sql = "select * from userno where used = ?";
    String snum = null;
    PreparedStatement pst = null;
    int isum = 0;
    try {
    pst = conn.prepareStatement(sql);
    pst.setString(1, "收入");
    ResultSet rst = pst.executeQuery();
    while(rst.next()) {
    User user = new User();
    user.setUsermoney(rst.getString("usermoney"));
    snum = user.getUsermoney();
    isum = isum + Integer.parseInt(snum);
    }
    rst.close();
    pst.close();
    } catch (SQLException e) {
    // TODO 自动生成的 catch 块
    e.printStackTrace();
    }
    return isum;
    }
    public int ExpendSum(){
    Connection conn = DbHelper.getConnection();
    String sql = "select * from userno where used = ?";
    int esum = 0;
    String snum = null;
    try {
    PreparedStatement pst = conn.prepareStatement(sql);
    pst.setString(1, "支出");
    ResultSet rst = pst.executeQuery();
    while(rst.next()) {
    User user = new User();
    user.setUsermoney(rst.getString("usermoney"));
    snum = user.getUsermoney();
    esum = esum + Integer.parseInt(snum);

    }
    rst.close();
    pst.close();
    } catch (SQLException e) {
    // TODO 自动生成的 catch 块
    e.printStackTrace();
    }
    return esum;
    }

    遇到问题:

    解决大部分问题,还有一些细节未修改

    明日目标:

    学习Android studio的开发

  • 相关阅读:
    java相关
    cmd批处理命令及powershell
    火狐浏览器调试模式
    windows 配置java环境变量
    Acwing-279-自然数拆分(背包)
    Acwing-278-数字组合(背包)
    Acwing-277-饼干(DP)
    Acwing-274-移动服务(DP)
    Acwing-275-传纸条(DP)
    Acwing-121-赶牛入圈(二分, 二维前缀和,离散化)
  • 原文地址:https://www.cnblogs.com/leiyu1905/p/14905731.html
Copyright © 2011-2022 走看看