zoukankan      html  css  js  c++  java
  • 结队项目5

    // Source code recreated from a .class file by IntelliJ IDEA
    // (powered by Fernflower decompiler)
    //

    package com.pwp.dao;

    import android.content.ContentValues;
    import android.content.Context;
    import android.database.Cursor;
    import android.database.sqlite.SQLiteDatabase;
    import com.pwp.dao.DBOpenHelper;
    import com.pwp.vo.ScheduleDateTag;
    import com.pwp.vo.ScheduleVO;
    import java.util.ArrayList;

    public class ScheduleDAO {
    private DBOpenHelper dbOpenHelper = null;

    public ScheduleDAO(Context context) {
        this.dbOpenHelper = new DBOpenHelper(context, "schedules.db");
    }
    
    public int save(ScheduleVO scheduleVO) {
        SQLiteDatabase db = this.dbOpenHelper.getWritableDatabase();
        ContentValues values = new ContentValues();
        values.put("scheduleTypeID", Integer.valueOf(scheduleVO.getScheduleTypeID()));
        values.put("remindID", Integer.valueOf(scheduleVO.getRemindID()));
        values.put("scheduleContent", scheduleVO.getScheduleContent());
        values.put("scheduleDate", scheduleVO.getScheduleDate());
        db.beginTransaction();
        int scheduleID = -1;
    
        try {
            db.insert("schedule", (String)null, values);
            Cursor cursor = db.rawQuery("select max(scheduleID) from schedule", (String[])null);
            if(cursor.moveToFirst()) {
                scheduleID = (int)cursor.getLong(0);
            }
    
            cursor.close();
            db.setTransactionSuccessful();
        } finally {
            db.endTransaction();
        }
    
        return scheduleID;
    }
    

    public ArrayList getTagDate(int currentYear, int currentMonth) {
    ArrayList dateTagList = new ArrayList();
    SQLiteDatabase db = this.dbOpenHelper.getReadableDatabase();
    Cursor cursor = db.query("scheduletagdate", new String[]{"tagID", "year", "month", "day", "scheduleID"}, "year=? and month=?", new String[]{String.valueOf(currentYear), String.valueOf(currentMonth)}, (String)null, (String)null, (String)null);

        while(cursor.moveToNext()) {
            int tagID = cursor.getInt(cursor.getColumnIndex("tagID"));
            int year = cursor.getInt(cursor.getColumnIndex("year"));
            int month = cursor.getInt(cursor.getColumnIndex("month"));
            int day = cursor.getInt(cursor.getColumnIndex("day"));
            int scheduleID = cursor.getInt(cursor.getColumnIndex("scheduleID"));
            ScheduleDateTag dateTag = new ScheduleDateTag(tagID, year, month, day, scheduleID);
            dateTagList.add(dateTag);
        }
    
        cursor.close();
        return dateTagList != null && dateTagList.size() > 0?dateTagList:null;
    }
    
    public String[] getScheduleByTagDate(int year, int month, int day) {
        new ArrayList();
        SQLiteDatabase db = this.dbOpenHelper.getReadableDatabase();
        Cursor cursor = db.query("scheduletagdate", new String[]{"scheduleID"}, "year=? and month=? and day=?", new String[]{String.valueOf(year), String.valueOf(month), String.valueOf(day)}, (String)null, (String)null, (String)null);
        String[] scheduleIDs = (String[])null;
        scheduleIDs = new String[cursor.getCount()];
    
        for(int i = 0; cursor.moveToNext(); ++i) {
            String scheduleID = cursor.getString(cursor.getColumnIndex("scheduleID"));
            scheduleIDs[i] = scheduleID;
        }
    
        cursor.close();
        return scheduleIDs;
    }
    
    public void destoryDB() {
        if(this.dbOpenHelper != null) {
            this.dbOpenHelper.close();
        }
    
    }
    

    }

    public ScheduleVO getScheduleByID(int scheduleID) {
    SQLiteDatabase db = this.dbOpenHelper.getWritableDatabase();
    Cursor cursor = db.query("schedule", new String[]{"scheduleID", "scheduleTypeID", "remindID", "scheduleContent", "scheduleDate"}, "scheduleID=?", new String[]{String.valueOf(scheduleID)}, (String)null, (String)null, (String)null);
    if(cursor.moveToFirst()) {
    int schID = cursor.getInt(cursor.getColumnIndex("scheduleID"));
    int scheduleTypeID = cursor.getInt(cursor.getColumnIndex("scheduleTypeID"));
    int remindID = cursor.getInt(cursor.getColumnIndex("remindID"));
    String scheduleContent = cursor.getString(cursor.getColumnIndex("scheduleContent"));
    String scheduleDate = cursor.getString(cursor.getColumnIndex("scheduleDate"));
    cursor.close();
    return new ScheduleVO(schID, scheduleTypeID, remindID, scheduleContent, scheduleDate);
    } else {
    cursor.close();
    return null;
    }
    }

    public ArrayList<ScheduleVO> getAllSchedule() {
        ArrayList list = new ArrayList();
        SQLiteDatabase db = this.dbOpenHelper.getReadableDatabase();
        Cursor cursor = db.query("schedule", new String[]{"scheduleID", "scheduleTypeID", "remindID", "scheduleContent", "scheduleDate"}, (String)null, (String[])null, (String)null, (String)null, "scheduleID desc");
    
        while(cursor.moveToNext()) {
            int scheduleID = cursor.getInt(cursor.getColumnIndex("scheduleID"));
            int scheduleTypeID = cursor.getInt(cursor.getColumnIndex("scheduleTypeID"));
            int remindID = cursor.getInt(cursor.getColumnIndex("remindID"));
            String scheduleContent = cursor.getString(cursor.getColumnIndex("scheduleContent"));
            String scheduleDate = cursor.getString(cursor.getColumnIndex("scheduleDate"));
            ScheduleVO vo = new ScheduleVO(scheduleID, scheduleTypeID, remindID, scheduleContent, scheduleDate);
            list.add(vo);
        }
    
        cursor.close();
        return list != null && list.size() > 0?list:null;
    }
    
    public void delete(int scheduleID) {
        SQLiteDatabase db = this.dbOpenHelper.getWritableDatabase();
        db.beginTransaction();
    
        try {
            db.delete("schedule", "scheduleID=?", new String[]{String.valueOf(scheduleID)});
            db.delete("scheduletagdate", "scheduleID=?", new String[]{String.valueOf(scheduleID)});
            db.setTransactionSuccessful();
        } finally {
            db.endTransaction();
        }
    
    }
    
    public void update(ScheduleVO vo) {
        SQLiteDatabase db = this.dbOpenHelper.getWritableDatabase();
        ContentValues values = new ContentValues();
        values.put("scheduleTypeID", Integer.valueOf(vo.getScheduleTypeID()));
        values.put("remindID", Integer.valueOf(vo.getRemindID()));
        values.put("scheduleContent", vo.getScheduleContent());
        values.put("scheduleDate", vo.getScheduleDate());
        db.update("schedule", values, "scheduleID=?", new String[]{String.valueOf(vo.getScheduleID())});
    }
    
    public void saveTagDate(ArrayList<ScheduleDateTag> dateTagList) {
        SQLiteDatabase db = this.dbOpenHelper.getWritableDatabase();
        new ScheduleDateTag();
    
        for(int i = 0; i < dateTagList.size(); ++i) {
            ScheduleDateTag dateTag = (ScheduleDateTag)dateTagList.get(i);
            ContentValues values = new ContentValues();
            values.put("year", Integer.valueOf(dateTag.getYear()));
            values.put("month", Integer.valueOf(dateTag.getMonth()));
            values.put("day", Integer.valueOf(dateTag.getDay()));
            values.put("scheduleID", Integer.valueOf(dateTag.getScheduleID()));
            db.insert("scheduletagdate", (String)null, values);
        }
    
    }
    

    ---恢复内容结束---

    / // Source code recreated from a .class file by IntelliJ IDEA // (powered by Fernflower decompiler) //

    package com.pwp.dao;

    import android.content.ContentValues;
    import android.content.Context;
    import android.database.Cursor;
    import android.database.sqlite.SQLiteDatabase;
    import com.pwp.dao.DBOpenHelper;
    import com.pwp.vo.ScheduleDateTag;
    import com.pwp.vo.ScheduleVO;
    import java.util.ArrayList;

    public class ScheduleDAO {
    private DBOpenHelper dbOpenHelper = null;

    public ScheduleDAO(Context context) {
        this.dbOpenHelper = new DBOpenHelper(context, "schedules.db");
    }
    
    public int save(ScheduleVO scheduleVO) {
        SQLiteDatabase db = this.dbOpenHelper.getWritableDatabase();
        ContentValues values = new ContentValues();
        values.put("scheduleTypeID", Integer.valueOf(scheduleVO.getScheduleTypeID()));
        values.put("remindID", Integer.valueOf(scheduleVO.getRemindID()));
        values.put("scheduleContent", scheduleVO.getScheduleContent());
        values.put("scheduleDate", scheduleVO.getScheduleDate());
        db.beginTransaction();
        int scheduleID = -1;
    
        try {
            db.insert("schedule", (String)null, values);
            Cursor cursor = db.rawQuery("select max(scheduleID) from schedule", (String[])null);
            if(cursor.moveToFirst()) {
                scheduleID = (int)cursor.getLong(0);
            }
    
            cursor.close();
            db.setTransactionSuccessful();
        } finally {
            db.endTransaction();
        }
    
        return scheduleID;
    }
    

    public ArrayList getTagDate(int currentYear, int currentMonth) {
    ArrayList dateTagList = new ArrayList();
    SQLiteDatabase db = this.dbOpenHelper.getReadableDatabase();
    Cursor cursor = db.query("scheduletagdate", new String[]{"tagID", "year", "month", "day", "scheduleID"}, "year=? and month=?", new String[]{String.valueOf(currentYear), String.valueOf(currentMonth)}, (String)null, (String)null, (String)null);

        while(cursor.moveToNext()) {
            int tagID = cursor.getInt(cursor.getColumnIndex("tagID"));
            int year = cursor.getInt(cursor.getColumnIndex("year"));
            int month = cursor.getInt(cursor.getColumnIndex("month"));
            int day = cursor.getInt(cursor.getColumnIndex("day"));
            int scheduleID = cursor.getInt(cursor.getColumnIndex("scheduleID"));
            ScheduleDateTag dateTag = new ScheduleDateTag(tagID, year, month, day, scheduleID);
            dateTagList.add(dateTag);
        }
    
        cursor.close();
        return dateTagList != null && dateTagList.size() > 0?dateTagList:null;
    }
    
    public String[] getScheduleByTagDate(int year, int month, int day) {
        new ArrayList();
        SQLiteDatabase db = this.dbOpenHelper.getReadableDatabase();
        Cursor cursor = db.query("scheduletagdate", new String[]{"scheduleID"}, "year=? and month=? and day=?", new String[]{String.valueOf(year), String.valueOf(month), String.valueOf(day)}, (String)null, (String)null, (String)null);
        String[] scheduleIDs = (String[])null;
        scheduleIDs = new String[cursor.getCount()];
    
        for(int i = 0; cursor.moveToNext(); ++i) {
            String scheduleID = cursor.getString(cursor.getColumnIndex("scheduleID"));
            scheduleIDs[i] = scheduleID;
        }
    
        cursor.close();
        return scheduleIDs;
    }
    
    public void destoryDB() {
        if(this.dbOpenHelper != null) {
            this.dbOpenHelper.close();
        }
    
    }
    

    }

    public ScheduleVO getScheduleByID(int scheduleID) {
    SQLiteDatabase db = this.dbOpenHelper.getWritableDatabase();
    Cursor cursor = db.query("schedule", new String[]{"scheduleID", "scheduleTypeID", "remindID", "scheduleContent", "scheduleDate"}, "scheduleID=?", new String[]{String.valueOf(scheduleID)}, (String)null, (String)null, (String)null);
    if(cursor.moveToFirst()) {
    int schID = cursor.getInt(cursor.getColumnIndex("scheduleID"));
    int scheduleTypeID = cursor.getInt(cursor.getColumnIndex("scheduleTypeID"));
    int remindID = cursor.getInt(cursor.getColumnIndex("remindID"));
    String scheduleContent = cursor.getString(cursor.getColumnIndex("scheduleContent"));
    String scheduleDate = cursor.getString(cursor.getColumnIndex("scheduleDate"));
    cursor.close();
    return new ScheduleVO(schID, scheduleTypeID, remindID, scheduleContent, scheduleDate);
    } else {
    cursor.close();
    return null;
    }
    }

    public ArrayList<ScheduleVO> getAllSchedule() {
        ArrayList list = new ArrayList();
        SQLiteDatabase db = this.dbOpenHelper.getReadableDatabase();
        Cursor cursor = db.query("schedule", new String[]{"scheduleID", "scheduleTypeID", "remindID", "scheduleContent", "scheduleDate"}, (String)null, (String[])null, (String)null, (String)null, "scheduleID desc");
    
        while(cursor.moveToNext()) {
            int scheduleID = cursor.getInt(cursor.getColumnIndex("scheduleID"));
            int scheduleTypeID = cursor.getInt(cursor.getColumnIndex("scheduleTypeID"));
            int remindID = cursor.getInt(cursor.getColumnIndex("remindID"));
            String scheduleContent = cursor.getString(cursor.getColumnIndex("scheduleContent"));
            String scheduleDate = cursor.getString(cursor.getColumnIndex("scheduleDate"));
            ScheduleVO vo = new ScheduleVO(scheduleID, scheduleTypeID, remindID, scheduleContent, scheduleDate);
            list.add(vo);
        }
    
        cursor.close();
        return list != null && list.size() > 0?list:null;
    }
    
    public void delete(int scheduleID) {
        SQLiteDatabase db = this.dbOpenHelper.getWritableDatabase();
        db.beginTransaction();
    
        try {
            db.delete("schedule", "scheduleID=?", new String[]{String.valueOf(scheduleID)});
            db.delete("scheduletagdate", "scheduleID=?", new String[]{String.valueOf(scheduleID)});
            db.setTransactionSuccessful();
        } finally {
            db.endTransaction();
        }
    
    }
    
    public void update(ScheduleVO vo) {
        SQLiteDatabase db = this.dbOpenHelper.getWritableDatabase();
        ContentValues values = new ContentValues();
        values.put("scheduleTypeID", Integer.valueOf(vo.getScheduleTypeID()));
        values.put("remindID", Integer.valueOf(vo.getRemindID()));
        values.put("scheduleContent", vo.getScheduleContent());
        values.put("scheduleDate", vo.getScheduleDate());
        db.update("schedule", values, "scheduleID=?", new String[]{String.valueOf(vo.getScheduleID())});
    }
    
    public void saveTagDate(ArrayList<ScheduleDateTag> dateTagList) {
        SQLiteDatabase db = this.dbOpenHelper.getWritableDatabase();
        new ScheduleDateTag();
    
        for(int i = 0; i < dateTagList.size(); ++i) {
            ScheduleDateTag dateTag = (ScheduleDateTag)dateTagList.get(i);
            ContentValues values = new ContentValues();
            values.put("year", Integer.valueOf(dateTag.getYear()));
            values.put("month", Integer.valueOf(dateTag.getMonth()));
            values.put("day", Integer.valueOf(dateTag.getDay()));
            values.put("scheduleID", Integer.valueOf(dateTag.getScheduleID()));
            db.insert("scheduletagdate", (String)null, values);
        }
    
    }
  • 相关阅读:
    Oracle学习
    WPF中获取DataGrid列表的选中行Id的方法
    调用MySql存储过程的方法 '增删改查'
    MySql中存储过程的基本增删改查操作
    在WinForm中遍历获取TreeView的节点及其子节点
    WinForm获取MySql数据的基本增删改查
    WinForm中的用户控件实现分页功能
    NGUI之自适应屏幕
    快速排序法
    Array,ArrayList、List<T>、HashSet<T>、LinkedList<T>与Dictionary<K,V>
  • 原文地址:https://www.cnblogs.com/whm1996/p/7045565.html
Copyright © 2011-2022 走看看