1. Buatlah program aplikasi pemasaran pada Matlab!
Jawab: 1. Program aplikasi pemasaran. Sintaks:
function varargout = Stat_Store(varargin)
% Stat_Store M-file for Stat_Store.fig % Stat_Store, by itself, creates a new Stat_Store or raises the existing % singleton*. % % H = Stat_Store returns the handle to a new Stat_Store or the handle to % the existing singleton*. % % Stat_Store('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in Stat_Store.M with the given input arguments. % % Stat_Store('Property','Value',...) creates a new Stat_Store or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before Stat_Store_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to Stat_Store_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 Stat_Store % Last Modified by GUIDE v2.5 01-Sep-2017 14:06:57 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @Stat_Store_OpeningFcn, ... 'gui_OutputFcn', @Stat_Store_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 Stat_Store is made visible. function Stat_Store_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 Stat_Store (see VARARGIN) % Choose default command line output for Stat_Store handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes Stat_Store wait for user response (see UIRESUME) % uiwait(handles.u9store); % --- Outputs from this function are returned to the command line. function varargout = Stat_Store_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 mouse press over figure background. function u9store_ButtonDownFcn(hObject, eventdata, handles) % hObject handle to u9store (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) function rpenj_namabarang_Callback(hObject, eventdata, handles) % hObject handle to rpenj_namabarang (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
rpenj_namabarang as text % str2double(get(hObject,'String')) returns contents of rpenj_namabarang as a double % --- Executes during object creation, after setting all properties. function rpenj_namabarang_CreateFcn(hObject, eventdata, handles) % hObject handle to rpenj_namabarang (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 rpenj_harga_Callback(hObject, eventdata, handles) % hObject handle to rpenj_harga (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 rpenj_harga
as text % str2double(get(hObject,'String')) returns contents of rpenj_harga as a double harga = str2double(get(hObject, 'String')); if isnan(harga) set(handles.rpenj_qty,'Enable','off'); set(hObject, 'String', ''); errordlg('Harga harus diisi dengan angka !!','Ada yang salah ?'); elseif (harga <= 0) set(handles.rpenj_qty,'Enable','off'); set(hObject, 'String', ''); errordlg('Harga tidak boleh nol !!','Ada yang salah ?'); elseif isempty(harga) set(handles.rpenj_qty,'Enable','off'); errordlg('Harga tidak boleh kosong !!','Ada yang salah ?'); else end set(handles.rpenj_qty,'Enable','on'); % --- Executes during object creation, after setting all properties. function rpenj_harga_CreateFcn(hObject, eventdata, handles) % hObject handle to rpenj_harga (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 selection change in rpenj_qty. function rpenj_qty_Callback(hObject, eventdata, handles) % hObject handle to rpenj_qty (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 rpenj_qty contents as cell array % contents{get(hObject,'Value')} returns selected item from rpenj_qty harga=str2num(get(handles.rpenj_harga, 'String')); tot1=harga*1; tot2=harga*2; tot3=harga*3; tot4=harga*4; contents = get(hObject,'Value') switch contents case 1 set(handles.rpemb_bayar,'Enable','off'); warndlg('Tentukan jumlah pembelian.','Peringatan !'); set(handles.rpemb_total, 'string', '-'); set(handles.rpemb_diskon, 'string', '-'); set(handles.rpemb_jmldiskon, 'string', ''); set(handles.rpemb_totalbayar, 'string', '-'); case 2 set(handles.rpemb_bayar,'Enable','on'); set(handles.rpemb_total, 'string', tot1); if tot1 >= 1000000 diskon=tot1*0.25; totalbayar=tot1-diskon; set(handles.rpemb_diskon, 'string', diskon); set(handles.rpemb_jmldiskon, 'string', '25%'); set(handles.rpemb_totalbayar, 'string', totalbayar); else set(handles.rpemb_diskon, 'string', '-'); set(handles.rpemb_jmldiskon, 'string', ''); set(handles.rpemb_totalbayar, 'string', tot1); end case 3 set(handles.rpemb_bayar,'Enable','on'); set(handles.rpemb_total, 'string', tot2); if tot2 >= 300000 diskon=tot2*0.25; totalbayar=tot2-diskon; set(handles.rpemb_diskon, 'string', diskon); set(handles.rpemb_jmldiskon, 'string', '25%'); set(handles.rpemb_totalbayar, 'string', totalbayar); else set(handles.rpemb_diskon, 'string', '-'); set(handles.rpemb_jmldiskon, 'string', ''); set(handles.rpemb_totalbayar, 'string', tot2); end case 4 set(handles.rpemb_bayar,'Enable','on'); set(handles.rpemb_total, 'string', tot3); if tot3 >= 300000 diskon=tot3*0.25; totalbayar=tot3-diskon; set(handles.rpemb_diskon, 'string', diskon); set(handles.rpemb_jmldiskon, 'string', '25%'); set(handles.rpemb_totalbayar, 'string', totalbayar); else set(handles.rpemb_diskon, 'string', '-'); set(handles.rpemb_jmldiskon, 'string', ''); set(handles.rpemb_totalbayar, 'string', tot3); end case 5 set(handles.rpemb_bayar,'Enable','on'); set(handles.rpemb_total, 'string', tot4); if tot4 >= 1000000 diskon=tot4*0.25; totalbayar=tot4-diskon; set(handles.rpemb_diskon, 'string', diskon); set(handles.rpemb_jmldiskon, 'string', '25%'); set(handles.rpemb_totalbayar, 'string', totalbayar); else set(handles.rpemb_diskon, 'string', '-'); set(handles.rpemb_jmldiskon, 'string', ''); set(handles.rpemb_totalbayar, 'string', tot4); end otherwise end % --- Executes during object creation, after setting all properties. function rpenj_qty_CreateFcn(hObject, eventdata, handles) % hObject handle to rpenj_qty (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 selection change in daftar_produk. function daftar_produk_Callback(hObject, eventdata, handles) % hObject handle to daftar_produk (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 daftar_produk contents as cell array % contents{get(hObject,'Value')} returns selected item from daftar_produk contents = get(hObject,'Value') switch contents case 1 set(handles.rpenj_qty,'Enable','off'); set(handles.rpenj_harga,'Enable','off'); warndlg('Silahkan pilih produk terlebih dahulu.','Peringatan !'); set(handles.detail_jenis, 'string', 'Pilih produk dulu !!'); set(handles.detail_merek, 'string', 'Pilih produk dulu !!'); set(handles.detail_warna, 'string', 'Pilih produk dulu !!'); set(handles.detail_size, 'string', 'Pilih produk dulu !!'); set(handles.detail_gender, 'string', 'Pilih produk dulu !!'); set(handles.rpenj_namabarang, 'string', 'Pilih produk dulu !!'); set(handles.rpenj_harga, 'string', 'Pilih produk dulu !!'); set(handles.rpemb_kembali, 'string', ''); set(handles.rpenj_qty, 'value', 1); set(handles.rpemb_total, 'string', ''); set(handles.rpemb_diskon, 'string', ''); set(handles.rpemb_totalbayar, 'string', ''); set(handles.rpemb_jmldiskon, 'string', ''); case 2 set(handles.rpenj_qty,'Enable','on'); set(handles.rpenj_harga,'Enable','on'); set(handles.detail_jenis, 'string', 'Baju'); set(handles.detail_merek, 'string', 'Tngr'); set(handles.detail_warna, 'string', 'White'); set(handles.detail_size, 'string', 'L'); set(handles.detail_gender, 'string', 'Pria Wanita'); set(handles.rpenj_namabarang, 'string', 'Tngr Katun Pria '); set(handles.rpenj_harga, 'string', '150000'); set(handles.rpemb_kembali, 'string', ''); set(handles.rpenj_qty, 'value', 1); set(handles.rpemb_total, 'string', ''); set(handles.rpemb_diskon, 'string', ''); set(handles.rpemb_totalbayar, 'string', ''); set(handles.rpemb_jmldiskon, 'string', ''); case 3 set(handles.rpenj_qty,'Enable','on'); set(handles.rpenj_harga,'Enable','on'); set(handles.detail_jenis, 'string', 'Celana'); set(handles.detail_merek, 'string', 'Louis'); set(handles.detail_warna, 'string', 'Black'); set(handles.detail_size, 'string', 'L'); set(handles.detail_gender, 'string', 'Pria'); set(handles.rpenj_namabarang, 'string', 'Louis Levis'); set(handles.rpenj_harga, 'string', '750000'); set(handles.rpemb_kembali, 'string', ''); set(handles.rpenj_qty, 'value', 1); set(handles.rpemb_total, 'string', ''); set(handles.rpemb_diskon, 'string', ''); set(handles.rpemb_totalbayar, 'string', ''); set(handles.rpemb_jmldiskon, 'string', ''); case 4 set(handles.rpenj_qty,'Enable','on'); set(handles.rpenj_harga,'Enable','on'); set(handles.detail_jenis, 'string', 'Jam Tangan'); set(handles.detail_merek, 'string', 'Eiger'); set(handles.detail_warna, 'string', 'Grey'); set(handles.detail_size, 'string', 'L'); set(handles.detail_gender, 'string', 'Pria'); set(handles.rpenj_namabarang, 'string', 'Eiger'); set(handles.rpenj_harga, 'string', '359000'); set(handles.rpemb_kembali, 'string', ''); set(handles.rpenj_qty, 'value', 1); set(handles.rpemb_total, 'string', ''); set(handles.rpemb_diskon, 'string', ''); set(handles.rpemb_totalbayar, 'string', ''); set(handles.rpemb_jmldiskon, 'string', ''); otherwise end % --- Executes during object creation, after setting all properties. function daftar_produk_CreateFcn(hObject, eventdata, handles) % hObject handle to daftar_produk (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 function rpemb_totalbayar_Callback(hObject, eventdata, handles) % hObject handle to rpemb_totalbayar (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
rpemb_totalbayar as text % str2double(get(hObject,'String')) returns contents of rpemb_totalbayar as a double % --- Executes during object creation, after setting all properties. function rpemb_totalbayar_CreateFcn(hObject, eventdata, handles) % hObject handle to rpemb_totalbayar (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 rpemb_kembali_Callback(hObject, eventdata, handles) % hObject handle to rpemb_kembali (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 rpemb_kembali
as text % str2double(get(hObject,'String')) returns contents of rpemb_kembali as a double % --- Executes during object creation, after setting all properties. function rpemb_kembali_CreateFcn(hObject, eventdata, handles) % hObject handle to rpemb_kembali (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 rpemb_bayar_Callback(hObject, eventdata, handles) % hObject handle to rpemb_bayar (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 rpemb_bayar as text % str2double(get(hObject,'String')) returns contents of rpemb_bayar as a double totalbayar=str2num(get(handles.rpemb_totalbayar, 'String')); uangbayar = str2double(get(hObject, 'String')); if isnan(uangbayar) set(handles.tmbl_bayar,'Enable','off'); set(hObject, 'String', ''); errordlg('Uang Bayar harus diisi dengan angka !!','Ada yang salah ?'); elseif (uangbayar <= 0) set(hObject, 'String', ''); errordlg('Uang bayar tidak boleh nol !!','Ada yang salah ?'); elseif (uangbayar < totalbayar) set(hObject, 'String', ''); errordlg('Uang bayar tidak boleh kurang dari total bayar !!','Ada yang salah ?'); else set(handles.tmbl_bayar,'Enable','on'); end % --- Executes during object creation, after setting all properties. function rpemb_bayar_CreateFcn(hObject, eventdata, handles) % hObject handle to rpemb_bayar (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 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) selection=questdlg(['Anda Yakin Ingin Menutup Aplikasi',' ?'],... ['Stat_Store.com bertanya' '' '...'],... 'Ya','Batal','Ya'); if strcmp(selection,'Batal') return end close; % --- Executes on button press in tmbl_tentang. function tmbl_tentang_Callback(hObject, eventdata, handles) % hObject handle to tmbl_tentang (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) selection=questdlg(['KHATIB RAMADHAN',' - P3E115013 (01TPLPC / 603)'],... ['Tentang pembuat' '' '...'],... 'OK','OK'); if strcmp(selection,'OK') return end % --- Executes on button press in tmbl_bayar. function tmbl_bayar_Callback(hObject, eventdata, handles) % hObject handle to tmbl_bayar (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) uangbayar=str2num(get(handles.rpemb_bayar, 'String')); totalbayar=str2num(get(handles.rpemb_totalbayar, 'String')); kembali=uangbayar-totalbayar; set(handles.rpemb_kembali, 'string', kembali); set(handles.rpemb_bayar,'Enable','off'); set(handles.rpenj_qty,'Enable','off'); set(handles.rpenj_harga,'Enable','off'); set(handles.rpenj_qty, 'value', 1); set(handles.rpemb_total, 'string', ''); set(handles.rpemb_diskon, 'string', ''); set(handles.rpemb_totalbayar, 'string', ''); set(handles.daftar_produk, 'value', 1); set(handles.rpenj_harga, 'string', ''); set(handles.rpenj_namabarang, 'string', ''); set(handles.rpemb_jmldiskon, 'string', ''); set(handles.detail_jenis, 'string', ''); set(handles.detail_merek, 'string', ''); set(handles.rpemb_bayar, 'string', ''); set(handles.detail_warna, 'string', ''); set(handles.detail_size, 'string', ''); set(handles.detail_gender, 'string', ''); warndlg('Terima kasih telah berbelanja di toko kami.','Peringatan !'); % --------Kode untuk validasi data (reset) function initialize_gui(fig_handle, handles, isreset) if isfield(handles, 'metricdata') && ~isreset return; end guidata(handles.u9store, handles); % --- Executes during object creation, after setting all properties. function bag_rincianpembayaran_CreateFcn(hObject, eventdata, handles) % hObject handle to bag_rincianpembayaran (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % --- Executes during object creation, after setting all properties. function bag_daftarproduk_CreateFcn(hObject, eventdata, handles) % hObject handle to bag_daftarproduk (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called Output: