Android学生信息标准管理系统APP_第1页
Android学生信息标准管理系统APP_第2页
Android学生信息标准管理系统APP_第3页
Android学生信息标准管理系统APP_第4页
Android学生信息标准管理系统APP_第5页
已阅读5页,还剩33页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Android学生信息管理系统APP需求分析为了方便进行对学生数据库操作,本app可在android设备上进行对学生信息数据库信息管理功效,具体功效以下:

1.对数据库中全部学生姓名进行显示,对各个条目进行点击可展开具体信息查询数据:查询数据是依据姓名和学号两个条件进行查询,二者满足任一条件则进行模糊查询,两个条件同时满足则进行正确查询,查询结果界面和功效一中相同,以姓名排列,点击展开全部信息增加数据:在数据库中增添条目,包含姓名(字符串),学号(数字,主键),性别(单选框),年纪(数字),专业(字符串)。每个条目全部有误输入设定,且主键可检验反复性,全部数据可检验完整性,若插入成功则会显示一条消息提醒成功,若失败则会提醒检验主键反复或数据不完整修改数据:依据姓名学号进行正确查找,查找成功后转入修改界面,为了预防漏填和便捷修改界面会默认填充之前数据(除学号),修改完成即可更新,一样会检验数据完整性删除数据:依据姓名学号进行正确查找,查找成功则会进行删除,并显示一条删除成功提醒,若失败,也会进行提醒概念结构设计ER图:逻辑结构设计学生:姓名(字符串)学号(数字,主码)性别(单选框)年纪(数字)专业(字符串)createtablestudent( nameTEXT, NOTEXTPrimaryKey, sexTEXT, professionTEXT, ageTEXT)具体实现1.主界面:主界面显示全部功效,每个按钮点击后,跳转进入对应功效关键代码:publicclassMainextendsActivity{ SQLiteDatabasedb; Buttonbtn_search; Buttonbtn_modify; Buttonbtn_add; Buttonbtn_delete; Buttonbtn_quit; Buttonbtn_show; @Override protectedvoidonCreate(BundlesavedInstanceState){ requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().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=(Button)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); try { Cursorcursor=db.rawQuery("select*fromstudent",null); cursor.close(); } catch(SQLiteExceptione) { db.execSQL("createtablestudent" +"(" +" nameTEXT," +" NOTEXTPrimaryKey," +" sexTEXT," +" professionTEXT," +" ageTEXT" +")"); } //显示全部数据按钮功效实现 btn_show.setOnClickListener(newOnClickListener() { publicvoidonClick(Viewsource){//获取指针 Cursorcursor=db.rawQuery("select*fromstudent",null); //判定数据库是否不存在任何数据 if(cursor.moveToFirst()==false) { Toast.makeText(Main.this,"不存在统计",Toast.LENGTH_SHORT).show(); } else { List<Student>p=newArrayList<Student>(); List<String>re_name=newArrayList<String>(); List<String[]>info=newArrayList<String[]>(); //保留搜索出全部数据 for(cursor.moveToFirst();!cursor.isAfterLast();cursor.moveToNext()) { intnameColume=cursor.getColumnIndex("name"); intNOColume=cursor.getColumnIndex("NO"); intproColume=cursor.getColumnIndex("profession"); intsexColume=cursor.getColumnIndex("sex"); intageColume=cursor.getColumnIndex("age"); Studentstudent=newStudent(); ="姓名:"+cursor.getString(nameColume); student.NO="学号:"+cursor.getString(NOColume); student.sex="性别:"+cursor.getString(sexColume); fession="专业:"+cursor.getString(proColume); student.age="年纪:"+cursor.getString(ageColume); p.add(student); String[]temp=student.MakeString(); info.add(temp); Stringnewname=cursor.getString(nameColume); re_name.add(newname); }//对保留数据进行封装 String[]Cur_name=newString[re_name.size()]; Cur_name=re_name.toArray(Cur_name); String[][]Cur_info=newString[info.size()][]; Cur_info=info.toArray(Cur_info); Bundlebundle=newBundle(); bundle.putStringArray("name",Cur_name); Studentdata=newStudent(); =Cur_info; //将封装数据传输给结果界面activity Intentintent=newIntent(Main.this,SearchResult.class); intent.putExtras(bundle); intent.putExtra("data",data); startActivity(intent); cursor.close(); } } }); //为剩下按钮绑定监听器实现跳转功效 btn_search.setOnClickListener(newOnClickListener() { publicvoidonClick(Viewsource){ Intentintent=newIntent(Main.this,Search.class); startActivity(intent); } }); btn_modify.setOnClickListener(newOnClickListener() { publicvoidonClick(Viewsource){ Intentintent=newIntent(Main.this,Modify.class); startActivity(intent); } }); btn_add.setOnClickListener(newOnClickListener() { publicvoidonClick(Viewsource){ Intentintent=newIntent(Main.this,Add.class); startActivity(intent); } }); btn_delete.setOnClickListener(newOnClickListener() { publicvoidonClick(Viewsource){ Intentintent=newIntent(Main.this,Delete.class); startActivity(intent); } }); btn_quit.setOnClickListener(newOnClickListener() { publicvoidonClick(Viewsource){ db.close(); finish(); } }); }}数据显示界面:按姓名排列,点击条目展开具体信息关键代码:publicclassSearchResultextendsActivity{ @SuppressLint("RtlHardcoded") publicvoidonCreate(BundlesavedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); //获取传送来数据 super.onCreate(savedInstanceState); setContentView(R.layout.layout_result); finalIntentintent=getIntent(); BaseExpandableListAdapteradapter=newBaseExpandableListAdapter() {//提取数据 Bundlebundle=intent.getExtras(); Studentmem_data=(Student)getIntent().getExtras().get("data"); String[]people=(String[])bundle.getSerializable("name"); String[][]data=mem_; publicObjectgetChild(intgroupPosition,intchildPosition) { returndata[groupPosition][childPosition]; } publiclonggetChildId(intgroupPosition,intchildPosition) { returnchildPosition; } publicintgetChildrenCount(intgroupPosition) { returndata[groupPosition].length; } //设定每个子选项每行显示方法 privateTextViewgetTextView() { AbsListView.LayoutParamslp=newAbsListView.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT); TextViewtextView=newTextView(SearchResult.this); textView.setLayoutParams(lp); textView.setGravity(Gravity.CENTER_VERTICAL|Gravity.LEFT); textView.setPadding(36,0,0,0); textView.setTextSize(20); returntextView; } //设定每个子选项显示内容 publicViewgetChildView(intgroupPosition,intchildPosition,booleanisLastChild,ViewconvertView,ViewGroupParent) { TextViewtextView=getTextView(); textView.setText(""+getChild(groupPosition,childPosition).toString()); returntextView; } publicObjectgetGroup(intgroupPosition) { returnpeople[groupPosition]; } publicintgetGroupCount() { returnpeople.length; } publiclonggetGroupId(intgroupPosition) { returngroupPosition; } //设定每个组选项显示内容 publicViewgetGroupView(intgroupPosition,booleanisExpanded,ViewconvertView,ViewGroupparnet) { LinearLayoutll=newLinearLayout(SearchResult.this); ll.setOrientation(0); TextViewtextView=getTextView(); textView.setText(""+getGroup(groupPosition).toString()); ll.addView(textView); returnll; } }; ExpandableListViewexpandListView=(ExpandableListView)findViewById(R.id.list); expandListView.setAdapter(adapter); }}增添数据界面:依据文本框输入内容进行数据插入,且含有完整性和反复性判定,插入成功失败均会产生提醒关键代码:publicclassAddextendsActivity{ SQLiteDatabasedb; Buttonbtn_Accept; Buttonbtn_Cancle; TextViewET_name; TextViewET_NO; TextViewET_Pro; TextViewET_Age; RadioGrouprg; Stringradio_sex="男"; @Override protectedvoidonCreate(BundlesavedInstanceState){ requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); super.onCreate(savedInstanceState); setContentView(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=(TextView)findViewById(R.id.ET_Add_name); ET_NO=(TextView)findViewById(R.id.ET_Add_NO); ET_Pro=(TextView)findViewById(R.id.ET_Add_Pro); ET_Age=(TextView)findViewById(R.id.ET_Add_Age); rg=(RadioGroup)findViewById(R.id.rg); rg.setOnCheckedChangeListener(newOnCheckedChangeListener(){ publicvoidonCheckedChanged(RadioGroupgroup,intCheckedId){ radio_sex=CheckedId==R.id.rad_male?"男":"女"; } }); //提交操作 btn_Accept.setOnClickListener(newOnClickListener() { publicvoidonClick(Viewsource){ Stringname=ET_name.getText().toString(); StringNO=ET_NO.getText().toString(); Stringsex=radio_sex; Stringpro=ET_Pro.getText().toString(); Stringage=ET_Age.getText().toString(); //规范性和完整性判定 try { //插入数据 db.execSQL("insertintostudentvalues(?,?,?,?,?)",newString[]{name,NO,sex,pro,age}); } //规范性和完整性判定 catch(SQLiteExceptione) { Toast.makeText(Add.this,"插入数据失败,请检验数据规范性和学号唯一性",Toast.LENGTH_SHORT).show(); return; } Toast.makeText(Add.this,"成功插入一条数据:"+"\n"+name+"\n"+NO+"\n"+sex+"\n"+pro+"\n"+age,Toast.LENGTH_SHORT).show(); } }); btn_Cancle.setOnClickListener(newOnClickListener() { publicvoidonClick(Viewsource){ db.close(); finish(); } }); }}修改数据界面:查找界面:对文本框内输入数据进行正确查找,成功后转入修改界面修改界面:文本框内默认显示之前数据,修改完成点击确定以文本框内信息对数据进行更新关键代码:查找:btn_Accept.setOnClickListener(newOnClickListener() { publicvoidonClick(Viewsource){ Stringname=ET_Modify_Name.getText().toString(); StringNO=ET_Modify_No.getText().toString(); Cursorcursor=db.rawQuery("select*fromstudentwhere" +"name=?" +"andNO=?" ,newString[]{name,NO}); //判定查找结果是否为空 if(cursor.moveToFirst()==false) { Toast.makeText(Modify.this,"统计不存在",Toast.LENGTH_SHORT).show(); } else { Stringmem_name=null; Stringmem_No=null; Stringmem_profession=null; Stringmem_sex=null; Stringmem_age=null; //保留全部数据 for(cursor.moveToFirst();!cursor.isAfterLast();cursor.moveToNext()) { intnameColume=cursor.getColumnIndex("name"); intNoColume=cursor.getColumnIndex("NO"); intproColume=cursor.getColumnIndex("profession"); intsexColume=cursor.getColumnIndex("sex"); intageColume=cursor.getColumnIndex("age"); mem_name=cursor.getString(nameColume); mem_No=cursor.getString(NoColume); mem_profession=cursor.getString(proColume); mem_sex=cursor.getString(sexColume); mem_age=cursor.getString(ageColume); } //封装全部数据 Bundlebundle=newBundle(); bundle.putString("name",mem_name); bundle.putString("No",mem_No); bundle.putString("profession",mem_profession); bundle.putString("sex",mem_sex); bundle.putString("age",mem_age); //传输数据 Intentintent=newIntent(Modify.this,ModifyResult.class); intent.putExtras(bundle); startActivity(intent); cursor.close(); } } }); btn_Cancle.setOnClickListener(newOnClickListener() { publicvoidonClick(Viewsource){ //TODOAuto-generatedmethodstub db.close(); finish(); } });修改:publicclassModifyResultextendsActivity{ SQLiteDatabasedb; Buttonbtn_accept; Buttonbtn_cancle; TextViewTextView_ModifyResult_No; EditTextET_ModifyResult_Name; EditTextET_ModifyResult_pro; EditTextET_ModifyResult_age; RadioGrouprg; Stringradio_sex; protectedvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.layout_modifyresult); //获取数据 finalIntentintent=getIntent(); Bundlebundle=intent.getExtras(); 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); TextView_ModifyResult_No=(TextView)findViewById(R.id.TextView_ModifyResult_No); ET_ModifyResult_Name=(EditText)findViewById(R.id.ET_ModifyResult_Name); ET_ModifyResult_pro=(EditText)findViewById(R.id.ET_ModifyResult_pro); ET_ModifyResult_age=(EditText)findViewById(R.id.ET_ModifyResult_age); rg=(RadioGroup)findViewById(R.id.modify_rg); //设定默认数据 Stringname=bundle.getString("name"); finalStringNo=bundle.getString("No"); Stringpro=bundle.getString("profession"); Stringage=bundle.getString("age"); radio_sex=bundle.getString("sex"); TextView_ModifyResult_No.setText(No); ET_ModifyResult_Name.setText(name); ET_ModifyResult_pro.setText(pro); ET_ModifyResult_age.setText(age); rg.setOnCheckedChangeListener(newOnCheckedChangeListener(){ publicvoidonCheckedChanged(RadioGroupgroup,intCheckedId){ radio_sex=CheckedId==R.id.rad_male?"男":"女"; } }); btn_accept.setOnClickListener(newOnClickListener() { publicvoidonClick(Viewsource){ Stringnew_name=ET_ModifyResult_Name.getText().toString(); Stringnew_profession=ET_ModifyResult_pro.getText().toString(); Stringnew_age=ET_ModifyResult_age.getText().toString(); Stringnew_sex=radio_sex; //更新数据 try { db.execSQL("UPDATEstudent" +"SETname=?,NO=?,sex=?,profession=?,age=?" +"WHERENO=?", newString[]{new_name,No,new_sex,new_profession,new_age,No}); } catch(SQLiteExceptione) { Toast.makeText(ModifyResult.this,"更新数据失败",Toast.LENGTH_SHORT).show(); return; } Toast.makeText(ModifyResult.this,"更新数据成功",Toast.LENGTH_SHORT).show(); finish(); } }); btn_cancle.setOnClickListener(newOnClickListener() { publicvoidonClick(Viewsource){ db.close(); finish(); } }); }}查找数据界面:对文本框内数据进行模糊查询,查询成功则跳转只查询结果界面,查询失败则产生对应提醒关键代码:publicclassSearchextendsActivity{ SQLiteDatabasedb; Buttonbtn_Accept; Buttonbtn_Cancle; EditTextET_name; EditTextET_NO; @Override protectedvoidonCreate(BundlesavedInstanceState){ 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()+"/Student.db3",null,SQLiteDatabase.OPEN_READWRITE); btn_Accept=(Button)findViewById(R.id.btn_Accept); btn_Cancle=(Button)findViewById(R.id.btn_Cancle); ET_name=(EditText)findViewById(R.id.ET_Search_name); ET_NO=(EditText)findViewById(R.id.ET_Search_NO); btn_Accept.setOnClickListener(newOnClickListener() { publicvoidonClick(Viewsource){ Stringname=ET_name.getText().toString(); StringNO=ET_NO.getText().toString(); //获取指针 Cursorcursor=db.rawQuery("select*fromstudentwhere" +"name=?"//+"or"+"name=?" +"orNO=?"//+"or"+"NO=?" ,newString[]{name,NO}); //检验查找是否为空 if(cursor.moveToFirst()==false) { Toast.makeText(Search.this,"统计不存在",Toast.LENGTH_SHORT).show(); } else { Toast.makeText(Search.this,"成功",Toast.LENGTH_SHORT).show(); //return; List<Student>p=newArrayList<Student>(); List<String>re_name=newArrayList<String>(); List<String[]>info=newArrayList<String[]>(); //保留数据 for(cursor.moveToFirst();!cursor.isAfterLast();cursor.moveToNext()) { intnameColume=cursor.getColumnIndex("name"); intNOColume=cursor.getColumnIndex("NO"); intproColume=cursor.getColumnIndex("profession"); intsexColume=cursor.getColumnIndex("sex"); intageColume=cursor.getColumnIndex("age"); Studentstudent=newStudent(); ="姓名:"+cursor.getString(nameColume); student.NO="学号:"+cursor.getString(NOColume); student.sex="性别:"+cursor.getString(sexColume); fession="专业:"+cursor.getString(proColume); student.age="年纪:"+cursor.getString(ageColume); p.add(student); String[]temp=student.MakeString(); info.add(temp); Stringnewname=cursor.getString(nameColume); re_name.add(newname); } //封装数据 String[]Cur_name=newString[re_name.size()]; Cur_name=re_name.toArray(Cur_name); String[][]Cur_info=newString[info.size()][]; Cur_info=info.toArray(Cur_info); Bundlebundle=newBundle(); bundle.putStringArray("name",Cur_name); Studentdata=newStudent(); =Cur_info; //传输数据 Intentintent=newIntent(Search.this,SearchResult.class); intent.putExtras(bundle); intent.putExtra("data",data); startActivity(intent); cursor.close(); } } }); btn_Cancle.setOnClickListener(newOnClickListener() { publicvoidonClick(Viewsource){ db.close(); finish(); } }); }}删除数据界面:对文本框内输入内容进行正确查询,若查询成功则对对应条目进行删除,并提醒删除成功,若失败,则提醒删除失败关键代码://确定按钮点击后监听事件 btn_Accept.setOnClickListener(newOnClickListener() { publicvoidonClick(Viewsource){ Stringname=ET_Modify_Name.getText().toString(); StringNO=ET_Modify_No.getText().toString(); //查询数据 Cursorcursor=db.rawQuery("select*fromstudentwhere" +"name=?" +"andNO=?" ,newString[]{name,NO}); if(cursor.moveToFirst()==false) { Toas

温馨提示

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

评论

0/150

提交评论