Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions src/tokomaterial/controller/AdminController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.logging.Level;
import java.util.logging.Logger;
import model.AdminModel;
import model.LoginModel;
import model.PemesananModel;
import view.HomeAdminView;
import view.LoginView;
import view.PemesananView;
import view.RekapPenjualanAdminView;
import model.RekapAdminModel;

/**
*
* @author World
*/
public class AdminController {

model.AdminModel theModel;
view.HomeAdminView theView;

public AdminController(AdminModel theModel, HomeAdminView theView) {
this.theModel = theModel;
this.theView = theView;

theView.pesanListener(new pesan());
theView.rekapPesananListener(new rekapPenjualanAdmin());
theView.logoutListener(new logout());

}

private class logout implements ActionListener {

@Override
public void actionPerformed(ActionEvent e) {
try {
LoginView lg = new LoginView();
theView.dispose();
lg.setVisible(true);
LoginModel theModel = new LoginModel();
LoginController theController = new LoginController(theModel, lg);
} catch (SQLException ex) {
Logger.getLogger(AdminController.class.getName()).log(Level.SEVERE, null, ex);
}
}

}

private class pesan implements ActionListener {

@Override
public void actionPerformed(ActionEvent e) {
try {
PemesananView a = new PemesananView();
theView.dispose();
a.setVisible(true);
PemesananModel theModel = new PemesananModel();
PemesananController theController = new PemesananController(theModel, a);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}

private class rekapPenjualanAdmin implements ActionListener {

@Override
public void actionPerformed(ActionEvent e) {
try {
RekapPenjualanAdminView rp = new RekapPenjualanAdminView();
theView.dispose();
rp.setVisible(true);
RekapAdminModel theModel = new RekapAdminModel();
RekapAdminController theController = new RekapAdminController(theModel, rp);
} catch (SQLException ex) {
Logger.getLogger(AdminController.class.getName()).log(Level.SEVERE, null, ex);
}
}

}

}
87 changes: 87 additions & 0 deletions src/tokomaterial/controller/LoginController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import model.AdminModel;
import model.LoginModel;
import model.ManajerModel;
import view.HomeAdminView;
import view.LoginView;
import view.HomeManagerView;

/**
*
* @author World
*/
public class LoginController {

private model.LoginModel theModel;
private view.LoginView theView;
private static String username;

public LoginController(LoginModel theModel, LoginView theView) throws SQLException {
this.theModel = theModel;
this.theView = theView;

theView.setVisible(true);
theView.loginListener(new loginListener());
}

public static void setUserLogin(String username) {
LoginController.username = username;
}

public static String getUserLogin() {
return username;
}

private class loginListener implements ActionListener {

@Override
public void actionPerformed(ActionEvent e) {
try {
int result = theModel.login(theView.getTxtUsername(), theView.getPassword());

if (result == 1) {
int level = theModel.lvlLogin(theView.getTxtUsername(), theView.getPassword());

if (level == 2) {
//JOptionPane.showMessageDialog(viewLogin, "Halo " + username + " !");
HomeManagerView m = new HomeManagerView();
theView.dispose();
m.setVisible(true);
ManajerModel modelManajer = new ManajerModel();
ManagerController controlManajer = new ManagerController(modelManajer, m);

} else if (level == 1) {
//JOptionPane.showMessageDialog(viewLogin, "Halo " + username + " !");
HomeAdminView admin = new HomeAdminView();
theView.dispose();
admin.setVisible(true);
AdminModel modeladmin = new AdminModel();
AdminController controller = new AdminController(modeladmin, admin);
}

} else if ((theView.getTxtUsername().equalsIgnoreCase("") || theView.getPassword().equalsIgnoreCase(""))) {
JOptionPane.showMessageDialog(theView, "Username dan Password tidak Boleh Kosong");
} else {
JOptionPane.showMessageDialog(theView, "USERNAME ATAU PASSWORD ANDA SALAH !");
}

} catch (SQLException ex) {
JOptionPane.showMessageDialog(theView, "Koneksi time out!");
Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, null, ex);
}

}
}
}
109 changes: 109 additions & 0 deletions src/tokomaterial/controller/ManagerController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import model.*;
import view.*;

/**
*
* @author World
*/
public class ManagerController {

model.ManajerModel theModel;
view.HomeManagerView theView;
// model.RekapManagerModel Model;

public ManagerController(ManajerModel theModel, HomeManagerView theView) {
this.theModel = theModel;
this.theView = theView;

theView.logout(new logout());
theView.admin(new admin());
theView.outlet(new outlet());
theView.rekapManager (new rekapPenjualanManager());

}

private class logout implements ActionListener {

@Override
public void actionPerformed(ActionEvent e) {
try {
LoginView lg = new LoginView();
theView.dispose();
lg.setVisible(true);
LoginModel theModel = new LoginModel();
LoginController theController = new LoginController(theModel, lg);
} catch (SQLException ex) {
Logger.getLogger(ManagerController.class.getName()).log(Level.SEVERE, null, ex);
}
}

}

private class admin implements ActionListener {

@Override
public void actionPerformed(ActionEvent e) {
try {
TambahAkunView a = new TambahAkunView();
theView.dispose();
a.setVisible(true);
TambahManajerModel theModel = new TambahManajerModel() {

};
TambahMenejerController theController = new TambahMenejerController(theModel, a);
} catch (SQLException ex) {
Logger.getLogger(ManagerController.class.getName()).log(Level.SEVERE, null, ex);
}

}
}

private class outlet implements ActionListener {

@Override
public void actionPerformed(ActionEvent e) {
try {
TambahOutletView a = new TambahOutletView();
theView.dispose();
a.setVisible(true);
TambahOutletModel theModel = new TambahOutletModel() {

};
TambahOutletController theController = new TambahOutletController(theModel, a);
} catch (SQLException ex) {
Logger.getLogger(ManagerController.class.getName()).log(Level.SEVERE, null, ex);
}

}
}
//
private class rekapPenjualanManager implements ActionListener {

@Override
public void actionPerformed(ActionEvent e) {
try {
RekapPenjualanManagerView rpm = new RekapPenjualanManagerView();
theView.dispose();
rpm.setVisible(true);
RekapManagerModel Model = new RekapManagerModel();
RekapManagerController theController = new RekapManagerController( Model, rpm);
} catch (SQLException ex) {
Logger.getLogger(ManagerController.class.getName()).log(Level.SEVERE, null, ex);
}
}

}

}
50 changes: 50 additions & 0 deletions src/tokomaterial/controller/OutletController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.ArrayList;
import model.*;
import view.*;

/**
*
* @author World
*/
public class OutletController {

model.OutletModel theModel;
view.TambahOutletView theView;
OutletModel om;
ArrayList<Outlet> listOutlet;

OutletController(OutletModel theModel, TambahOutletView theView) throws SQLException, ParseException {
this.theModel = theModel;
this.theView = theView;
om = new OutletModel();
listOutlet = om.getAllAdmin();
this.theView.btnKembali(new OutletController.kembali());

// this.theView.addAdminList(listOutlet);

}

private class kembali implements ActionListener {

@Override
public void actionPerformed(ActionEvent e) {
HomeManagerView a = new HomeManagerView();
theView.dispose();
a.setVisible(true);
ManajerModel theModel = new ManajerModel();
ManagerController theController = new ManagerController(theModel, a);
}

}
}
Loading