function varargout = kundenliste2(varargin)
% KUNDENLISTE2 M-file for kundenliste2.fig
%      KUNDENLISTE2, by itself, creates a new KUNDENLISTE2 or raises the existing
%      singleton*.
%
%      H = KUNDENLISTE2 returns the handle to a new KUNDENLISTE2 or the handle to
%      the existing singleton*.
%
%      KUNDENLISTE2('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in KUNDENLISTE2.M with the given input arguments.
%
%      KUNDENLISTE2('Property','Value',...) creates a new KUNDENLISTE2 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before kundenliste2_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to kundenliste2_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 kundenliste2

% Last Modified by GUIDE v2.5 23-Jun-2008 23:52:57

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @kundenliste2_OpeningFcn, ...
                   'gui_OutputFcn',  @kundenliste2_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 kundenliste2 is made visible.
function kundenliste2_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 kundenliste2 (see VARARGIN)

% Choose default command line output for kundenliste2
handles.output = hObject;
load kundenliste
global kunde;
n = numel(kunde.name);
set(handles.listbox1, 'String', {kunde.name} );
global a;
handles.select=0;
set(handles.text4, 'String', 'test');
set(handles.text5, 'String', 'test');

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = kundenliste2_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;


% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns listbox1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from listbox1
global kunde
    vars = get(hObject,'String');
	handles.select = get(hObject,'Value');
    set(handles.text4, 'String', handles.select);
    name=kunde(handles.select).name;
    vorname=kunde(handles.select).vorname;
    adresse=kunde(handles.select).adresse;
    plz=kunde(handles.select).plz;
    ort=kunde(handles.select).ort;
    antwort=sprintf(' Name: %s \n Vorname: %s \n Adresse: %s \n Plz: %s \n Ort: %s',name,vorname,adresse,plz,ort);
    set(handles.text5, 'String', antwort);
    guidata(hObject,handles);


% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox 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

%h = uicontrol('Style','ListBox','String',{kunde.name},'Position',[1 1 200 400]);



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
global a;
%set(hObject,'String',handles.select);


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


% --- Executes on key press with focus on listbox1 and none of its controls.
function listbox1_KeyPressFcn(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  structure with the following fields (see UICONTROL)
%	Key: name of the key that was pressed, in lower case
%	Character: character interpretation of the key(s) that was pressed
%	Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles    structure with handles and user data (see GUIDATA)


% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over listbox1.
function listbox1_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global a;
a=get(hObject, 'String');


% --- Executes on button press in pushbutton_kundeneditieren.
function pushbutton_kundeneditieren_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_kundeneditieren (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 pushbutton_kundenloechen.
function pushbutton_kundenloechen_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_kundenloechen (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global kunde
a=questdlg('Den Ausgewählen Kunden wirklich löschen?', 'Ausgewählten Kunden löschen?', 'Ja','Abbruch', 'Ja');
switch a
    case 'Ja'
        kunde(handles.select)=[ ];
        save kundenliste
end

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


% --- 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)
load kundenliste
global kunde;
%kunde2.name=orderfields(kunde.name)
n = numel(kunde.name);
set(handles.listbox1, 'String', {kunde.name}) 

