Andrews class-based report

                                                                                              Andrews curriculum design

                                                                                                 Accounting Management System

               

                                                                                           School: Shenyang Institute of Technology

                                                                                           Department: Information and Control Engineering

                                                                                            Major: Computer Science and Technology

                                                                                             Class: 1702

                                                                                             Student Number: 173 230 222

                                                                                             Name: Yan Feng

                                                                                             Instructor: Guo Dan

                                  

                                                

                                                                                                       table of Contents

 

                                                                                One. Needs analysis ..................................

 

                                                                                two. Technical Note ..................................

 

                                                                                three. Code ......................................

 

                                                                                four. System testing ..................................

 

                                                                                Fives. System implementation ..................................

 

                                                                                six. Summary ......................................

 

 

  A: needs analysis

  1. Functional Description:

Add accounts, query and modify accounts, account information statistics, exit system

  1. Design ideas:

(1) new accounts: You can increase the content of the accounts, save the new account information

(2) query and modify: View account information, can be modified audit the accounts, and save the modified information

(3) statistical accounts: Accounts automatic classification of the statistical system for some time, for easy viewing

(4) to exit the system: when you want to shut down the system, you can quickly exit the system

two. Technical Description

Today, technology has improved continuously, people are increasingly high demand for high-tech, on -demand applications on the Android platform more and more. This course is designed primarily to achieve a billing management system to achieve record revenues and record of expenditure and income and expenditure statistics may be this month, and you can log in to register. Use SQLite storage technology income and expenditure information.

UML class diagrams

 

 

FIG Example Analysis:

 

 

three. Code

The list of documents:

 

 

 

Layout file:

1. Screenshot

记账统计主界面

 

 

 

 

添加收入支出

 

 

 

登录

 

 

 

2. 原文件

  

1LoginActivity.java:  主要用来进行登录

/**
 * login event
 * @param v
 */
public void OnMyLoginClick(View v){
    if(pubFun.isEmpty(editPhone.getText().toString()) || pubFun.isEmpty(editPwd.getText().toString())){
        Toast.makeText(this, "手机号或密码不能为空!", Toast.LENGTH_SHORT).show();
        return;
    }

    //call DBOpenHelper
    DBOpenHelper helper = new DBOpenHelper(this,"qianbao.db",null,1);
    SQLiteDatabase db = helper.getWritableDatabase();
    Cursor c = db.query("user_tb",null,"userID=? and pwd=?",new String[]{editPhone.getText().toString(),editPwd.getText().toString()},null,null,null);
    if(c!=null && c.getCount() >= 1){
        String[] cols = c.getColumnNames();
        while(c.moveToNext()){
            for(String ColumnName:cols){
                Log.i("info",ColumnName+":"+c.getString(c.getColumnIndex(ColumnName)));
            }
        }
        c.close();
        db.close();

        //将登陆用户信息存储到SharedPreferences中
        SharedPreferences mySharedPreferences= getSharedPreferences("setting",Activity.MODE_PRIVATE); //实例化SharedPreferences对象
        SharedPreferences.Editor editor = mySharedPreferences.edit();//实例化SharedPreferences.Editor对象
        editor.putString("userID", editPhone.getText().toString()); //用putString的方法保存数据
        editor.commit(); //提交当前数据

        this.finish();
    }
    else{
        Toast.makeText(this, "手机号或密码输入错误!", Toast.LENGTH_SHORT).show();
    }
}

 

 

2RegistActivity  主要注册成为会员

.java:

/**

 * Description : 注册信息

*/

/**
 * register event
 * @param v
 */
public void OnMyRegistClick(View v)
{
    boolean isTrue = true;
    if(pubFun.isPhoneNumberValid(editPhone.getText().toString()) == false){
        isTrue = false;
        Toast.makeText(this, "手机号格式不正确!", Toast.LENGTH_SHORT).show();
        return;
    }
    if(pubFun.isEmpty(editPwd.getText().toString())){
        isTrue = false;
        Toast.makeText(this, "密码不能为空!", Toast.LENGTH_SHORT).show();
        return;
    }

    if(isTrue = true){
        //call DBOpenHelper
        DBOpenHelper helper = new DBOpenHelper(this,"qianbao.db",null,1);
        SQLiteDatabase db = helper.getWritableDatabase();
        Cursor c = db.query("user_tb",null,"userID=?",new String[]{editPhone.getText().toString()},null,null,null);
        if(c!=null && c.getCount() >= 1){
            Toast.makeText(this, "该用户已存在", Toast.LENGTH_SHORT).show();
            c.close();
        }
        else{
            //insert data
            ContentValues values= new ContentValues();
            values.put("userID",editPhone.getText().toString());
            values.put("pwd",editPwd.getText().toString());
            long rowid = db.insert("user_tb",null,values);

            Toast.makeText(this, "注册成功", Toast.LENGTH_SHORT).show();
            this.finish();
        }
        db.close();
    }else{
        return;
    }
}

 

 

3SpendingActivity  记录记账信息添加

.java

/**

 * Description :记账

*/

String[] titles = new String[]{"明细", "类别报表"};
private static final String[] yearList = {pubFun.getTime("Y") + "年"};
private static final String[] monthList = { "01月", "02月", "03月", "04月", "05月", "06月", "07月", "08月", "09月", "10月", "11月", "12月" };

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //去除工具栏
    getSupportActionBar().hide();
    setContentView(R.layout.spending);

    initViews();

    initSpinner();

    mFragmentAdapter = new FragmentAdapter(this.getSupportFragmentManager(), mFragmentList);
    vp.setOffscreenPageLimit(2);//ViewPager的缓存为2帧
    vp.setAdapter(mFragmentAdapter);
    vp.setCurrentItem(0);//初始设置ViewPager选中第一帧
    item_detail.setTextColor(Color.parseColor("#1ba0e1"));

    //ViewPager的监听事件
    vp.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            /*此方法在页面被选中时调用*/
            //title.setText(titles[position]);
            changeTextColor(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
            /*此方法是在状态改变的时候调用,其中arg0这个参数有三种状态(0,1,2)。
            arg0==1的时辰默示正在滑动,
            arg0==2的时辰默示滑动完毕了,
            arg0==0的时辰默示什么都没做。*/
        }
    });

 

 

4MainActivity  系统的主界面包括按钮

.java:

/**

 * Description :主界面

*/

package com.hyl.accountbook;

import com.hyl.accountbook.CircleMenuLayout.OnMenuItemClickListener;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Toast;

/**
 * @programName: MainActivity.java
 * @programFunction: the home page
 * @createDate:
 * @author: AnneHan
 * @version:
 * xx.   yyyy/mm/dd   ver    author    comments
 * 01.      1.00
 */
public class MainActivity extends AppCompatActivity {

    //第一次点击事件发生的时间
    private long mExitTime;

    private CircleMenuLayout mCircleMenuLayout;

    private String[] mItemTexts = new String[] { "登录&注册", "关于我们", "心愿墙",
            "特色设置", "收入&支出", "统计" };
    private int[] mItemImgs = new int[] { R.mipmap.home_mbank_1_normal,
            R.mipmap.home_mbank_2_normal, R.mipmap.home_mbank_3_normal,
            R.mipmap.home_mbank_4_normal, R.mipmap.home_mbank_5_normal,
            R.mipmap.home_mbank_6_normal };

    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mCircleMenuLayout = (CircleMenuLayout) findViewById(R.id.id_menulayout);
        mCircleMenuLayout.setMenuItemIconsAndTexts(mItemImgs, mItemTexts);

        mCircleMenuLayout.setOnMenuItemClickListener(new OnMenuItemClickListener() {
            public void itemClick(View view, int pos) {
                if (mItemTexts[pos] == "特色设置") {
                    openSettingWind(view);
                } else if (mItemTexts[pos] == "收入&支出") {
                    openSpendingWind(view);
                } else if (mItemTexts[pos] == "登录&注册") {
                    openLoginWind(view);
                } else if (mItemTexts[pos] == "统计") {
                    openCountWind(view);
                } else if (mItemTexts[pos] == "关于我们") {
                    openAboutUsAddWind(view);
                } else if (mItemTexts[pos] == "心愿墙") {
                    openWishWind(view);
                }
                ;
            }

            public void itemCenterClick(View view) {
                Toast.makeText(MainActivity.this, "you can do something just like login or register", Toast.LENGTH_SHORT).show();
            }
        });
    }

    /**
     * 跳转至登录&注册界面
     * @param v
     */
    private void openLoginWind(View v){
        Intent intent = new Intent();
        intent.setClass(MainActivity.this, LoginActivity.class);
        this.startActivity(intent);
    }

    /**
     * 跳转至开销界面,记录收入与支出
     * @param v
     */
    private void openSpendingWind(View v){
        Intent intent = new Intent();
        intent.setClass(MainActivity.this, SpendingActivity.class);
        this.startActivity(intent);
    }

    /**
     * 跳转至统计界面
     * @param v
     */
    private void openCountWind(View v){
        Intent intent=new Intent();
        intent.setClass(MainActivity.this, CountActivity.class);
        this.startActivity(intent);
    }

    /**
     * 跳转至特色设置界面
     * @param v
     */
    private void openSettingWind(View v){
        Intent intent = new Intent();
        intent.setClass(MainActivity.this, SettingActivity.class);
        this.startActivity(intent);
    }

    /**
     * 跳转至心愿墙界面
     * @param v
     */
    private void openWishWind(View v){
        Intent intent = new Intent();
        intent.setClass(MainActivity.this, WishActivity.class);
        this.startActivity(intent);
    }

    /**
     * 跳转至关于我们界面
     * @param v
     */
    private void openAboutUsAddWind(View v){
        Intent intent=new Intent();
        intent.setClass(MainActivity.this, AboutUsActivity.class);
        this.startActivity(intent);
    }

    /**
     * 点击两次返回退出app
     */
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            if ((System.currentTimeMillis() - mExitTime) > 2000) {
                Object mHelperUtils;
                Toast.makeText(this, "再按一次退出金金记较", Toast.LENGTH_SHORT).show();
                //System.currentTimeMillis()系统当前时间
                mExitTime = System.currentTimeMillis();
            } else {
                finish();
            }
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }


}

 

四.系统测试:

(1)测试能否添加收入支出

(2)测试能否删除账本信息

(3)测试能否修改金额及账本信息

(4)测试能否查看收入支出情况以及账本信息

 

 

五.系统实现:

(1)登录功能可以实现

(2)添加功能可以实现

(3)删除功能可以实现

(4)修改功能可以实现

(5)查询功能可以实现

 

 

 

 

 

 

六.总结

通过这次课程设计,我明白了原来安卓是一门非常难学难理解的课程,繁琐复杂的代码运行,难懂的安卓语言等困难必须要有非常坚实的基础,有足够的功底才能学好这门课程。目前我是处于一种完全理解不了安卓语言的水平,所以我需要更加进一步的学习这门课程,争取能理解得了一些。

 

 

 

 

Guess you like

Origin www.cnblogs.com/fengyan1/p/11999973.html