function varargout = LibSys(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name',      mfilename, ...
                  'gui_Singleton',  gui_Singleton, ...
                  'gui_OpeningFcn', @LibSys_OpeningFcn, ...
                  'gui_OutputFcn',  @LibSys_OutputFcn, ...
                  'gui_LayoutFcn',  [] , ...
                  'gui_Callback',  []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
function LibSys_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
ha=axes('units','normalized','position',[0 0 1 1]);
uistack(ha,'down')
II=imread('背景图片.jpg');
image(II)
colormap gray 
set(ha,'handlevisibility','off','visible','off'); 
function varargout = LibSys_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
%获取下拉列表下的数字
function popupmenu1_Callback(hObject, eventdata, handles)
global val;
val=get(hObject,'value')
function popupmenu1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
%输入的回调函数,不用全部遍历,只需要遍历和前面下拉框对应的列
function BookEdit_Callback(hObject, eventdata, handles)
function BookEdit_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function LookPushbutton_Callback(hObject, eventdata, handles)
global val;
global s;
global rnk;
switch val
    case 1
        s=0;
        for i=1:rnk-1
            s=strcmp(get(handles.BookEdit,'string'),deblank(handles.bookname(i,:)));
            if s==1
                str1=['书名          ','作者        ','类别          ','位置    '];
                str2=[handles.bookname(i,:),'      ',handles.writer(i,:),'    ',handles.kind(i,:),'    ',handles.weizhi(i,:)];             
                str=strvcat(str1,str2);
                set(handles.edit6,'string',str);
                break;
            end
        end
        if s==0
            errordlg('查无此书','错误报告');
        end 
    case 2
        s=0;
        for i=1:rnk-1
            get(handles.BookEdit,'string')
            handles.writer(i,:)
            s=strcmp(get(handles.BookEdit,'string'),deblank(handles.writer(i,:)));
            if s==1
                str1=['书名        ','作者      ','类别    ','位置    '];
                str2=[handles.bookname(i,:),'      ',handles.writer(i,:),'    ',handles.kind(i,:),'    ',handles.weizhi(i,:)];             
                str=strvcat(str1,str2);
                set(handles.edit6,'string',str);
                break;
            end
        en
d
        if s==0
            errordlg('查无此书','错误报告');
        end
    case 3
        s=0;
        for i=1:rnk-1
            s=strcmp(get(handles.BookEdit,'string'),deblank(handles.kind(i,:)));
            if s==1
                str1=[' 书名        ','作者        ','类别      ','位置    '];
                str2=[handles.bookname(i,:),'    ',handles.writer(i,:),'  ',handles.kind(i,:),'    ',handles.weizhi(i,:)];             
                str=strvcat(str1,str2);
                set(handles.edit6,'string',str);
                break;
            end
        end
        if s==0
            errordlg('查无此书','错误报告');
        end
end
guidata(hObject, handles); 
%输出的回调函数
object to
function edit2_Callback(hObject, eventdata, handles)
function edit2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
% --- Executes on slider movement.
function slider2_Callback(hObject, eventdata, handles)
%下滑条的回调函数
function slider2_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --------------------------------------------------------------------
function File_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function Design_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function Help_Callback(hObject, eventdata, handles)
% 背景颜设置回调函数
% function Window_Colours_Callback(hObject, eventdata, handles)
% c=uisetcolor([1 1 1],'背景颜');
% set(handles.LibSys,'BackColor',c); 
% 字体颜设置
function Word_Colour_Callback(hObject, eventdata, handles)
% hObject    handle to Word_Colour (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
c=uisetcolor([0 0 0],'字体颜');
set(handles.LibSyss,'ForegroundColor',c); 
2,'ForegroundColor',c); 
set(handles.popupmenu1,'ForegroundColor',c);   
set(handles.LookPushbutton,'ForegroundColor',c);   
% 字体框背景颜设置
function Background_Colour_Callback(hObject, eventdata, handles)
% hObject    handle to Background_Colour (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
c=uisetcolor([0 1 1],'窗口背景颜');
set(handles.LibSyss,'BackgroundColor',c); 
2,'BackgroundColor',c); 
set(handles.popupmenu1,'BackgroundColor',c);   
set(handles.LookPushbutton,'BackgroundColor',c);   
%打开文件
function Open_Callback(hObject, eventdata, handles)
global fname;
global pname;
global rnk;  %行数
g
lobal row;  %列数
[fname,pname]=uigetfile('.xls','选择文件');
str=[pname,fname];
[b c rawdata]=xlsread(str);          %读取指定的excel文件
[rnk,row]=size(rawdata);
handles.rawdata=rawdata;
rawdata(1,:)=[];   
%k
%handles.rawdata
handles.bookname=char(rawdata(:,1));
handles.writer=char(rawdata(:,2));                         
handles.kind=char(rawdata(:,3)); 
handles.weizhi=char(rawdata(:,4));
handles.writer;
handles.bookname;
handles.kind;
handles.weizhi;
guidata(hObject, handles);
h=waitbar(0,'正在导入文件...');
for i=1:1000
    waitbar(i/1000,h)
end
close(h)
%保存文件
function Save_Callback(hObject, eventdata, handles)
% global bookname;
% global writer;
global rnk;
global row;
book=cell(rnk,row);
book(1,:)={'书名','作者','类别','位置'};          %制作表头
book([2:1:rnk],1)=cellstr(handles.bookname);
book([2:1:rnk],2)=cellstr(handles.writer);
book([2:1:rnk],3)=cellstr(handles.kind);
book([2:1:rnk],4)=cellstr(handles.weizhi);
xlswrite('tushutow.xls',book);
h=waitbar(0,'请稍等,正在保存文件.....');
pause(1.5);
for i=1:1:99
    pause(rand()*rand()*0.2);
    str=strcat('已经完成',num2str(i),'%');
    waitbar(i/100,h,str);     
end
waitbar(1,h,'已完成');
close(h);
%删除图书
function Delet_Book_Callback(hObject, eventdata, handles)
global rnk;
global s;
prompt={'书名','作者','类别'};
title='删除图书';
lines=[1 1 1 ]';
list=inputdlg(prompt,title,lines);%参数输入对话框
s=0;
for i=1:rnk
    s=strcmp(deblank(handles.bookname(i,:)),char(list(1)))
    if s==1
      handles.bookname(i,:)=[];
      handles.writer(i,:)=[];
      handles.kind(i,:)=[];
      handles.weizhi(i,:)=[];
      break;
    end
end
book=cell(rnk-1,4);                       
book(1,:)={'书名','作者','类别','位置'};             
book([2:1:rnk-1],1)=cellstr(handles.bookname);
book([2:1:rnk-1],2)=cellstr(handles.writer);
book([2:1:rnk-1],3)=cellstr(handles.kind);
book([2:1:rnk-1],4)=cellstr(handles.weizhi);
xlswrite('tushutow.xls',book,'sheet1');
h=waitbar(0,'请稍等,正在保存文件.....');
for i=1:1:99
    pause(rand()*rand()*0.2);
    str=strcat('已经完成',num2str(i),'%');
    waitbar(i/100,h,str);     
end
waitbar(1,h,'已完成');
close(h);
guidata(hObject,handles);
%添加图书
function Add_Book_Callback(hObject, eventdata, handles)
global rnk;   
global row;
prompt={'书名','作者','类别','位置'};
title='图书增加';
lines=[1 1 1 1]';
answer =inputdlg(prompt,title,lines);%参数输入对话框
rnk=rnk+1;
book=cell(rnk,row);
book(1,:)={'书名','作者','类别','位置'};          %制作表头
book([2:1:rnk-1],1)=cellstr(handles.bookname);
book([2:1:rnk-1],2)=cellstr(handles.writer);
book([2:1:rnk-1],3)=cellstr(handles.kind);
book([2:1:rnk-1],4)=cellstr(handles.weizhi);
book(rnk,1)=answer(1);
book(rnk,2)=answer(2);
book(rnk,3)=answer(3);
book(rnk,4)=answer(4);
xlswrite('tushutow.xls',book);
h=waitbar(0,'请稍等,正在保存
文件.....');
for i=1:1:99
    pause(rand()*rand()*0.2);
    str=strcat('已经完成',num2str(i),'%');
    waitbar(i/100,h,str);     
end
waitbar(1,h,'已完成');
close(h);
%msgbox('添加完成','添加完成');
guidata(hObject, handles);
%菜单栏的退出键
function Quit_Callback(hObject, eventdata, handles)
close(gcf);
function pushbutton3_Callback(hObject, eventdata, handles)
function edit6_Callback(hObject, eventdata, handles)
function edit6_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function slider3_Callback(hObject, eventdata, handles)
function slider3_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。