资源描述
matlabgui数据管理系统
24
2020年4月19日
文档仅供参考
程序附件1:
一、 主界面:学生课程成绩管理系统
1、打开文件按钮:
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global str;
[FileName PathName]=uigetfile(('*.xls'),'choose a File');
str=[PathName FileName];
set(handles.edit1,'string',str);
2、 数据库管理按扭:
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%shujukuguanli();
global str;
setappdata(shujukuguanli(),'str',str);
3、 成绩查询按钮:
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global str;
setappdata(chengjichaxun(),'str',str);
5、 成绩直方图按钮:
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global str;
setappdata(chengjizhifangtu(),'str',str);
6、 退出按钮:
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close(cjguanli());
二、 子界面:数据库管理
1、 显示整体数据按钮:
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hbject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%[FileName PathName]=uigetfile(('*.xls'),'choose a File');
%str=[PathName FileName];
%set(handles.edit1,'string',str);
global str1;
str1=getappdata(shujukuguanli(),'str');
[shuzi fuhao]=xlsread(str1);
hj=size(shuzi,1);
handles.xingming=fuhao(2:hj+1,1);
set(handles.listbox1,'string',handles.xingming);
set(handles.listbox3,'string',num2str(shuzi(:,2:end)));
set(handles.listbox2,'string',num2str(shuzi(:,1)));
handles.chengji=shuzi(:,2:end);
handles.xuehao=shuzi(:,1);
guidata(hObject,handles);
2、 设置课程学分按钮:
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles) %设置各科学分
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
ke1xuefeng=get(handles.edit3,'string'); %各科学分
ke2xuefeng=get(handles.edit4,'string');
ke3xuefeng=get(handles.edit5,'string');
xuefenghe=ke1xuefeng+ke2xuefeng+ke3xuefeng;%三课学分之和
ke1xuefeng1=ke1xuefeng/xuefenghe; %各科学分占比
ke2xuefeng1=ke2xuefeng/xuefenghe;
ke3xuefeng1=ke3xuefeng/xuefenghe;
ke1chengjijiaquan=handles.chengji(:,1).*ke1xuefeng1;%各科成绩乘以占比
ke2chengjijiaquan=handles.chengji(:,2).*ke2xuefeng1;
ke3chengjijiaquan=handles.chengji(:,3).*ke3xuefeng1;
jiaquanchengji=ke1chengjijiaquan + ke2chengjijiaquan + ke2chengjijiaquan;
set(handles.listbox4,'string',num2str(jiaquanchengji));
3、 添加按钮:
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles) %添加函数
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global str1;
mima=get(handles.edit11,'string');
password='123456';
k=strcmp(mima,password);
if k==0
set(handles.edit11,'string','密码输入错误请重输!');
return
else
name1=get(handles.edit6,'string');
xuehao1=str2num(get(handles.edit7,'string'));
kecheng11=str2num(get(handles.edit8,'string'));
kecheng21=str2num(get(handles.edit9,'string'));
kecheng31=str2num(get(handles.edit10,'string'));
handles.xingming=[handles.xingming;name1];
handles.xuehao=[handles.xuehao;xuehao1];
handles.chengji=[handles.chengji; kecheng11, kecheng21,kecheng31];
guidata(hObject,handles);
set(handles.listbox1,'string',handles.xingming);
set(handles.listbox2,'string',num2str(handles.xuehao));
set(handles.listbox3,'string',num2str(handles.chengji));
xlswrite(str1,handles.xingming,1,'A2');
xlswrite(str1,handles.xuehao,1,'B2');
xlswrite(str1,handles.chengji,1,'C2');
end
4、 按姓名查询按钮:
% --- Executes on button press in pushbutton6.
function pushbutton6_Cllback(hObject, eventdata, handles) %姓名查询
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global mm;
name2=get(handles.edit6,'string');
aa=strcmp(name2,handles.xingming);
[mm n]=find(aa==1);
xingming=handles.xingming;
xuehao=handles.xuehao;
chengji=handles.chengji;
if mm==0
set(handles.edit11,'string','无此人!请重输!');
return
else
set(handles.edit6,'string',xingming(mm,: ));
set(handles.edit7,'string',num2str(xuehao(mm,: )));
set(handles.edit8,'string',num2str(chengji(mm,1)));
set(handles.edit9,'string',num2str(chengji(mm,2)));
set(handles.edit10,'string',num2str(chengji(mm,3)));
End
5、 修改按钮:
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles) %修改函数
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global str1;
mima=get(handles.edit11,'string');
password='123456';
k=strcmp(mima,password);
if k==0
set(handles.edit11,'string','密码输入错误请重输!');
return
else
name1=get(handles.edit6,'string');
xuehao1=str2num(get(handles.edit7,'string'));
kecheng11=str2num(get(handles.edit8,'string'));
kecheng21=str2num(get(handles.edit9,'string'));
kecheng31=str2num(get(handles.edit10,'string'));
xingming=handles.xingming;
xuehao=handles.xuehao;
chengji=handles.chengji;
xingming(mm)=name1;
xuehao(mm)=xuehao1;
chengji(mm,:)=[kecheng11,kecheng21,kecheng31];
handles.xingming=xingming;
handles.xuehao=xuehao;
handles.chengji=chengji;
guidata(hObject,handles);
set(handles.listbox1,'string',handles.xingming);
set(handles.listbox2,'string',num2str(handles.xuehao));
set(handles.listbox3,'string',num2str(handles.chengji));
xlswrite(str1,handles.xingming,1,'A2');
xlswrite(str1,handles.xuehao,1,'B2');
xlswrite(str1,handles.chengji,1,'C2');
end
7、 返回按钮:
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
cjguanli();
close(shujukuguanli());
三、 子系统成绩查询:
1、 姓名查询按钮:
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global str1;
name=get(handles.edit1,'string');
str1=getappdata(chengjichaxun(),'str');
[shuzi fuhao]=xlsread(str1);
handles.xingming=fuhao(2:end,1);
handles.xuehao=shuzi(:,1);
handles.chengji=shuzi(:,2:end);
guidata(hObject,handles);
chengji=handles.chengji;
xuehao=handles.xuehao;
xingming=handles.xingming;
[lia,id]=ismember(name,handles.xingming);
set(handles.listbox1,'string',xingming(id,: ));
set(handles.listbox2,'string',num2str(xuehao(id,: )));
set(handles.listbox3,'string',num2str(chengji(id,: )));
3、 返回按钮:
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
cjguanli();
close(chengjichaxun());
四、 子系统:成绩排序
1、 课程1排序按钮:
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles) %按课程1 降序排序
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global shuzi;
global fuhao;
str1=getappdata(chengjipaixu(),'str');
[shuzi fuhao]=xlsread(str1);
handles.xingming=fuhao(2:end,1);
handles.xuehao=shuzi(:,1);
handles.chengji=shuzi(:,2:end);
handles.zhongtishuju=shuzi;
zhongtishuju1=sortrows(shuzi,-2);%排序
xuehao1=zhongtishuju1(:,1);
chengji1=zhongtishuju1(:,2:end);
hang=size(xuehao1,1);
[id1,id2]=ismember(handles.xuehao,xuehao1);
for pp=1:hang
xingming1(id2(pp))=handles.xingming(pp);
end
xingming2=xingming1';
handles.xingming22=xingming2;
handles.xuehao22=xuehao1;
handles.chengji22=chengji1;
guidata(hObject,handles);
set(handles.listbox1,'string',xingming2);
set(handles.listbox2,'string',num2str(xuehao1));
set(handles.listbox3,'string',num2str(chengji1));
2、 课程2排序按钮:
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)%按课程2排序
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%global shuzi;
%global fuhao;
str1=getappdata(chengjipaixu(),'str');
[shuzi fuhao]=xlsread(str1);
xingming=fuhao(2:end,1);
xuehao=shuzi(:,1);
zhongtishuju3=sortrows(shuzi,-3);%排序
xuehao1=zhongtishuju3(:,1);
chengji1=zhongtishuju3(:,2:end);
hang=size(xuehao1,1);
[id1,id2]=ismember(xuehao,xuehao1);
for pp=1:hang
xingming1(id2(pp))=xingming(pp);
end
xingming2=xingming1';
handles.xingming22=xingming2;
handles.xuehao22=xuehao1;
handles.chengji22=chengji1;
guidata(hObject,handles);
set(handles.listbox1,'string',xingming2);
set(handles.listbox2,'string',num2str(xuehao1));
set(handles.listbox3,'string',num2str(chengji1));
4、 对排序结果保存按钮:
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
str1=getappdata(chengjipaixu(),'str');
xlswrite(str1,handles.xingming22,1,'A2');
xlswrite(str1,handles.xuehao22,1,'B2');
xlswrite(str1,handles.chengji22,1,'C2');
5、 返回按钮:
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
cjguanli();
close(chengjipaixu());
五、 子系统:成绩直方图
1、 课程1按钮:
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles) %课程1直方图
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
str1=getappdata(chengjizhifangtu(),'str');
[shuzi fuhao]=xlsread(str1);
axes(handles.axes1);
X=[5,15,25,35,45,55,65,75,85,95];
handles.chengji=shuzi(:,2:end);
kecheng1=handles.chengji(:,1);
hist(kecheng1,X);
2、 课程2按扭:
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
str1=getappdata(chengjizhifangtu(),'str');
[shuzi fuhao]=xlsread(str1);
axes(handles.axes2);
X=[5,15,25,35,45,55,65,75,85,95];
handles.chengji=shuzi(:,2:end);
kecheng2=handles.chengji(:,2);
hist(kecheng2,X);
xlabel('分数');
ylabel('人数');
3、 课程3按钮:
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
str1=getappdata(chengjizhifangtu(),'str');
[shuzi fuhao]=xlsread(str1);
axes(handles.axes3);
X=[5,15,25,35,45,55,65,75,85,95];
handles.chengji=shuzi(:,2:end);
kecheng3=handles.chengji(:,3);
hist(kecheng3,X);
4、 返回按钮:
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
cjguanli();
close(chengjizhifangtu());
展开阅读全文