0
% Begin initialization code - DO NOT EDIT

        gui_Singleton = 1;
        gui_State = struct('gui_Name',       mfilename, ...
                           'gui_Singleton',  gui_Singleton, ...
                           'gui_OpeningFcn', @skripsi_OpeningFcn, ...
                           'gui_OutputFcn',  @skripsi_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 skripsi is made visible.
function skripsi_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 skripsi (see VARARGIN)

% Choose default command line output for skripsi

    handles.output = hObject;

% Update handles structure

    guidata(hObject, handles);

% UIWAIT makes skripsi wait for user response (see UIRESUME)
% uiwait(handles.figure1);

    conmysql = database('skripsi_mysql','root','')
    fetch(conmysql,'select * from data')

% --- Outputs from this function are returned to the command line.
function varargout = skripsi_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 code_Callback(hObject, eventdata, handles)
% hObject    handle to code (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 code as text
%        str2double(get(hObject,'String')) returns contents of code as a double

    code = get(hObject,'String')
    handles.code = code
    guidata(hObject,handles)

% --- Executes during object creation, after setting all properties.
function code_CreateFcn(hObject, eventdata, handles)
% hObject    handle to code (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 in_Callback(hObject, eventdata, handles)
% hObject    handle to in (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 in as text
%        str2double(get(hObject,'String')) returns contents of in as a double

    in = get(hObject,'String')
    handles.in = in
    guidata(hObject,handles)

% --- Executes during object creation, after setting all properties.
function in_CreateFcn(hObject, eventdata, handles)
% hObject    handle to in (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 out_Callback(hObject, eventdata, handles)
% hObject    handle to out (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 out as text
%        str2double(get(hObject,'String')) returns contents of out as a double

    out = get(hObject,'String')
    handles.out = out
    guidata(hObject,handles)

% --- Executes during object creation, after setting all properties.
function out_CreateFcn(hObject, eventdata, handles)
% hObject    handle to out (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 fee_Callback(hObject, eventdata, handles)
% hObject    handle to fee (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 fee as text
%        str2double(get(hObject,'String')) returns contents of fee as a double

    fee = str2double(get(hObject,'String'))
    handles.fee = fee
    guidata(hObject,handles)

% --- Executes during object creation, after setting all properties.
function fee_CreateFcn(hObject, eventdata, handles)
% hObject    handle to fee (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 masuk.
function masuk_Callback(hObject, eventdata, handles)
% hObject    handle to masuk (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

    a = 'QWERTY';
    t = datestr(datenum(now),'HH:MM');
    conmysql = database('skripsi_mysql','root','')
    field = {'Code','In','Out','Fee'}
    databaru = {a,t,'',}
    insert(conmysql,'data',field,databaru)
    data = fetch(conmysql,'select * from data') 


% --- Executes on button press in camera.
function camera_Callback(hObject, eventdata, handles)
% hObject    handle to camera (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --- Executes on button press in keluar.
function keluar_Callback(hObject, eventdata, handles)
% hObject    handle to keluar (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

    conmysql = database('skripsi_mysql','root','')
    sql = ['select * from data where PlatNomor =','''',handles.code,''''];
    fetch(conmysql,'select *from data');
    data = fetch(conmysql,sql)
    data.In
    t1 = datestr(datenum(now),'HH:MM');
    t2 = datenum(t1);
    t3 = datenum(data.in);
    time_diff = t3 - t2;
    hours = ceil(time_diff * 24)
    fee = hours * 5;
    field = {'JamKeluar','Biaya'};
    databaru = {t1,2000};
    tablename = 'data';
    whereclause = ['where PlatNomor =','''',handles.code,''''];
    update(conmysql,tablename,field,databaru,whereclause);
    set(handles.in,'String',data.in)
    set(handles.out,'String',data.out)
    set(handles.fee,'String',data.fee)
Finn
  • 2,333
  • 1
  • 10
  • 21
  • apperantly `data` returned from the `fetch` command, does not have an entry `in`. can you please post what data looks like? (you can just run your code with the `;`removed on fetch and will pop up in the command window) – Finn Sep 14 '16 at 11:51
  • thanks for reply. if i fetch from typing Code ABCD to code editbox the result is this : data = Code: {'ABCD'}, In: {'01:00'}, Out {'02:00'}, Fee: 2000 – Alfi Nugraha Sep 14 '16 at 11:55
  • i am not sure but this might be case sensitive. could you please try again with `data.In` – Finn Sep 14 '16 at 11:57
  • ive tring this code : disp(data.In) but has still same problem . – Alfi Nugraha Sep 14 '16 at 11:59
  • could you please use the command `setdbprefs` and tell us what DataReturnformat you have? – Finn Sep 14 '16 at 13:39
  • here : DataReturnFormat: 'structure', ErrorHandling: 'store', NullNumberRead: 'NaN', NullNumberWrite: 'NaN', NullStringRead: 'null', NullStringWrite: 'null,' JDBCDataSourceFile: '', UseRegistryForSources: 'yes', TempDirForRegistryOutput: 'C:\Users\ALFI\AppData\Local\Temp', DefaultRowPreFetch: '10000', FetchInBatches: 'no', FetchBatchSize: '1000'. Thank you sir still helping me to solve it – Alfi Nugraha Sep 14 '16 at 14:00
  • ok thank you. could you please also try just `disp(data)` right after the `data = fetch(` and post that too? – Finn Sep 14 '16 at 14:03
  • here it is sir : Code {'ALFI'} In: {'19:09'} Out: {'19:18'} Fee: 2000 . – Alfi Nugraha Sep 14 '16 at 14:19
  • and does `data.Code` `data.Out` `data.Fee` return the correct vlaues – Finn Sep 14 '16 at 14:27
  • yes sir, it correct. but still i cant show it to editbox in my gui. do you have any alternative way or another algoritm program to solve it ? – Alfi Nugraha Sep 14 '16 at 14:31
  • is that `t3 = datenum(data.in);`line 208 of your script? could you post al of it? otherwise i am out of ideas – Finn Sep 14 '16 at 14:33
  • Error in skripsi>out_Callback (line 208) t3 = datenum(data.in); Error in gui_mainfcn (line 95) feval(varargin{:}); Error in skripsi (line 42) gui_mainfcn(gui_State, varargin{:}); Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)skripsi('out_Callback',hObject,eventdata,guidata(hObject)) Error while evaluating UIControl Callback – Alfi Nugraha Sep 14 '16 at 14:44
  • i am getting out of ideas. i am quite certain that it has to be `t3 = datenum(data.In);` with a big **In** not **in** . but if that doesnt fix it you have to post all of your porgram – Finn Sep 14 '16 at 14:51
  • i tag edit box 'in' sir . oke i'll update all . and someone suggest me like this : "You have no field called 'in' contained in the data cursor returned by fetch. You probably want to look into the 'Data' property of cursor as this is where the fetched data is stored, I would highly recommend entering into debug more on the lines where you can not figure out what is happening" and give me code like this : returnedData = data.Data. but i still dont get it – Alfi Nugraha Sep 14 '16 at 14:59
  • @Finn updated sir all my prog . Thanks a lot sir for your time – Alfi Nugraha Sep 14 '16 at 15:13

1 Answers1

0

its just the same error twice thats why it didnt worked:

REPLACE t3 = datenum(data.in); WITH t3 = datenum(data.In); and

REPLACE set(handles.in,'String',data.in) WITH set(handles.in,'String',data.In)

Finn
  • 2,333
  • 1
  • 10
  • 21