Android学生信息管理系统APP.docx

上传人:b****1 文档编号:14353463 上传时间:2023-06-22 格式:DOCX 页数:31 大小:833.70KB
下载 相关 举报
Android学生信息管理系统APP.docx_第1页
第1页 / 共31页
Android学生信息管理系统APP.docx_第2页
第2页 / 共31页
Android学生信息管理系统APP.docx_第3页
第3页 / 共31页
Android学生信息管理系统APP.docx_第4页
第4页 / 共31页
Android学生信息管理系统APP.docx_第5页
第5页 / 共31页
Android学生信息管理系统APP.docx_第6页
第6页 / 共31页
Android学生信息管理系统APP.docx_第7页
第7页 / 共31页
Android学生信息管理系统APP.docx_第8页
第8页 / 共31页
Android学生信息管理系统APP.docx_第9页
第9页 / 共31页
Android学生信息管理系统APP.docx_第10页
第10页 / 共31页
Android学生信息管理系统APP.docx_第11页
第11页 / 共31页
Android学生信息管理系统APP.docx_第12页
第12页 / 共31页
Android学生信息管理系统APP.docx_第13页
第13页 / 共31页
Android学生信息管理系统APP.docx_第14页
第14页 / 共31页
Android学生信息管理系统APP.docx_第15页
第15页 / 共31页
Android学生信息管理系统APP.docx_第16页
第16页 / 共31页
Android学生信息管理系统APP.docx_第17页
第17页 / 共31页
Android学生信息管理系统APP.docx_第18页
第18页 / 共31页
Android学生信息管理系统APP.docx_第19页
第19页 / 共31页
Android学生信息管理系统APP.docx_第20页
第20页 / 共31页
亲,该文档总共31页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

Android学生信息管理系统APP.docx

《Android学生信息管理系统APP.docx》由会员分享,可在线阅读,更多相关《Android学生信息管理系统APP.docx(31页珍藏版)》请在冰点文库上搜索。

Android学生信息管理系统APP.docx

Android学生信息管理系统APP

Android学生信息管理系统APP

一、需求分析

为了方便的进行对学生数据库的操作,本app可在android设备上进行对学生信息数据库的信息管理功能,具体功能如下:

1.对数据库中所有学生进行显示,对各个条目进行点击可展开具体信息

2.查询数据:

查询数据是根据与学号两个条件进行查询,两者满足任一条件则进行模糊查询,两个条件同时满足则进行精确查询,查询结果界面与功能一中相同,以排列,点击展开所有信息

3.增加数据:

在数据库中增添条目,包括(字符串),学号(数字,主键),性别(单选框),年龄(数字),专业(字符串)。

每个条目均有误输入设定,且主键可检查重复性,所有数据可检查完整性,若插入成功则会显示一条消息提示成功,若失败则会提示检查主键重复或者数据不完整

4.修改数据:

根据学号进行精确查找,查找成功后转入修改界面,为了防止漏填与便捷修改界面会默认填充之前的数据(除学号),修改完毕即可更新,同样会检查数据完整性

5.删除数据:

根据学号进行精确查找,查找成功则会进行删除,并显示一条删除成功的提示,若失败,也会进行提示

二、概念结构设计

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

{

Listp=newArrayList();

Listre_name=newArrayList();

Listinfo=newArrayList();

//保存搜索出的所有数据

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();

student.name=":

"+cursor.getString(nameColume);

student.NO="学号:

"+cursor.getString(NOColume);

student.sex="性别:

"+cursor.getString(sexColume);

student.profession="专业:

"+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();

data.info=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();

}

});

}

}

2.数据显示界面:

按排列,点击条目展开具体信息

核心代码:

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_data.info;

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);

}

}

 

3.增添数据界面:

根据文本框输入容进行数据的插入,且具有完整性和重复性的判断,插入成功失败均会产生提示

核心代码:

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();

}

});

}

}

 

4.修改数据界面:

查找界面:

对文本框输入的数据进行精确查找,成功后转入修改界面

 

修改界面:

文本框默认显示之前的数据,修改完成点击确定以文本框的信息对数据进行更新

核心代码:

查找:

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).s

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 表格模板 > 合同协议

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2