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的开发

  • 相关阅读:
    [POJ 1200]Crazy Search
    [来源不详]删数方案数
    noip搜索模拟题 骰子
    [SDOI2010]地精部落
    [HAOI2008]硬币购物
    BZOJ1009: [HNOI2008]GT考试
    BZOJ1830: [AHOI2008]Y型项链 & BZOJ1789: [Ahoi2008]Necklace Y型项链
    BZOJ1251: 序列终结者
    BZOJ3620: 似乎在梦中见过的样子
    BZOJ4477: [Jsoi2015]字符串树
  • 原文地址:https://www.cnblogs.com/leiyu1905/p/14905731.html
Copyright © 2011-2022 走看看