package com.xiaoke.accountsoft.activity;
import java.util.Calendar;
import com.xiaoke.accountsoft.dao.InaccountDAO;
import com.xiaoke.accountsoft.dao.OutaccountDAO;
import com.xiaoke.accountsoft.model.Tb_inaccount;
import com.xiaoke.accountsoft.model.Tb_outaccount;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
public class InfoManage extends Activity {
protected static final int DATE_DIALOG_ID = 0;// 创建日期对话框常量
TextView tvtitle, textView;// 创建两个TextView对象
EditText txtMoney, txtTime, txtHA, txtMark;// 创建4个EditText对象
Spinner spType;// 创建Spinner对象
Button btnEdit, btnDel;// 创建两个Button对象
String[] strInfos;// 定义字符串数组
String strid, strType;// 定义两个字符串变量,分别用来记录信息编号和管理类型
private int mYear;// 年
private int mMonth;// 月
private int mDay;// 日
OutaccountDAO outaccountDAO = new OutaccountDAO(InfoManage.this);// 创建OutaccountDAO对象
InaccountDAO inaccountDAO = new InaccountDAO(InfoManage.this);// 创建InaccountDAO对象
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.infomanage);// 设置布局文件
tvtitle = (TextView) findViewById(R.id.inouttitle);// 获取标题标签对象
textView = (TextView) findViewById(R.id.tvInOut);// 获取地点/付款方标签对象
txtMoney = (EditText) findViewById(R.id.txtInOutMoney);// 获取金额文本框
txtTime = (EditText) findViewById(R.id.txtInOutTime);// 获取时间文本框
spType = (Spinner) findViewById(R.id.spInOutType);// 获取类别下拉列表
txtHA = (EditText) findViewById(R.id.txtInOut);// 获取地点/付款方文本框
txtMark = (EditText) findViewById(R.id.txtInOutMark);// 获取备注文本框
btnEdit = (Button) findViewById(R.id.btnInOutEdit);// 获取修改按钮
btnDel = (Button) findViewById(R.id.btnInOutDelete);// 获取删除按钮
Intent intent = getIntent();// 创建Intent对象
Bundle bundle = intent.getExtras();// 获取传入的数据,并使用Bundle记录
strInfos = bundle.getStringArray(Showinfo.FLAG);// 获取Bundle中记录的信息
strid = strInfos[0];// 记录id
strType = strInfos[1];// 记录类型
if (strType.equals("btnoutinfo"))// 如果类型是btnoutinfo
{
tvtitle.setText("支出管理");// 设置标题为“支出管理”
textView.setText("地 点:");// 设置“地点/付款方”标签文本为“地 点:”
// 根据编号查找支出信息,并存储到Tb_outaccount对象中
Tb_outaccount tb_outaccount = outaccountDAO.find(Integer
.parseInt(strid));
txtMoney.setText(String.valueOf(tb_outaccount.getMoney()));// 显示金额
txtTime.setText(tb_outaccount.getTime());// 显示时间
spType.setPrompt(tb_outaccount.getType());// 显示类别
txtHA.setText(tb_outaccount.getAddress());// 显示地点
txtMark.setText(tb_outaccount.getMark());// 显示备注
} else if (strType.equals("btnininfo"))// 如果类型是btnininfo
{
tvtitle.setText("收入管理");// 设置标题为“收入管理”
textView.setText("付款方:");// 设置“地点/付款方”标签文本为“付款方:”
// 根据编号查找收入信息,并存储到Tb_outaccount对象中
Tb_inaccount tb_inaccount = inaccountDAO.find(Integer
.parseInt(strid));
txtMoney.setText(String.valueOf(tb_inaccount.getMoney()));// 显示金额
txtTime.setText(tb_inaccount.getTime());// 显示时间
spType.setPrompt(tb_inaccount.getType());// 显示类别
txtHA.setText(tb_inaccount.getHandler());// 显示付款方
txtMark.setText(tb_inaccount.getMark());// 显示备注
}
txtTime.setOnClickListener(new OnClickListener() {// 为时间文本框设置单击监听事件
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
showDialog(DATE_DIALOG_ID);// 显示日期选择对话框
}
});
btnEdit.setOnClickListener(new OnClickListener() {// 为修改按钮设置监听事件
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
if (strType.equals("btnoutinfo"))// 判断类型如果是btnoutinfo
{
Tb_outaccount tb_outaccount = new Tb_outaccount();// 创建Tb_outaccount对象
tb_outaccount.setid(Integer.parseInt(strid));// 设置编号
tb_outaccount.setMoney(Double.parseDouble(txtMoney
.getText().toString()));// 设置金额
tb_outaccount.setTime(txtTime.getText().toString());// 设置时间
tb_outaccount.setType(spType.getSelectedItem().toString());// 设置类别
tb_outaccount.setAddress(txtHA.getText().toString());// 设置地点
tb_outaccount.setMark(txtMark.getText().toString());// 设置备注
outaccountDAO.update(tb_outaccount);// 更新支出信息
} else if (strType.equals("btnininfo"))// 判断类型如果是btnininfo
{
Tb_inaccount tb_inaccount = new Tb_inaccount();// 创建Tb_inaccount对象
tb_inaccount.setid(Integer.parseInt(strid));// 设置编号
tb_inaccount.setMoney(Double.parseDouble(txtMoney.getText()
.toString()));// 设置金额
tb_inaccount.setTime(txtTime.getText().toString());// 设置时间
tb_inaccount.setType(spType.getSelectedItem().toString());// 设置类别
tb_inaccount.setHandler(txtHA.getText().toString());// 设置付款方
tb_inaccount.setMark(txtMark.getText().toString());// 设置备注
inaccountDAO.update(tb_inaccount);// 更新收入信息
}
// 弹出信息提示
Toast.makeText(InfoManage.this, "〖数据〗修改成功!", Toast.LENGTH_SHORT)
.show();
}
});
btnDel.setOnClickListener(new OnClickListener() {// 为删除按钮设置监听事件
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
if (strType.equals("btnoutinfo"))// 判断类型如果是btnoutinfo
{
outaccountDAO.detele(Integer.parseInt(strid));// 根据编号删除支出信息
} else if (strType.equals("btnininfo"))// 判断类型如果是btnininfo
{
inaccountDAO.detele(Integer.parseInt(strid));// 根据编号删除收入信息
}
Toast.makeText(InfoManage.this, "〖数据〗删除成功!", Toast.LENGTH_SHORT)
.show();
}
});
final Calendar c = Calendar.getInstance();// 获取当前系统日期
mYear = c.get(Calendar.YEAR);// 获取年份
mMonth = c.get(Calendar.MONTH);// 获取月份
mDay = c.get(Calendar.DAY_OF_MONTH);// 获取天数
updateDisplay();// 显示当前系统时间
}
@Override
protected Dialog onCreateDialog(int id)// 重写onCreateDialog方法
{
switch (id) {
case DATE_DIALOG_ID:// 弹出日期选择对话框
return new DatePickerDialog(this, mDateSetListener, mYear, mMonth,
mDay);
}
return null;
}
private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
mYear = year;// 为年份赋值
mMonth = monthOfYear;// 为月份赋值
mDay = dayOfMonth;// 为天赋值
updateDisplay();// 显示设置的日期
}
};
private void updateDisplay() {
// 显示设置的时间
txtTime.setText(new StringBuilder().append(mYear).append("-")
.append(mMonth + 1).append("-").append(mDay));
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
基于android的家庭理财软件 (156个子文件)
resources.ap_ 113KB
AccountMS.apk 133KB
proguard.cfg 1KB
Showinfo.class 10KB
InfoManage.class 9KB
AddOutaccount.class 8KB
AddInaccount.class 8KB
OutaccountDAO.class 8KB
InaccountDAO.class 8KB
FlagDAO.class 6KB
Outaccountinfo.class 6KB
pictureAdapter.class 6KB
Inaccountinfo.class 6KB
MainActivity.class 6KB
Showinfo.class 5KB
InfoManage.class 5KB
Picture.class 5KB
FlagManage.class 5KB
OutaccountDAO.class 4KB
ViewHolder.class 4KB
InaccountDAO.class 4KB
Login.class 4KB
Accountflag.class 4KB
FlagDAO.class 4KB
Sysset.class 4KB
R$id.class 4KB
AddInaccount.class 3KB
AddOutaccount.class 3KB
Outaccountinfo.class 3KB
Inaccountinfo.class 3KB
InfoManage$3.class 3KB
Tb_outaccount.class 3KB
Tb_inaccount.class 3KB
PwdDAO.class 3KB
R$id.class 3KB
pictureAdapter.class 3KB
Showinfo$4.class 2KB
AddOutaccount$3.class 2KB
AddInaccount$3.class 2KB
MainActivity$1.class 2KB
FlagManage.class 2KB
PwdDAO.class 2KB
Login$1.class 2KB
Outaccountinfo$1.class 2KB
Inaccountinfo$1.class 2KB
ReportView.class 2KB
Accountflag$1.class 2KB
Tb_outaccount.class 2KB
Tb_inaccount.class 2KB
FlagManage$1.class 2KB
MainActivity.class 2KB
InfoManage$4.class 2KB
Sysset$1.class 2KB
DBOpenHelper.class 2KB
R$string.class 2KB
R$layout.class 2KB
DBOpenHelper.class 2KB
R$drawable.class 2KB
R.class 2KB
FlagManage$2.class 1KB
Tb_flag.class 1KB
R$array.class 1KB
AddInaccount$4.class 1KB
AddOutaccount$4.class 1KB
Accountflag.class 1KB
Tb_pwd.class 1KB
R$attr.class 1KB
Sysset.class 1KB
Login.class 1KB
AddOutaccount$1.class 1KB
AddInaccount$1.class 1KB
InfoManage$1.class 1KB
Sysset$2.class 1006B
Accountflag$2.class 980B
Picture.class 908B
Showinfo$3.class 901B
Showinfo$1.class 901B
Showinfo$2.class 901B
Tb_flag.class 885B
AddOutaccount$2.class 885B
AddInaccount$2.class 879B
InfoManage$2.class 867B
R$string.class 837B
R$layout.class 835B
Login$2.class 825B
R$drawable.class 770B
R.class 683B
Tb_pwd.class 651B
Report.class 525B
R$array.class 491B
ViewHolder.class 410B
R$attr.class 379B
.classpath 364B
classes.dex 41KB
InfoManage.java 7KB
R.java 6KB
Showinfo.java 6KB
MainActivity.java 5KB
OutaccountDAO.java 5KB
InaccountDAO.java 5KB
共 156 条
- 1
- 2
资源评论
- wcjp5292014-09-12很有用,谢谢
- lqclqc1232014-11-04很有用,没有bug
- daokai19932016-04-18看了代码,不错的软件!对于初学者好处很大!
- csdn_coolhong11222014-12-14好东西,值得参考
- chh521cxf2015-04-09很实用,对我的Android编程很有帮助
周公点灯
- 粉丝: 1
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功