|
|
@@ -45,6 +45,7 @@ public class DBManager {
|
|
|
String sql = "replace into B2BMSG"
|
|
|
+ "(b2b_content,b2b_time,b2b_hasRead,b2b_master)"
|
|
|
+ " values (?, ?, ?, ?);";
|
|
|
+ if (!db.isOpen())return ;
|
|
|
SQLiteStatement sta = db.compileStatement(sql);
|
|
|
sta.bindString(1, entity.getContent());
|
|
|
sta.bindString(2, entity.getTime());
|
|
|
@@ -59,6 +60,7 @@ public class DBManager {
|
|
|
String groupBy = null;
|
|
|
String having = null;
|
|
|
String orderBy = " b2b_hasRead,b2b_time DESC";
|
|
|
+ if (!db.isOpen())return entity;
|
|
|
Cursor cursor = db.query(table, null, selection, selectionArgs, groupBy, having, orderBy);
|
|
|
while (cursor.moveToNext()) {
|
|
|
B2BMsg model = new B2BMsg();
|
|
|
@@ -79,6 +81,7 @@ public class DBManager {
|
|
|
String sql = "update B2BMSG"
|
|
|
+ " set b2b_hasRead=?"
|
|
|
+ " where id=? and b2b_master=? ;";
|
|
|
+ if (!db.isOpen())return ;
|
|
|
SQLiteStatement sta = db.compileStatement(sql);
|
|
|
sta.bindLong(1, data.getHasRead());
|
|
|
sta.bindLong(2, data.getId());
|
|
|
@@ -90,6 +93,7 @@ public class DBManager {
|
|
|
String table = "B2BMSG";
|
|
|
String[] whereArgs = {String.valueOf(data.getId()), data.getMaster()};
|
|
|
String whereClause = "id=? and b2b_master=? ";
|
|
|
+ if (!db.isOpen())return ;
|
|
|
db.delete(table, whereClause, whereArgs);
|
|
|
}
|
|
|
|
|
|
@@ -101,6 +105,7 @@ public class DBManager {
|
|
|
String sql = "replace into hrorgs"
|
|
|
+ "(or_code,whichsys,or_subof,company,or_isleaf,or_name,or_id,or_flag,or_headmanname,or_headmancode,or_remark)"
|
|
|
+ " values (?, ?, ?, ?, ?, ?, ?,?,?,?,?);";
|
|
|
+ if (!db.isOpen())return ;
|
|
|
SQLiteStatement sta = db.compileStatement(sql);
|
|
|
db.beginTransaction();
|
|
|
for (int i = 0; i < hrorgsList.size(); i++) {
|
|
|
@@ -131,6 +136,7 @@ public class DBManager {
|
|
|
String sql = "update hrorgs"
|
|
|
+ " set or_remark=?"
|
|
|
+ " where or_id=? and whichsys=?;";
|
|
|
+ if (!db.isOpen())return ;
|
|
|
SQLiteStatement sta = db.compileStatement(sql);
|
|
|
sta.bindLong(1, or_remark);
|
|
|
sta.bindLong(2, or_id);//更新关键字段
|
|
|
@@ -146,6 +152,7 @@ public class DBManager {
|
|
|
String sql = "update hrorgs"
|
|
|
+ " set or_code=?,whichsys=?,or_subof=?,company=?,or_isleaf=?,or_name=?,or_id=?,or_flag=?"
|
|
|
+ " where or_code=?;";
|
|
|
+ if (!db.isOpen())return ;
|
|
|
SQLiteStatement sta = db.compileStatement(sql);
|
|
|
db.beginTransaction();
|
|
|
for (int i = 0; i < hrorgsList.size(); i++) {
|
|
|
@@ -173,6 +180,7 @@ public class DBManager {
|
|
|
*/
|
|
|
public void saveEmployees(List<EmployeesEntity> employeesEntities) {
|
|
|
String sql = "replace into employees(EM_ID,EM_CODE,EM_NAME,EM_POSITION,EM_DEFAULTORNAME,EM_DEPART,EM_MOBILE,EM_UU,COMPANY,WHICHSYS,Em_defaultorid,Em_flag,Em_imid,EM_EMAIL) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?);";
|
|
|
+ if (!db.isOpen())return ;
|
|
|
SQLiteStatement sta = db.compileStatement(sql);
|
|
|
db.beginTransaction();
|
|
|
for (int i = 0; i < employeesEntities.size(); i++) {
|
|
|
@@ -205,6 +213,7 @@ public class DBManager {
|
|
|
String sql = "update employees"
|
|
|
+ " set EM_ID=?,EM_CODE=?,EM_NAME=?,EM_POSITION=?,EM_DEFAULTORNAME=?,EM_DEPART=?,EM_MOBILE=?,EM_UU=?,COMPANY=?,WHICHSYS=?,Em_defaultorid=?,Em_flag=?"
|
|
|
+ " where EM_CODE=?;";
|
|
|
+ if (!db.isOpen())return ;
|
|
|
SQLiteStatement sta = db.compileStatement(sql);
|
|
|
db.beginTransaction();
|
|
|
for (int i = 0; i < employeesEntities.size(); i++) {
|
|
|
@@ -237,6 +246,7 @@ public class DBManager {
|
|
|
String sql = "insert into empdate"
|
|
|
+ "(ed_lastdate,ed_kind,ed_company,ed_whichsys)"
|
|
|
+ " values (?, ?, ?, ?);";
|
|
|
+ if (!db.isOpen())return ;
|
|
|
SQLiteStatement sta = db.compileStatement(sql);
|
|
|
|
|
|
sta.bindString(1, data.get("ed_lastdate").toString());
|
|
|
@@ -255,6 +265,7 @@ public class DBManager {
|
|
|
String sql = "update empdate"
|
|
|
+ " set ed_lastdate=?"
|
|
|
+ " where ed_kind=? and ed_company=? and ed_whichsys=?;";
|
|
|
+ if (!db.isOpen())return ;
|
|
|
SQLiteStatement sta = db.compileStatement(sql);
|
|
|
sta.bindString(1, data.get("ed_lastdate").toString());
|
|
|
sta.bindString(2, data.get("ed_kind").toString());
|
|
|
@@ -274,6 +285,7 @@ public class DBManager {
|
|
|
String groupBy = null;
|
|
|
String having = null;
|
|
|
String orderBy = null;
|
|
|
+ if (!db.isOpen())return null;
|
|
|
Cursor cursor = db.query(table, columns, where, selectionArgs, groupBy, having, orderBy);
|
|
|
while (cursor.moveToNext()) {
|
|
|
datestr = cursor.getString(cursor.getColumnIndex("ed_lastdate"));
|
|
|
@@ -290,6 +302,7 @@ public class DBManager {
|
|
|
String table = "employees";
|
|
|
String whereClause = "em_flag=?";
|
|
|
String[] whereArgs = {"DELETE"};
|
|
|
+ if (!db.isOpen())return ;
|
|
|
db.delete(table, whereClause, whereArgs);
|
|
|
|
|
|
table = "hrorgs";
|
|
|
@@ -311,6 +324,7 @@ public class DBManager {
|
|
|
String groupBy = null;
|
|
|
String having = null;
|
|
|
String orderBy = null;
|
|
|
+ if (!db.isOpen())return hrorgsEntities;
|
|
|
Cursor cursor = db.query(table, columns, selection, selectionArgs, groupBy, having, orderBy);
|
|
|
while (cursor.moveToNext()) {
|
|
|
Hrorgs.HrorgItem hrorgItem = new Hrorgs().new HrorgItem();
|
|
|
@@ -362,6 +376,7 @@ public class DBManager {
|
|
|
// String having = null;
|
|
|
// String orderBy = null;
|
|
|
//db.query(table, columns, selection, selectionArgs, groupBy, having, orderBy);
|
|
|
+ if (!db.isOpen())return 0;
|
|
|
Cursor cursor =
|
|
|
db.rawQuery("select count(*) from employees where em_defaultorid=? and WHICHSYS=?", selectionArgs);
|
|
|
if (cursor.moveToFirst()) {
|
|
|
@@ -377,6 +392,7 @@ public class DBManager {
|
|
|
String table = "hrorgs";
|
|
|
String[] whereArgs = {master};
|
|
|
String whereClause = "whichsys=?";
|
|
|
+ if (!db.isOpen())return ;
|
|
|
db.delete(table, whereClause, whereArgs);
|
|
|
table = "employees";
|
|
|
db.delete(table, whereClause, whereArgs);
|
|
|
@@ -395,6 +411,7 @@ public class DBManager {
|
|
|
String groupBy = null;
|
|
|
String having = null;
|
|
|
String orderBy = null;
|
|
|
+ if (!db.isOpen())return hrorgsEntities;
|
|
|
Cursor cursor = db.query(table, columns, selection, selectionArgs, groupBy, having, orderBy);
|
|
|
while (cursor.moveToNext()) {
|
|
|
hrorgsEntities = new HrorgsEntity();
|
|
|
@@ -427,6 +444,7 @@ public class DBManager {
|
|
|
String groupBy = null;
|
|
|
String having = null;
|
|
|
String orderBy = null;
|
|
|
+ if (!db.isOpen())return hrorgsEntities;
|
|
|
Cursor cursor = db.query(table, columns, selection, selectionArgs, groupBy, having, orderBy);
|
|
|
while (cursor.moveToNext()) {
|
|
|
HrorgsEntity hrorgsEntity = new HrorgsEntity();
|
|
|
@@ -496,8 +514,10 @@ public class DBManager {
|
|
|
for (String e : selectionArgs) {
|
|
|
Log.i("todo", "e=" + e);
|
|
|
}
|
|
|
- Cursor cursor = db.query(table, null, selection, selectionArgs, groupBy, having, orderBy);
|
|
|
EmployeesEntity model = null;
|
|
|
+ if (!db.isOpen())return model;
|
|
|
+ Cursor cursor = db.query(table, null, selection, selectionArgs, groupBy, having, orderBy);
|
|
|
+
|
|
|
Log.i("todo", "e数据为空");
|
|
|
while (cursor.moveToNext()) {
|
|
|
Log.i("todo", "cursor.moveToNext()");
|
|
|
@@ -538,6 +558,7 @@ public class DBManager {
|
|
|
}*/
|
|
|
public void saveListToAllSubs(List<SubscriptionNumber> subscriptionNumbers) {
|
|
|
String saveSql = "replace into AllSubs(subs_id,subs_title,subs_kind,subs_status,subs_type,subs_master,subs_username,subs_removed,subs_img) values (?,?,?,?,?,?,?,?,?)";
|
|
|
+ if (!db.isOpen())return ;
|
|
|
SQLiteStatement sqLiteStatement = db.compileStatement(saveSql);
|
|
|
for (int i = 0; i < subscriptionNumbers.size(); i++) {
|
|
|
SubscriptionNumber subscriptionNumber = subscriptionNumbers.get(i);
|
|
|
@@ -561,6 +582,7 @@ public class DBManager {
|
|
|
String groupBy = null;
|
|
|
String having = null;
|
|
|
String orderBy = null;
|
|
|
+ if (!db.isOpen())return subscriptionNumbers;
|
|
|
Cursor cursor = db.query(table, null, selection, selectionArgs, groupBy, having, orderBy);
|
|
|
while (cursor.moveToNext()) {
|
|
|
SubscriptionNumber subscriptionNumber = new SubscriptionNumber();
|
|
|
@@ -585,6 +607,7 @@ public class DBManager {
|
|
|
String sql = "update AllSubs"
|
|
|
+ " set subs_status=?, subs_removed=? "
|
|
|
+ " where subs_id=? and subs_master=? and subs_username=? ;";
|
|
|
+ if (!db.isOpen())return ;
|
|
|
SQLiteStatement sta = db.compileStatement(sql);
|
|
|
sta.bindLong(1, subscriptionNumber.getStatus());
|
|
|
sta.bindLong(2, subscriptionNumber.getRemoved());
|
|
|
@@ -598,6 +621,7 @@ public class DBManager {
|
|
|
String sql = "update AllSubs"
|
|
|
+ " set subs_status=?, subs_removed=? "
|
|
|
+ " where subs_id=? and subs_master=? and subs_username=? ;";
|
|
|
+ if (!db.isOpen())return ;
|
|
|
SQLiteStatement sta = db.compileStatement(sql);
|
|
|
|
|
|
for (int i = 0; i < subscriptionNumbers.size(); i++) {
|
|
|
@@ -633,6 +657,7 @@ public class DBManager {
|
|
|
String table = "AllSubs";
|
|
|
String[] whereArgs = {master, username};
|
|
|
String whereClause = "subs_master=? and subs_username=? ";
|
|
|
+ if (!db.isOpen())return ;
|
|
|
db.delete(table, whereClause, whereArgs);
|
|
|
}
|
|
|
|
|
|
@@ -655,6 +680,7 @@ public class DBManager {
|
|
|
|
|
|
public void saveListToMySubs(List<PersonalSubscriptionBean> personalSubscriptionBeans) {
|
|
|
String saveSql = "replace into MySubs(subs_id,subs_title,subs_kind,subs_type,subs_applied,subs_master,subs_username,subs_img) values (?,?,?,?,?,?,?,?)";
|
|
|
+ if (!db.isOpen())return ;
|
|
|
SQLiteStatement sqLiteStatement = db.compileStatement(saveSql);
|
|
|
for (int i = 0; i < personalSubscriptionBeans.size(); i++) {
|
|
|
PersonalSubscriptionBean personalSubscriptionBean = personalSubscriptionBeans.get(i);
|
|
|
@@ -676,6 +702,7 @@ public class DBManager {
|
|
|
String groupBy = null;
|
|
|
String having = null;
|
|
|
String orderBy = null;
|
|
|
+ if (!db.isOpen())return personalSubscriptionBeans;
|
|
|
Cursor cursor = db.query(table, null, selection, selectionArgs, groupBy, having, orderBy);
|
|
|
while (cursor.moveToNext()) {
|
|
|
PersonalSubscriptionBean personalSubscriptionBean = new PersonalSubscriptionBean();
|
|
|
@@ -711,6 +738,7 @@ public class DBManager {
|
|
|
String table = "MySubs";
|
|
|
String[] whereArgs = {String.valueOf(personalSubscriptionBean.getNUM_ID()), personalSubscriptionBean.getMASTER(), personalSubscriptionBean.getUSERNAME()};
|
|
|
String whereClause = "subs_id=? and subs_master=? and subs_username=? ";
|
|
|
+ if (!db.isOpen())return ;
|
|
|
db.delete(table, whereClause, whereArgs);
|
|
|
}
|
|
|
|
|
|
@@ -728,6 +756,7 @@ public class DBManager {
|
|
|
String table = "MySubs";
|
|
|
String[] whereArgs = {master, username};
|
|
|
String whereClause = "subs_master=? and subs_username=? ";
|
|
|
+ if (!db.isOpen())return ;
|
|
|
db.delete(table, whereClause, whereArgs);
|
|
|
}
|
|
|
|