sujinwen
2017-07-24 254191b0a6e9e9843791e80666b802cd01fec9eb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package cn.com.basic.face.service.sqlite;
 
import android.database.Cursor;
 
import java.util.ArrayList;
import java.util.List;
 
import cn.com.basic.face.base.MainActivity;
import cn.com.basic.face.discern.entity.Employee;
 
/**
 * Created by SJW on 2017/7/24 0024.
 */
 
public class EmployeeDao {
 
    public static EmployeeDao instance=new EmployeeDao();
    public static EmployeeDao getInstance(){
        return instance;
    }
 
 
    //加载需要同步的数据
    public List<Employee> getEmployeeList(String deviceCompanyId){
        String sql="select * from employee where is_synchron='N' and device_company_id="+Integer.parseInt(deviceCompanyId);
        Cursor c = MainActivity.getInstance().db.rawQuery(sql,new String[]{});
        List<Employee> result=new ArrayList<Employee>();
        Employee emp=null;
        if(c.moveToFirst()){
            emp=new Employee();
            emp.setIsSynchron(c.getString(c.getColumnIndex("is_synchron")));
            emp.setUpdateTime(c.getString(c.getColumnIndex("update_time")));
            emp.setDeviceCompanyId(c.getString(c.getColumnIndex("device_company_id")));
            emp.setRegisterId(c.getString(c.getColumnIndex("register_id")));
            result.add(emp);
        }
        return result;
    }
 
    //删除已经上传到服务器的数据
    public void delEmployee(String deviceCompanyId){
        String sql="delete from employee where is_synchron='N' and device_company_id="+Integer.parseInt(deviceCompanyId);
        MainActivity.getInstance().db.execSQL(sql);
 
    }
}