zoukankan      html  css  js  c++  java
  • 团队冲刺八

    昨天完成了,支出界面的设置,今天转到后台学习数据传输。

    后台代码:

    package com.yuukidach.ucount;

    import android.provider.ContactsContract;
    import android.widget.TextView;
    import org.litepal.crud.DataSupport;
    import java.text.DecimalFormat;
    import java.text.SimpleDateFormat;
    import java.util.Date;


    public class Sum extends DataSupport {
    public final int SUM = 1;
    public final int MONTHLY_COST = 2;
    public final int MONTHLY_EARN = 3;

    private double total = 0;
    private String name;
    private String date;
    private int id;
    private int mId;

    private DecimalFormat decimalFormat = new DecimalFormat("0.00");
    private SimpleDateFormat formatSum = new SimpleDateFormat("yyyy年MM月");

    public void setTotal(double total) { this.total = total; }
    public void setName(String name) { this.name = name; }
    public void setDate(String date) { this.date = date; }
    public void setId(int id) { this.id = id; }
    public void setmId(int mId) { this.mId = mId; }

    public double getTotal() { return total; }
    public String getName() { return name; }
    public String getDate() { return date; }
    public int getId() { return id; }
    public int getmId() { return mId; }

    public void calculateMoney(int id, double money, int type){
    Sum sum = new Sum();
    sum = DataSupport.find(Sum.class, id);
    sum.setTotal(sum.getTotal() + money * type);
    sum.save();
    }

    public void calculateMoneyIncludeNull(int id,String name, double money, int type, String date) {
    Sum sum = new Sum();
    if (isThereASum(id)) {
    sum = DataSupport.find(Sum.class, id);
    sum.setTotal(sum.getTotal() + money * type);
    sum.save();
    } else {
    saveSum(sum, id, name, money, type, date);
    }
    }

    public boolean isThereASum(int id) {
    if (DataSupport.find(Sum.class, id) == null)
    return false;
    return true;
    }

    public void saveSum(Sum sum, int id, String name, double money, int type, String date) {
    sum.setId(id);
    sum.setName(name);
    sum.setTotal(money * type);
    setDate(date);
    sum.save();
    }

    // save without name
    public void saveSum(Sum sum, int id, double money, int type, String date) {
    sum.setId(id);
    sum.setTotal(money * type);
    setDate(date);
    sum.save();
    }

    public void setMoneyText(int id, TextView textView) {
    if (isThereASum(id)) {
    Sum sum = DataSupport.find(Sum.class, id);
    if (!sum.getDate().equals(formatSum.format(new Date()))) {
    sum.saveSum(sum, id, 0.0, 1, formatSum.format(new Date()));
    }
    textView.setText(decimalFormat.format(sum.getTotal()));
    } else {
    textView.setText(decimalFormat.format(0));
    }
    }
    }

  • 相关阅读:
    [Linux] Chmod 改变权限
    [linux命令]基本命令
    [Linux命令] 查看目录大小du
    [Linux命令]格式化mkfs
    在VMWare下的Linux切换
    .net的MSMQ异步调用
    CASSINI源代码分析
    [Wix] RadioButton与ListItem的属性要改掉了
    如何快速生成Insert数据插入语句?
    撕纸
  • 原文地址:https://www.cnblogs.com/mac-13/p/12791982.html
Copyright © 2011-2022 走看看