基于安卓平台开发的学生考勤管理系统,本系统采用java语言设计,数据存储使用SQLite轻量级数据库实现
SQLite 简介
SQLite是一个软件库,实现了自给自足的、无服务器的、零配置的、事务性的 SQL 数据库引擎。SQLite是一个增长最快的数据库引擎,这是在普及方面的增长,与它的尺寸大小无关。SQLite 源代码不受版权限制。
什么是 SQLite?
SQLite是一个进程内的库,实现了自给自足的、无服务器的、零配置的、事务性的 SQL 数据库引擎。它是一个零配置的数据库,这意味着与其他数据库不一样,您不需要在系统中配置。
就像其他数据库,SQLite 引擎不是一个独立的进程,可以按应用程序需求进行静态或动态连接。SQLite 直接访问其存储文件。
为什么要用 SQLite?
-
不需要一个单独的服务器进程或操作的系统(无服务器的)。
-
SQLite 不需要配置,这意味着不需要安装或管理。
-
一个完整的 SQLite 数据库是存储在一个单一的跨平台的磁盘文件。
-
SQLite 是非常小的,是轻量级的,完全配置时小于 400KiB,省略可选功能配置时小于250KiB。
-
SQLite 是自给自足的,这意味着不需要任何外部的依赖。
教师(管理远端): (登录,注册,班级管理,学生管理,课程管理,签到管理,请假管理,个人中心)
学生端: (我要请假,考勤签到)
部分核心代码
注册页面
/**
* 注册
*/
public class RegisterActivity extends BaseActivity {
private static final String TAG = "RegisterActivity";
private Toolbar mToolbar;
private AppCompatEditText et_user_name, et_user_pswd;
private UserDao mUserInfoDao;
@Override
protected int getLayoutId() {
return R.layout.activity_register;
}
@Override
protected void initViews() {
mToolbar = findViewById(R.id.toolbar);
et_user_name = findViewById(R.id.et_user_name);
et_user_pswd = findViewById(R.id.et_user_pswd);
if (mUserInfoDao == null) {
mUserInfoDao = new UserDao(this);
}
}
@Override
protected void setListener() {
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
@Override
protected void initData() {
findViewById(R.id.btn_register).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String name = et_user_name.getText().toString().trim();
String pawsd = et_user_pswd.getText().toString().trim();
if (TextUtils.isEmpty(name)) {
BastToast("请输入用户名");
} else if (TextUtils.isEmpty(pawsd)) {
BastToast("请输入密码");
} else {
int insert = mUserInfoDao.insert(name, pawsd, "", "今天你微笑了吗", "90分", "上海市", "北京市", "教师", "未婚", "xxx","xxx");
if (insert != -1) {
BastToast("注册成功");
finish();
} else {
BastToast("注册失败");
}
}
}
});
}
}
学生管理页面
public class StudentActivity extends BaseActivity {
static final int CODE = 200;
private Toolbar mToolbar;
private RecyclerView mRecyclerView;
private DelateDialog mDelateDialog;
private StudentAdapter mStudentAdapter;
private StudioDao mStudioDao;
@Override
protected int getLayoutId() {
return R.layout.activity_student;
}
@Override
protected void initViews() {
if (mStudioDao == null) {
mStudioDao = new StudioDao(this);
}
mToolbar = findViewById(R.id.toolbar);
mRecyclerView = findViewById(R.id.recyclerView);
mStudentAdapter = new StudentAdapter();
mRecyclerView.setAdapter(mStudentAdapter);
showLoading();
}
@Override
protected void setListener() {
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
findViewById(R.id.btn_add).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivityForResult(new Intent(StudentActivity.this, AddStudentActivity.class), CODE);
}
});
mStudentAdapter.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
Intent intent = new Intent(StudentActivity.this, UpdateStudentActivity.class);
intent.putExtra("info", mStudioDao.queryAll().get(position));
startActivityForResult(intent, CODE);
}
});
mStudentAdapter.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(@NonNull BaseQuickAdapter adapter, @NonNull View view, int position) {
StudentBean bean = mStudioDao.queryAll().get(position);
if (mDelateDialog == null) {
mDelateDialog = new DelateDialog(StudentActivity.this);
}
mDelateDialog.setDelateListener(new DelateDialog.DelateListener() {
@Override
public void delate() {
int delate = mStudioDao.delate(bean.getStudent_name());
if (delate == 1) {
BastToast("删除成功");
} else {
BastToast("删除失败");
}
mDelateDialog.dismiss();
mStudentAdapter.setNewInstance(mStudioDao.queryAll());
}
});
mDelateDialog.show();
return false;
}
});
}
@Override
protected void initData() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mStudentAdapter.setNewInstance(mStudioDao.queryAll());
hiddenDialog();
}
}, 200);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (data != null && resultCode == CODE) {
mStudentAdapter.setNewInstance(mStudioDao.queryAll());
}
}
}
个人中心页面
public class CenterActivity extends BaseActivity {
private TextView username, signature, credit, home, hometown, professional, status, school, school_scl;
private TextView edit;
@Override
protected int getLayoutId() {
return R.layout.activity_center;
}
@Override
protected void initViews() {
signature = findViewById(R.id.signature);
username = findViewById(R.id.username);
edit = findViewById(R.id.edit);
credit = findViewById(R.id.credit);
home = findViewById(R.id.home);
hometown = findViewById(R.id.hometown);
professional = findViewById(R.id.professional);
status = findViewById(R.id.status);
school = findViewById(R.id.school);
school_scl = findViewById(R.id.school_scl);
}
@Override
protected void setListener() {
edit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(CenterActivity.this, EditActivity.class);
startActivityForResult(intent, 200);
}
});
}
@SuppressLint("SetTextI18n")
@Override
protected void initData() {
UserInfo info = SPUtils.getObject(this, "userInfo", UserInfo.class);
if (null != info) {
signature.setText("个性签名:" + info.getSignature());
username.setText("用户名:" + info.getUserName());
credit.setText("信用:" + info.getCredit());
home.setText("所在地:" + info.getHome());
hometown.setText("家乡:" + info.getHometown());
professional.setText("职业:" + info.getProfessional());
status.setText("感情状况:" + info.getStatus());
school.setText("学校:" + info.getSchool());
school_scl.setText("专业:" + info.getSchool_scl());
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (null != data && resultCode == 200) {
initData();
}
}
}