Android学生信息管理系统APP

上传人:痛*** 文档编号:109167147 上传时间:2022-06-16 格式:DOC 页数:18 大小:89KB
收藏 版权申诉 举报 下载
Android学生信息管理系统APP_第1页
第1页 / 共18页
Android学生信息管理系统APP_第2页
第2页 / 共18页
Android学生信息管理系统APP_第3页
第3页 / 共18页
资源描述:

《Android学生信息管理系统APP》由会员分享,可在线阅读,更多相关《Android学生信息管理系统APP(18页珍藏版)》请在装配图网上搜索。

1、-Android学生信息管理系统APP一、 需求分析为了方便的进展对学生数据库的操作,本app可在android设备上进展对学生信息数据库的信息管理功能,具体功能如下:1.对数据库中所有学生*进展显示,对各个条目进展点击可展开具体信息2. 查询数据:查询数据是根据*与*两个条件进展查询,两者满足任一条件则进展模糊查询,两个条件同时满足则进展准确查询,查询结果界面与功能一中一样,以*排列,点击展开所有信息3. 增加数据:在数据库中增添条目,包括*字符串,*数字,主键,性别单项选择框,年龄数字,专业字符串。每个条目均有误输入设定,且主键可检查重复性,所有数据可检查完整性,假设插入成功则会显示一条消

2、息提示成功,假设失败则会提示检查主键重复或者数据不完整4. 修改数据:根据*进展准确查找,查找成功后转入修改界面,为了防止漏填与便捷修改界面会默认填充之前的数据除*,修改完毕即可更新,同样会检查数据完整性5. 删除数据:根据*进展准确查找,查找成功则会进展删除,并显示一条删除成功的提示,假设失败,也会进展提示二、 概念构造设计 ER图:三、 逻辑构造设计学生:*字符串*数字,主码性别单项选择框年龄数字专业字符串create table student(name TE*T,NO TE*T Primary Key,se* TE*T,profession TE*T,age TE*T)四、 具体实现1

3、.主界面:主界面显示所有功能,每个按钮点击后,跳转进入相应功能核心代码:publicclass Main e*tends Activity SQLiteDatabase db;Button btn_search;Button btn_modify;Button btn_add;Button btn_delete;Button btn_quit;Button btn_show;Overrideprotectedvoid onCreate(Bundle savedInstanceState) requestWindowFeature(Window.FEATURE_NO_TITLE);getWind

4、ow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);super.onCreate(savedInstanceState);setContentView(R.layout.layout_main);/翻开数据库,假设不存在,则创立db = SQLiteDatabase.openOrCreateDatabase(this.getFilesDir().toString()+/Student.db3, null);btn_search = (Butto

5、n) findViewById(R.id.btn_search);btn_modify = (Button) findViewById(R.id.btn_modify);btn_add = (Button) findViewById(R.id.btn_add);btn_delete = (Button) findViewById(R.id.btn_delete);btn_quit = (Button) findViewById(R.id.btn_quit);btn_show = (Button) findViewById(R.id.Btn_show);tryCursor cursor = db

6、.rawQuery(select * from student, null);cursor.close();catch(SQLiteE*ception e)db.e*ecSQL(create table student+ (+ name TE*T,+ NO TE*T Primary Key,+ se* TE*T,+ profession TE*T,+ age TE*T+ );/显示所有数据按钮的功能实现btn_show.setOnClickListener(new OnClickListener()publicvoid onClick(View source) /获取指针Cursor curs

7、or = db.rawQuery(select * from student, null);/判断数据库是否不存在任何数据if(cursor.moveToFirst() = false)Toast.makeTe*t(Main.this, 不存在记录, Toast.LENGTH_SHORT).show();elseList p = new ArrayList();List re_name = new ArrayList();List info = new ArrayList();/保存搜索出的所有数据for(cursor.moveToFirst() ; !cursor.isAfterLast()

8、 ; cursor.moveToNe*t()int nameColume = cursor.getColumnInde*(name);int NOColume = cursor.getColumnInde*(NO);int proColume = cursor.getColumnInde*(profession);int se*Colume = cursor.getColumnInde*(se*);int ageColume = cursor.getColumnInde*(age);Student student = new Student();student.name = *:+cursor

9、.getString(nameColume);student.NO = *:+cursor.getString(NOColume);student.se* = 性别:+cursor.getString(se*Colume);student.profession = 专业:+cursor.getString(proColume);student.age = 年龄:+cursor.getString(ageColume);p.add(student);String temp = student.MakeString();info.add(temp);String newname = cursor.

10、getString(nameColume);re_name.add(newname);/对保存的数据进展封装String Cur_name = new Stringre_name.size();Cur_name = re_name.toArray(Cur_name);String Cur_info = new Stringinfo.size();Cur_info = info.toArray(Cur_info);Bundle bundle = new Bundle();bundle.putStringArray(name, Cur_name);Student data = new Studen

11、t();data.info = Cur_info;/将封装的数据传递给结果界面的activityIntent intent =new Intent(Main.this,SearchResult.class);intent.putE*tras(bundle);intent.putE*tra(data, data);startActivity(intent);cursor.close(););/为剩下的按钮绑定监听器实现跳转功能btn_search.setOnClickListener(new OnClickListener()publicvoid onClick(View source) Int

12、ent intent = new Intent(Main.this,Search.class);startActivity(intent););btn_modify.setOnClickListener(new OnClickListener()publicvoid onClick(View source) Intent intent = new Intent(Main.this,Modify.class);startActivity(intent););btn_add.setOnClickListener(new OnClickListener()publicvoid onClick(Vie

13、w source) Intent intent = new Intent(Main.this,Add.class);startActivity(intent););btn_delete.setOnClickListener(new OnClickListener()publicvoid onClick(View source) Intent intent = new Intent(Main.this,Delete.class);startActivity(intent););btn_quit.setOnClickListener(new OnClickListener()publicvoid

14、onClick(View source) db.close();finish(););2. 数据显示界面:按*排列,点击条目展开具体信息核心代码:publicclass SearchResult e*tends ActivitySuppressLint(RtlHardcoded)publicvoid onCreate(Bundle savedInstanceState)requestWindowFeature(Window.FEATURE_NO_TITLE);getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, Win

15、dowManager.LayoutParams.FLAG_FULLSCREEN);/获取传送来的数据super.onCreate(savedInstanceState);setContentView(R.layout.layout_result);final Intent intent = getIntent();BaseE*pandableListAdapter adapter = new BaseE*pandableListAdapter()/提取数据Bundle bundle = intent.getE*tras();Student mem_data = (Student) getInt

16、ent().getE*tras().get(data);String people = (String) bundle.getSerializable(name);String data = mem_data.info;public Object getChild(int groupPosition,int childPosition)returndatagroupPositionchildPosition;publiclong getChildId(int groupPosition,int childPosition)return childPosition;publicint getCh

17、ildrenCount(int groupPosition)returndatagroupPosition.length;/设定每个子选项每行的显示方式private Te*tView getTe*tView()AbsListView.LayoutParams lp = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);Te*tView te*tView = new Te*tView(SearchResult.this);te*tView.

18、setLayoutParams(lp);te*tView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);te*tView.setPadding(36, 0, 0, 0);te*tView.setTe*tSize(20);return te*tView;/设定每个子选项显示内容public View getChildView(int groupPosition , int childPosition,boolean isLastChild,View convertView,ViewGroup Parent)Te*tView te*tView

19、 = getTe*tView();te*tView.setTe*t( +getChild(groupPosition,childPosition).toString();return te*tView;public Object getGroup(int groupPosition)returnpeoplegroupPosition;publicint getGroupCount()returnpeople.length;publiclong getGroupId(int groupPosition)return groupPosition;/设定每个组选项显示内容public View ge

20、tGroupView(int groupPosition, boolean isE*panded ,View convertView , ViewGroup parnet)LinearLayout ll = new LinearLayout(SearchResult.this);ll.setOrientation(0);Te*tView te*tView = getTe*tView();te*tView.setTe*t( +getGroup(groupPosition).toString();ll.addView(te*tView);return ll;E*pandableListView e

21、*pandListView = (E*pandableListView) findViewById(R.id.list);e*pandListView.setAdapter(adapter);3. 增添数据界面:根据文本框输入内容进展数据的插入,且具有完整性和重复性的判断,插入成功失败均会产生提示核心代码:publicclass Add e*tends Activity SQLiteDatabase db;Button btn_Accept;Button btn_Cancle;Te*tView ET_name;Te*tView ET_NO;Te*tView ET_Pro;Te*tView ET

22、_Age;RadioGroup rg;String radio_se* = 男;Overrideprotectedvoid onCreate(Bundle savedInstanceState) requestWindowFeature(Window.FEATURE_NO_TITLE);getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);super.onCreate(savedInstanceState);setContentVi

23、ew(R.layout.layout_add);db = SQLiteDatabase.openDatabase(this.getFilesDir().toString()+/Student.db3, null,SQLiteDatabase.OPEN_READWRITE);btn_Accept = (Button) findViewById(R.id.btn_Accept);btn_Cancle = (Button) findViewById(R.id.btn_Cancle);ET_name = (Te*tView) findViewById(R.id.ET_Add_name);ET_NO =

24、 (Te*tView) findViewById(R.id.ET_Add_NO);ET_Pro = (Te*tView) findViewById(R.id.ET_Add_Pro);ET_Age = (Te*tView) findViewById(R.id.ET_Add_Age);rg = (RadioGroup) findViewById(R.id.rg);rg.setOnCheckedChangeListener(new OnCheckedChangeListener()publicvoid onCheckedChanged(RadioGroup group, int CheckedId)

25、radio_se* = CheckedId = R.id.rad_male 男 : 女;);/提交操作btn_Accept.setOnClickListener(new OnClickListener()publicvoid onClick(View source) String name = ET_name.getTe*t().toString();String NO = ET_NO.getTe*t().toString();String se* = radio_se*;String pro = ET_Pro.getTe*t().toString();String age = ET_Age.

26、getTe*t().toString();/标准性与完整性判断try/插入数据db.e*ecSQL(insert into student values( , , , , ),new String name, NO, se*, pro, age);/标准性与完整性判断catch(SQLiteE*ception e)Toast.makeTe*t(Add.this, 插入数据失败,请检查数据标准性与*的唯一性, Toast.LENGTH_SHORT).show();return;Toast.makeTe*t(Add.this, 成功插入一条数据:+n+name+n+NO+n+se*+n+pro+n

27、+age, Toast.LENGTH_SHORT).show(););btn_Cancle.setOnClickListener(new OnClickListener()publicvoid onClick(View source) db.close();finish(););4. 修改数据界面:查找界面:对文本框内输入的数据进展准确查找,成功后转入修改界面修改界面:文本框内默认显示之前的数据,修改完成点击确定以文本框内的信息对数据进展更新核心代码:查找:btn_Accept.setOnClickListener(new OnClickListener()publicvoid onClick

28、(View source) String name = ET_Modify_Name.getTe*t().toString();String NO = ET_Modify_No.getTe*t().toString();Cursor cursor = db.rawQuery(select * from student where + name=+ and NO=, new String name, NO);/判断查找结果是否为空if(cursor.moveToFirst() = false)Toast.makeTe*t(Modify.this, 记录不存在, Toast.LENGTH_SHOR

29、T).show();elseString mem_name = null;String mem_No = null;String mem_profession = null;String mem_se* = null;String mem_age = null;/保存所有数据for(cursor.moveToFirst() ; !cursor.isAfterLast() ; cursor.moveToNe*t()int nameColume = cursor.getColumnInde*(name);int NoColume = cursor.getColumnInde*(NO);int pr

30、oColume = cursor.getColumnInde*(profession);int se*Colume = cursor.getColumnInde*(se*);int ageColume = cursor.getColumnInde*(age);mem_name = cursor.getString(nameColume);mem_No = cursor.getString(NoColume);mem_profession = cursor.getString(proColume);mem_se* = cursor.getString(se*Colume);mem_age = c

31、ursor.getString(ageColume);/封装所有数据Bundle bundle = new Bundle();bundle.putString(name, mem_name);bundle.putString(No, mem_No);bundle.putString(profession, mem_profession);bundle.putString(se*, mem_se*);bundle.putString(age, mem_age);/传递数据Intent intent = new Intent(Modify.this,ModifyResult.class);inte

32、nt.putE*tras(bundle);startActivity(intent);cursor.close(););btn_Cancle.setOnClickListener(new OnClickListener()publicvoid onClick(View source) / TODO Auto-generated method stubdb.close();finish(););修改:publicclass ModifyResult e*tends ActivitySQLiteDatabase db;Button btn_accept;Button btn_cancle;Te*t

33、View Te*tView_ModifyResult_No;EditTe*t ET_ModifyResult_Name;EditTe*t ET_ModifyResult_pro;EditTe*t ET_ModifyResult_age;RadioGroup rg;String radio_se*;protectedvoid onCreate(Bundle savedInstanceState)super.onCreate(savedInstanceState);setContentView(R.layout.layout_modifyresult);/获取数据final Intent inte

34、nt = getIntent();Bundle bundle = intent.getE*tras();db = SQLiteDatabase.openDatabase(this.getFilesDir().toString()+/Student.db3, null,SQLiteDatabase.OPEN_READWRITE);btn_accept = (Button) findViewById(R.id.btn_modifyresult_accept);btn_cancle = (Button) findViewById(R.id.btn_modifyresult_cancle);Te*tV

35、iew_ModifyResult_No = (Te*tView) findViewById(R.id.Te*tView_ModifyResult_No);ET_ModifyResult_Name = (EditTe*t) findViewById(R.id.ET_ModifyResult_Name);ET_ModifyResult_pro = (EditTe*t) findViewById(R.id.ET_ModifyResult_pro);ET_ModifyResult_age = (EditTe*t) findViewById(R.id.ET_ModifyResult_age);rg =

36、(RadioGroup) findViewById(R.id.modify_rg);/设定默认数据String name = bundle.getString(name);final String No = bundle.getString(No);String pro = bundle.getString(profession);String age = bundle.getString(age);radio_se* = bundle.getString(se*);Te*tView_ModifyResult_No.setTe*t(No);ET_ModifyResult_Name.setTe*

37、t(name);ET_ModifyResult_pro.setTe*t(pro);ET_ModifyResult_age.setTe*t(age);rg.setOnCheckedChangeListener(new OnCheckedChangeListener()publicvoid onCheckedChanged(RadioGroup group, int CheckedId)radio_se* = CheckedId = R.id.rad_male 男 : 女;);btn_accept.setOnClickListener(new OnClickListener()publicvoid

38、 onClick(View source) String new_name = ET_ModifyResult_Name.getTe*t().toString();String new_profession = ET_ModifyResult_pro.getTe*t().toString();String new_age = ET_ModifyResult_age.getTe*t().toString();String new_se* = radio_se*;/更新数据trydb.e*ecSQL(UPDATE student + SET name= ,NO= ,se*= ,profession

39、= ,age= + WHERE NO=,new String new_name , No , new_se* , new_profession , new_age , No);catch(SQLiteE*ception e)Toast.makeTe*t(ModifyResult.this, 更新数据失败, Toast.LENGTH_SHORT).show();return;Toast.makeTe*t(ModifyResult.this, 更新数据成功, Toast.LENGTH_SHORT).show();finish(););btn_cancle.setOnClickListener(ne

40、w OnClickListener()publicvoid onClick(View source) db.close();finish(););5. 查找数据界面:对文本框内的数据进展模糊查询,查询成功则跳转只查询结果界面,查询失败则产生相应提示核心代码:publicclass Search e*tends Activity SQLiteDatabase db;Button btn_Accept;Button btn_Cancle;EditTe*t ET_name;EditTe*t ET_NO;Overrideprotectedvoid onCreate(Bundle savedInstan

41、ceState) requestWindowFeature(Window.FEATURE_NO_TITLE);getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);super.onCreate(savedInstanceState);setContentView(R.layout.layout_search);db = SQLiteDatabase.openDatabase(this.getFilesDir().toString()

42、+/Student.db3, null,SQLiteDatabase.OPEN_READWRITE);btn_Accept = (Button) findViewById(R.id.btn_Accept);btn_Cancle = (Button) findViewById(R.id.btn_Cancle);ET_name = (EditTe*t) findViewById(R.id.ET_Search_name);ET_NO = (EditTe*t) findViewById(R.id.ET_Search_NO);btn_Accept.setOnClickListener(new OnCli

43、ckListener()publicvoid onClick(View source) String name = ET_name.getTe*t().toString();String NO = ET_NO.getTe*t().toString();/获取指针Cursor cursor = db.rawQuery(select * from student where + name=/+ or + name=+ or NO=/+ or + NO=, new String name, NO);/检验查找是否为空if(cursor.moveToFirst() = false)Toast.make

44、Te*t(Search.this, 记录不存在, Toast.LENGTH_SHORT).show();elseToast.makeTe*t(Search.this, 成功, Toast.LENGTH_SHORT).show();/return;List p = new ArrayList();List re_name = new ArrayList();List info = new ArrayList();/保存数据for(cursor.moveToFirst() ; !cursor.isAfterLast() ; cursor.moveToNe*t()int nameColume = c

45、ursor.getColumnInde*(name);int NOColume = cursor.getColumnInde*(NO);int proColume = cursor.getColumnInde*(profession);int se*Colume = cursor.getColumnInde*(se*);int ageColume = cursor.getColumnInde*(age);Student student = new Student();student.name = *:+cursor.getString(nameColume);student.NO = *:+c

46、ursor.getString(NOColume);student.se* = 性别:+cursor.getString(se*Colume);student.profession = 专业:+cursor.getString(proColume);student.age = 年龄:+cursor.getString(ageColume);p.add(student);String temp = student.MakeString();info.add(temp);String newname = cursor.getString(nameColume);re_name.add(newnam

47、e);/封装数据String Cur_name = new Stringre_name.size();Cur_name = re_name.toArray(Cur_name);String Cur_info = new Stringinfo.size();Cur_info = info.toArray(Cur_info);Bundle bundle = new Bundle();bundle.putStringArray(name, Cur_name);Student data = new Student();data.info = Cur_info;/传递数据Intent intent =

48、new Intent(Search.this,SearchResult.class);intent.putE*tras(bundle);intent.putE*tra(data, data);startActivity(intent);cursor.close(););btn_Cancle.setOnClickListener(new OnClickListener()publicvoid onClick(View source) db.close();finish(););6. 删除数据界面:对文本框内输入的内容进展准确查询,假设查询成功则对对应的条目进展删除,并提示删除成功,假设失败,则提

49、示删除失败核心代码:/确定按钮点击后的监听事件btn_Accept.setOnClickListener(new OnClickListener()publicvoid onClick(View source) String name = ET_Modify_Name.getTe*t().toString();String NO = ET_Modify_No.getTe*t().toString();/查询数据Cursor cursor = db.rawQuery(select * from student where + name=+ and NO=, new String name, NO

50、);if(cursor.moveToFirst() = false)Toast.makeTe*t(Delete.this, 记录不存在, Toast.LENGTH_SHORT).show();elsetrydb.e*ecSQL(delete from student + where name=+ and NO=,new String name, NO);/假设查询失败则提示删除失败catch(SQLiteE*ception e)Toast.makeTe*t(Delete.this, 删除失败, Toast.LENGTH_SHORT).show();return;/假设查询成功,则提示记录已经删

51、除Toast.makeTe*t(Delete.this, 一条记录已删除, Toast.LENGTH_SHORT).show();cursor.close();finish(););/取消按钮点击后的监听事件btn_Cancle.setOnClickListener(new OnClickListener()publicvoid onClick(View source) db.close();finish(););附:student类的定义publicclass Student implements SerializableprivatestaticfinallongserialVersion

52、UID = 1L;public String name;public String NO;public String se*;public String profession;public String age;public String MakeString()String s = name,NO,se*,profession,age;return s;public String info;五、 总结这个安卓app实现了对数据库操作的根本功能,使用起来简便性强,轻便直接,因为是可视化编程,所以对于界面也进展了一定程度的美化,对应的编写平台是手机,所以实现的功能都是以简单实用美观为根底,并且同

53、时保证强健性为目标,但是同样因为这个原因在查询功能上,功能比较简单,比方查询操作,只能在满足根本的查询功能上添加简易的模糊查询,并且查找条件比较单一,因此,仍然可以在此方面做出改进. z.-计算机科学与技术学院课程设计成绩单课程名称:数据库系统原理课程设计 *詹博策性别男*5班级DB1302综合成绩成绩等级程序运行情况占总成绩20%能正确运行 根本能正确运行 能运行但结果不完善20分 15分 10分程序功能完善程度占总成绩10%完善 根本完善 不完善10分 8分 5分程序构造的合理性占总成绩10%合理 根本合理 不太合理10分 8分 5分对问题的辩论情况占总成绩40%概念正确有创新 40分能正确答复所有问题 35分根本能正确答复 30分 局部问题答复概念不清晰 20分学生的工作态度与独立工作能力占总成绩10%工作态度认真能独立完成任务 10分工作态度根本认真,独立性尚可 8分工作态度和独立性较差 5分设计报告的标准性占总成绩10%符合标准 根本符合标准 标准性较差10分 8分 5分A:90100分 A-:8589分 B+:8284分 B:7881分 B-:7577分 C+:7274分 C:6871分 C-:6467分 D:6063分 F:60分 *科技大学计算机科学与技术学院制表. z.

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!