Вы находитесь на странице: 1из 7

function varargout = Registrasi(varargin)

% REGISTRASI MATLAB code for Registrasi.fig


% REGISTRASI, by itself, creates a new REGISTRASI or raises the existing
% singleton*.
%
% H = REGISTRASI returns the handle to a new REGISTRASI or the handle to
% the existing singleton*.
%
% REGISTRASI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in REGISTRASI.M with the given input arguments.
%
% REGISTRASI('Property','Value',...) creates a new REGISTRASI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Registrasi_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Registrasi_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Registrasi

% Last Modified by GUIDE v2.5 05-Dec-2016 22:42:33

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Registrasi_OpeningFcn, ...
'gui_OutputFcn', @Registrasi_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
% End initialization code - DO NOT EDIT

% --- Executes just before Registrasi is made visible.


function Registrasi_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to Registrasi (see VARARGIN)

% Choose default command line output for Registrasi


handles.output = hObject;

% Update handles structure


guidata(hObject, handles);
movegui(hObject,'center');
warning off all;

% UIWAIT makes Registrasi wait for user response (see UIRESUME)


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = Registrasi_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure


varargout{1} = handles.output;

function edit1_Callback(hObject, eventdata, handles)


% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text


% str2double(get(hObject,'String')) returns contents of edit1 as a double

% --- Executes during object creation, after setting all properties.


function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit2_Callback(hObject, eventdata, handles)


% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text


% str2double(get(hObject,'String')) returns contents of edit2 as a double

% --- Executes during object creation, after setting all properties.


function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit3_Callback(hObject, eventdata, handles)


% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text


% str2double(get(hObject,'String')) returns contents of edit3 as a double

% --- Executes during object creation, after setting all properties.


function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit4_Callback(hObject, eventdata, handles)


% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit4 as text


% str2double(get(hObject,'String')) returns contents of edit4 as a double

% --- Executes during object creation, after setting all properties.


function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

% --- Executes on button press in radiobutton1.


function radiobutton1_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton1


set(hObject,'Value',1)
set(handles.radiobutton2,'Value',0)

% --- Executes on button press in radiobutton2.


function radiobutton2_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton2


set(hObject,'Value',1)
set(handles.radiobutton1,'Value',0)

% --- Executes on selection change in popupmenu1.


function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as


cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1

% --- Executes during object creation, after setting all properties.


function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

% --- Executes on button press in pushbutton3.


function pushbutton1_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)

% A = cell(1,8);
% Database_All = cell2table(A);
% Database_All.Properties.VariableNames{1} = 'No';
% Database_All.Properties.VariableNames{2} = 'NIM';
% Database_All.Properties.VariableNames{3} = 'Nama';
% Database_All.Properties.VariableNames{4} = 'Jenis_Kelamin';
% Database_All.Properties.VariableNames{5} = 'TTL';
% Database_All.Properties.VariableNames{6} = 'Alamat';
% Database_All.Properties.VariableNames{7} = 'Tahun_Masuk';
% Database_All.Properties.VariableNames{8} = 'Foto';
try
load Database_All
[no1,~] = size(Database_All.No{1,1});
if no1 == 0
no = 1;
else
[no,~] = size(Database_All.No);
no = no+1;
end

nim = get(handles.edit1,'String');
nama = get(handles.edit2,'String');
laki2 = get(handles.radiobutton1,'Value');
perempuan = get(handles.radiobutton2,'Value');
if laki2 == 1
jenis_kel = 'Laki-laki';
elseif perempuan == 1
jenis_kel = 'Perempuan';
end
ttl = get(handles.edit3,'String');
alamat = get(handles.edit4,'String');
tahun = get(handles.popupmenu1,'Value');
switch tahun
case 1
tahun_masuk = '2011';
case 2
tahun_masuk = '2012';
case 3
tahun_masuk = '2013';
case 4
tahun_masuk = '2014';
case 5
tahun_masuk = '2015';
case 6
tahun_masuk = '2016';
case 7
tahun_masuk = '2017';
case 8
tahun_masuk = '2018';
case 9
tahun_masuk = '2019';
case 10
tahun_masuk = '2020';
end

if isempty(nim)
warndlg('NIM tidak boleh kosong','Warning');
elseif isempty(nama)
warndlg('Nama tidak boleh kosong','Warning');
else
Database_All.No{no,1} = no;
Database_All.Nama{no,1} = nama;
Database_All.NIM{no,1} = nim;
Database_All.Jenis_Kelamin{no,1} = jenis_kel;
Database_All.TTL{no,1} = ttl;
Database_All.Alamat{no,1} = alamat;
Database_All.Tahun_Masuk{no,1} = tahun_masuk;
Database_All.Foto{no,1} = handles.Img;
save Database_All.mat Database_All
msgbox(strcat(['Data Mahasiswa No. ',num2str(no),' berhasil
disimpan']),'Message')
end
catch
warndlg('Foto tidak boleh kosong','Message')
end

% --- Executes on button press in pushbutton3.


function pushbutton2_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)
set(handles.edit1,'String','')
set(handles.edit2,'String','')
set(handles.edit3,'String','')
set(handles.edit4,'String','')

set(handles.radiobutton1,'Value',1)
set(handles.radiobutton2,'Value',0)

set(handles.popupmenu1,'Value',1)

axes(handles.axes1)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])

% --- 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)
close;
guidata(Database_Mahasiswa);

% --- 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)
try
[filename,pathname] = uigetfile({'*.jpg'});

if ~isequal(filename,0)
Img = imread(fullfile(pathname,filename));
axes(handles.axes1)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])
imshow(Img);
else
return
end

handles.Img = Img;
guidata(hObject,handles)
catch
warndlg('File harus berformat foto digital','Warning')
end

Вам также может понравиться