其他分享
首页 > 其他分享> > 第七天敏捷冲刺

第七天敏捷冲刺

作者:互联网

1.昨天已经完成的工作

2.今天计划完成的工作

3.工作中遇到的困难

4.代码签入


)

5.最新模块的代码

public class MyDBOpenHelper extends SQLiteOpenHelper {
    public MyDBOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory,
                          int version) {
        super(context, "my.db", null, 1);
    }

    @Override
    //数据库第一次创建时被调用
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE planlist(planid long primary key," +
                "name varchar(20)," +
                "description varchar(30)," +
                "worktime long," +
                "breaktime long," +
                "begintime long," +
                "finishtime long," +
                "mouldname varchar(20))");

        db.execSQL("create table mouldlist(" +
                "name varchar(20) primary key," +
                "breakclkpath varchar(30)," +
                "workclkpath varchar(30))");
    }

    //软件版本号发生改变时调用
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    }
}
private static final SQLiteDatabase db = myDBHelper.getWritableDatabase();
private static final String debug = "SQLUtils中的日志信息";

//判断planlist表中当前有多少个元素
public static int getCountOfPlanInDB() {
    Cursor cursor = db.rawQuery("SELECT * FROM planlist", null);
    return cursor.getCount();
}

//判断p是否已经存在于数据库中planlist表中
private static boolean isInPlanList(Plan p) {
    //选出和p相同id的元组放入结果集中
    Cursor cursor = db.rawQuery("SELECT * FROM planlist WHERE planid = ?",
            new String[]{String.valueOf(p.planid)});
    //若结果集为空,则说明没有重复,反之则代表此plan已经在数据库中的planlist中
    if ((cursor.moveToFirst())) {
        Log.d(debug, "id为" + p.planid + "的plan已经在database中了");
        return true;
    }
    Log.d(debug, "id为" + p.planid + "的plan不在database中");
    return false;
}

//保存计划到TABLE planlist
public static void savePlan(Plan p) {
    //如果计划p不在数据库中的planlist中,则需要插入这一条plan的信息
    if (!isInPlanList(p)) {
        Log.d(debug, "id为" + p.planid + "的plan不在planlist中,可以插入这一条plan的信息");
        db.execSQL("INSERT INTO planlist(planid,name,description,worktime,breaktime,begintime,finishtime,mouldname)" +
                "values(?,?,?,?,?,?,?,?)", new Object[]{p.planid, p.name, p.description, p.workTime, p.breakTime, p.beginTime, p.finishTime, p.mould.name});
    }

}

//更新TABLE planlist中p的信息
public static void updatePlan(Plan p) {
    //如果计划p已经在planlist表中了,才能够进行更新数据,否则无法更新
    if (isInPlanList(p)) {
        Log.d(debug, "id为" + p.planid + "的plan已在planlist表中,满足条件,可以更新");
        db.execSQL("UPDATE planList SET name = ?,description = ?,worktime=?,breaktime=?,begintime=?,finishtime=?,mouldname=? WHERE planid = ?",
                new Object[]{p.name, p.description, p.workTime, p.breakTime, p.beginTime, p.finishTime, p.mould.name, p.planid});
    } else
        Log.d(debug, "id为" + p.planid + "的plan不在planlist表中,不满足条件,不可以更新");
}

6.每人每日总结

陈泽同:项目很简单
谢国浩:多多学习
韦秋风:由于之前规划不当,因此Sputills只能被迫全部放弃,所以核心开发人员在此基础上写的IOUTILS全部木大。
希望核心开发人员心脏没事(阿门)

标签:name,planid,db,冲刺,planlist,plan,敏捷,public,第七天
来源: https://www.cnblogs.com/BabeBella-carol/p/15614138.html