import [Link].
*;
import [Link].*;
import [Link];
import [Link];
public class Main {
static DefaultTableModel userModel;
public static void main(String[] args) {
showLogin();
initUsers();
}
public static void initUsers() {
String[] columns = {"ID", "Username", "Password", "Role"};
userModel = new DefaultTableModel(columns, 0);
[Link](new Object[]{1, "admin", "admin", "Technician"});
[Link](new Object[]{2, "user", "user", "Brgy. Official"});
}
// LOGIN
public static void showLogin() {
JFrame frame = new JFrame("Barangay Login");
[Link](350, 220);
[Link](JFrame.EXIT_ON_CLOSE);
[Link](null);
[Link](new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
JLabel userLabel = new JLabel("Username:");
JTextField userText = new JTextField(15);
JLabel passLabel = new JLabel("Password:");
JPasswordField passText = new JPasswordField(15);
JButton loginButton = new JButton("Login");
[Link] = new Insets(10, 10, 10, 10);
[Link] = [Link];
[Link] = 0; [Link] = 0;
[Link](userLabel, gbc);
[Link] = 1;
[Link](userText, gbc);
[Link] = 0; [Link] = 1;
[Link](passLabel, gbc);
[Link] = 1;
[Link](passText, gbc);
[Link] = 0; [Link] = 2;
[Link] = 2;
[Link](loginButton, gbc);
[Link](e -> {
String username = [Link]();
String password = new String([Link]());
boolean valid = false;
String role = "";
for (int i = 0; i < [Link](); i++) {
String u = [Link](i, 1).toString();
String p = [Link](i, 2).toString();
if ([Link](u) && [Link](p)) {
valid = true;
role = [Link](i, 3).toString();
break;
}
}
if (valid) {
[Link]();
if ([Link]("Technician")) {
showTechdashboard(role);
} else {
showDashboard(role);
}
} else {
[Link](frame, "Invalid login!");
}
});
[Link](true);
public static void showTechdashboard(String role) {
JFrame frame = new JFrame(role + " Dashboard");
[Link](600, 400);
[Link](JFrame.EXIT_ON_CLOSE);
[Link](null);
[Link](new BorderLayout());
// SIDEBAR
JPanel sidebar = new JPanel();
[Link](new Dimension(150, 0));
[Link](new Color(40, 45, 50));
[Link](new FlowLayout([Link], 10, 20));
Dimension size = new Dimension(120, 35);
JButton dashBtn = new JButton("Home");
JButton userBtn = new JButton("Users");
JButton logoutBtn = new JButton("Logout");
[Link](size);
[Link](size);
[Link](size);
[Link](dashBtn);
[Link](userBtn);
[Link](logoutBtn);
CardLayout cardLayout = new CardLayout();
JPanel contentPanel = new JPanel(cardLayout);
JPanel homePanel = new JPanel();
[Link](new JLabel("Technician Dashboard"));
JPanel userPanel = new JPanel(new BorderLayout());
JTable table = new JTable(userModel);
JScrollPane scrollPane = new JScrollPane(table);
JButton addBtn = new JButton("Add User");
JButton removeBtn = new JButton("Remove User");
JPanel btnPanel = new JPanel();
[Link](addBtn);
[Link](removeBtn);
[Link](scrollPane, [Link]);
[Link](btnPanel, [Link]);
[Link](addBtn);
[Link](removeBtn);
[Link](logoutBtn);
// ADD USER FUNCTION
[Link](e -> {
JTextField usernameField = new JTextField();
JTextField passwordField = new JTextField();
JComboBox<String> roleBox = new JComboBox<>(new String[]
{"Technician", "Brgy. Official"});
Object[] fields = {
"Username:", usernameField,
"Password:", passwordField,
"Role:", roleBox
};
int option = [Link](frame, fields, "Add
User", JOptionPane.OK_CANCEL_OPTION);
if (option == JOptionPane.OK_OPTION) {
int id = [Link]() == 0 ? 1 :
(int) [Link]([Link]()-1, 0) +
1;
[Link](new Object[]{
id,
[Link](),
[Link](),
[Link]()
});
}
});
// REMOVE USER FUNCTION
[Link](e -> {
int row = [Link]();
if (row == -1) {
[Link](frame, "Select a user first!");
return;
}
int confirm = [Link](frame, "Remove
selected user?", "Confirm", JOptionPane.YES_NO_OPTION);
if (confirm == JOptionPane.YES_OPTION) {
[Link](row);
}
});
[Link](homePanel, "home");
[Link](userPanel, "users");
// LOGOUT
[Link](e -> [Link](contentPanel,
"home"));
[Link](e -> [Link](contentPanel,
"users"));
[Link](e -> {
[Link]();
showLogin();
});
// TITLE
JLabel title = new JLabel("User Management System",
[Link]);
[Link](new Font("Arial", [Link], 18));
[Link](new EmptyBorder(10, 10, 10, 10));
[Link](title, [Link]);
[Link](sidebar, [Link]);
[Link](contentPanel, [Link]);
[Link](true);
}
public static void showDashboard(String role) {
JFrame frame = new JFrame(role + " Dashboard");
[Link](1000, 600);
[Link](JFrame.EXIT_ON_CLOSE);
[Link](null);
[Link](new BorderLayout());
// SIDEBAR
JPanel sidebar = new JPanel();
[Link](new Dimension(150, 0));
[Link](new Color(40, 45, 50));
[Link](new FlowLayout([Link], 10, 20));
Dimension size = new Dimension(120, 35);
JButton dashBtn = new JButton("Home");
JButton resBtn = new JButton("Residents");
JButton clerBtn = new JButton("Clearances");
JButton compBtn = new JButton("Compliance");
JButton blotterBtn = new JButton("Blotter");
JButton transBtn = new JButton("Transactions");
JButton logoutBtn = new JButton("Logout");
[Link](size);
[Link](size);
[Link](size);
[Link](size);
[Link](size);
[Link](size);
[Link](size);
[Link](false);
[Link](false);
[Link](false);
[Link](false);
[Link](false);
[Link](false);
[Link](false);
// add buttons
[Link](dashBtn);
[Link](resBtn);
[Link](clerBtn);
[Link](compBtn);
[Link](blotterBtn);
[Link](transBtn);
[Link](logoutBtn);
CardLayout cardLayout = new CardLayout();
JPanel contentPanel = new JPanel(cardLayout);
// DASHBOARD PANEL
JPanel dashboardPanel = new JPanel();
[Link](new BorderLayout());
[Link](new Color(245, 247, 250));
// TITLE
JLabel welcome = new JLabel("Barangay Information Dashboard");
[Link](new Font("Arial", [Link], 20));
[Link](new EmptyBorder(15, 15, 15, 15));
[Link](welcome, [Link]);
// STATS CARDS
JPanel statsPanel = new JPanel(new GridLayout(1, 3, 15, 15));
[Link](new EmptyBorder(20, 20, 20, 20));
[Link](new Color(245, 247, 250));
// Cards
JLabel complianceCountLabel = new JLabel("0");
JLabel totalResidentsLabel = new JLabel("0");
JLabel approvedClearancesLabel = new JLabel("0");
JLabel blotterCountLabel = new JLabel("0");
[Link](createInfoCard("Total Residents", totalResidentsLabel,
new Color(52, 152, 219)));
[Link](createInfoCard("Compliance Cases",
complianceCountLabel, new Color(231, 76, 60)));
[Link](createInfoCard("Approved Clearances",
approvedClearancesLabel, new Color(46, 204, 113)));
[Link](createInfoCard("Blotter Incidents", blotterCountLabel,
new Color(155, 89, 182)));
[Link](statsPanel, [Link]);
//Arrays of data for tables
String[] compColumns = {"Comp ID", "Resident Name", "Violation",
"Status"};
DefaultTableModel compModel = new
DefaultTableModel(compColumns, 0);
String[] clerColumns = {"Clearance ID", "Resident Name", "Type",
"Status"};
DefaultTableModel clerModel = new DefaultTableModel(clerColumns,
0);
String[] columns = {"ID", "Name", "Gender","Age","Address"};
DefaultTableModel residentModel = new DefaultTableModel(columns,
0);
String[] transColumns = {"Trans ID", "Type", "Description", "Date"};
DefaultTableModel transModel = new
DefaultTableModel(transColumns, 0);
String[] blotterColumns = {"Blotter ID", "Complainant",
"Respondent", "Incident", "Status"};
DefaultTableModel blotterModel = new
DefaultTableModel(blotterColumns, 0);
// RESIDENTS PANEL
[Link](new Object[]{"1", "Lorens", "Male","25","Zone
1"});
[Link](new Object[]{"2", "Mama Meya",
"Female","30","Purok 2"});
[Link](new Object[]{"3", "Gooding",
"Female","40","Purok 3"});
[Link](new Object[]{"4", "WAwawewaw",
"Female","22","Purok 4"});
[Link]([Link]([Link]()));
JTable table = new JTable(residentModel);
JScrollPane tableScroll = new JScrollPane(table);
JPanel residentsPanel = new JPanel(new BorderLayout());
[Link](tableScroll, [Link]);
JButton addBtn = new JButton("Add Resident");
JButton removeBtn = new JButton("Remove Resident");
[Link](e -> {
JTextField nameField = new JTextField();
JTextField genderField = new JTextField();
JTextField ageField = new JTextField();
JTextField addressField = new JTextField();
Object[] fields = {
"Name:", nameField,
"Gender:", genderField,
"Age:", ageField,
"Address:", addressField
};
int option = [Link](
null,
fields,
"Add Resident",
JOptionPane.OK_CANCEL_OPTION
);
if (option == JOptionPane.OK_OPTION) {
String name = [Link]();
String gender = [Link]();
String age = [Link]();
String address = [Link]();
int id = [Link]() + 1;
[Link](new Object[]{id, name, gender, age,
address});
[Link]([Link]([Link]()));
int transId = [Link]() + 1;
String type = "Resident Added";
String description = "Added resident: " + name;
String date = new [Link]().toString();
[Link](new Object[]{transId, type, description,
date});
}
});
[Link](e -> {
int selectedRow = [Link]();
if (selectedRow == -1) {
[Link](frame, "Please select a resident
to remove.");
} else {
int confirm = [Link](
frame,
"Remove selected resident?",
"Confirm",
JOptionPane.YES_NO_OPTION
);
if (confirm == JOptionPane.YES_OPTION) {
String name = [Link](selectedRow,
1).toString();
[Link](selectedRow);
[Link]([Link]([Link]()));
int transId = [Link]() + 1;
String type = "Resident Removed";
String description = "Removed resident: " + name;
String date = new [Link]().toString();
[Link](new Object[]{transId, type, description,
date});
}
}
});
JPanel topPanel = new JPanel();
[Link](addBtn);
[Link](removeBtn);
[Link](topPanel, [Link]);
// TRANSACTIONS PANEL
JTable transTable = new JTable(transModel);
JScrollPane transScroll = new JScrollPane(transTable);
JPanel transPanel = new JPanel(new BorderLayout());
[Link](transScroll, [Link]);
// CLEARANCE PANEL
[Link](new Object[]{"1", "Lorens", "Barangay Clearance",
"Pending"});
[Link](new Object[]{"2", "Mama Meya", "Business
Permit", "Approved"});
JTable clerTable = new JTable(clerModel);
JScrollPane clerScroll = new JScrollPane(clerTable);
JPanel clearancePanel = new JPanel(new BorderLayout());
[Link](clerScroll, [Link]);
JButton addclerBtn = new JButton("Add Clearance");
JButton approveBtn = new JButton("Approve");
JButton rejectBtn = new JButton("Reject");
JButton reviewBtn = new JButton("Review");
JPanel clerBtnPanel = new JPanel();
[Link](addclerBtn);
[Link](reviewBtn);
[Link](approveBtn);
[Link](rejectBtn);
[Link](clerBtnPanel, [Link]);
// ADD CLEARANCE
[Link](e -> {
JTextField nameField = new JTextField();
JTextField typeField = new JTextField();
Object[] fields = {
"Resident Name:", nameField,
"Type:", typeField
};
int option = [Link](
null,
fields,
"Add Clearance",
JOptionPane.OK_CANCEL_OPTION
);
if (option == JOptionPane.OK_OPTION) {
int id = [Link]() + 1;
[Link](new Object[]{
id,
[Link](),
[Link](),
"Pending"
});
// log transaction
[Link](new Object[]{
[Link]() + 1,
"Clearance Added",
"Added clearance for " + [Link](),
new [Link]().toString()
});
}
});
// APPROVE
[Link](e -> {
int row = [Link]();
if (row == -1) {
[Link](null, "Select a record first!");
return;
}
String status = [Link](row, 3).toString();
if () {
[Link](null, "Must review before
approving.");
return;
}
[Link]("Approved", row, 3);
[Link](
[Link](countApproved(clerModel))
);
[Link](new Object[]{
[Link]() + 1,
"Clearance Approved",
"Approved clearance of " + [Link](row, 1),
new [Link]().toString()
});
});
// REJECT
[Link](e -> {
int row = [Link]();
if (row == -1) {
[Link](null, "Select a record first!");
return;
}
String status = [Link](row, 3).toString();
if () {
[Link](null, "Must review before
rejecting.");
return;
}
String name = [Link](row, 1).toString();
[Link](row);
[Link](new Object[]{
[Link]() + 1,
"Clearance Rejected",
"Rejected clearance of " + name,
new [Link]().toString()
});
[Link](
[Link](countApproved(clerModel))
);
});
[Link](e -> {
int row = [Link]();
if (row == -1) {
[Link](null, "Select a record first!");
return;
}
String status = [Link](row, 3).toString();
if () {
[Link](null, "Only pending requests
can be reviewed.");
return;
}
[Link]("Under Review", row, 3);
[Link](new Object[]{
[Link]() + 1,
"Clearance Under Review",
"Reviewing clearance of " + [Link](row, 1),
new [Link]().toString()
});
});
// COMPLIANCE PANEL
[Link](new Object[]{"1", "Lorens", "Noise Complaint",
"Pending"});
[Link](new Object[]{"2", "Sample", "Harassment
Complaint", "Pending"});
[Link](new Object[]{"3", "Test", "Littering Complaint",
"Under Review"});
JTable compTable = new JTable(compModel);
JScrollPane compScroll = new JScrollPane(compTable);
JPanel compliancePanel = new JPanel(new BorderLayout());
[Link](compScroll, [Link]);
// BUTTONS
JButton addCompBtn = new JButton("Add Case");
JButton reviewCompBtn = new JButton("Review");
JButton approveCompBtn = new JButton("Resolve");
JButton rejectCompBtn = new JButton("Dismiss");
JPanel compBtnPanel = new JPanel();
[Link](addCompBtn);
[Link](reviewCompBtn);
[Link](approveCompBtn);
[Link](rejectCompBtn);
[Link](compBtnPanel, [Link]);
[Link](e -> {
JTextField nameField = new JTextField();
JTextField violationField = new JTextField();
Object[] fields = {
"Resident Name:", nameField,
"Violation:", violationField
};
int option = [Link](
null,
fields,
"Add Compliance Case",
JOptionPane.OK_CANCEL_OPTION
);
if (option == JOptionPane.OK_OPTION) {
[Link](new Object[]{
[Link]() + 1,
[Link](),
[Link](),
"Pending"
});
[Link](new Object[]{
[Link]() + 1,
"Compliance Added",
"Case for " + [Link](),
new [Link]().toString()
});
updateAllDashboard(
complianceCountLabel,
totalResidentsLabel,
approvedClearancesLabel,
blotterCountLabel,
compModel,
residentModel,
clerModel,
blotterModel
);
}
});
[Link](e -> {
int row = [Link]();
if (row == -1) {
[Link](null, "Select a record first!");
return;
}
if (.equals("Pending")) {
[Link](null, "Only pending cases can
be reviewed.");
return;
}
[Link]("Under Review", row, 3);
});
[Link](e -> {
int row = [Link]();
if (row == -1) {
[Link](null, "Select a record first!");
return;
}
if (.equals("Under Review")) {
[Link](null, "Must review before
resolving.");
return;
}
[Link]("Resolved", row, 3);
});
[Link](e -> {
int row = [Link]();
if (row == -1) {
[Link](null, "Select a record first!");
return;
}
String status = [Link](row, 3).toString();
if (.equals("Under Review")) {
[Link](null, "Must review before
resolving.");
return;
}
String name = [Link](row, 1).toString();
[Link](row);
[Link](new Object[]{
[Link]() + 1,
"Compliance Dismissed",
"Dismissed case of " + name,
new [Link]().toString()
});
updateAllDashboard(
complianceCountLabel,
totalResidentsLabel,
approvedClearancesLabel,
blotterCountLabel,
compModel,
residentModel,
clerModel,
blotterModel
);
});
//BLOTTER PANEL
[Link](new Object[]{"1", "Lorens", "Juan Dela Cruz",
"Noise Disturbance", "Pending"});
[Link](new Object[]{"2", "Maria", "Pedro", "Verbal
Altercation", "Pending"});
JTable blotterTable = new JTable(blotterModel);
JScrollPane blotterScroll = new JScrollPane(blotterTable);
JPanel blotterPanel = new JPanel(new BorderLayout());
[Link](blotterScroll, [Link]);
JButton addBlotterBtn = new JButton("Add Blotter");
JButton reviewBlotterBtn = new JButton("Review");
JButton settleBlotterBtn = new JButton("Settle");
JButton dismissBlotterBtn = new JButton("Dismiss");
JPanel blotterBtnPanel = new JPanel();
[Link](addBlotterBtn);
[Link](reviewBlotterBtn);
[Link](settleBlotterBtn);
[Link](dismissBlotterBtn);
[Link](blotterBtnPanel, [Link]);
[Link](e -> {
JTextField complainantField = new JTextField();
JTextField respondentField = new JTextField();
JTextField incidentField = new JTextField();
Object[] fields = {
"Complainant:", complainantField,
"Respondent:", respondentField,
"Incident:", incidentField
};
int option = [Link](
null,
fields,
"Add Blotter",
JOptionPane.OK_CANCEL_OPTION
);
if (option == JOptionPane.OK_OPTION) {
[Link](new Object[]{
[Link]() + 1,
[Link](),
[Link](),
[Link](),
"Pending"
});
[Link](new Object[]{
[Link]() + 1,
"Blotter Added",
"Incident: " + [Link](),
new [Link]().toString()
});
updateBlotterCount(blotterCountLabel, blotterModel);
}
});
[Link](e -> {
int row = [Link]();
if (row == -1) {
[Link](null, "Select a record first!");
return;
}
String status = [Link](row, 4).toString();
if () {
[Link](null, "Only Pending cases
can be reviewed.");
return;
}
[Link]("Under Investigation", row, 4);
});
[Link](e -> {
int row = [Link]();
if (row == -1) {
[Link](null, "Select a record first!");
return;
}
String status = [Link](row, 4).toString();
if () {
[Link](null, "Blotter must be under
investigation first!");
return;
}
[Link]("Settled", row, 4);
});
[Link](e -> {
int row = [Link]();
if (row == -1) {
[Link](null, "Select a record first!");
return;
}
String status = [Link](row, 4).toString();
if () {
[Link](null, "Blotter must be
reviewed first!");
return;
}
String incident = [Link](row, 3).toString();
[Link](row);
[Link](new Object[]{
[Link]() + 1,
"Blotter Dismissed",
"Dismissed incident: " + incident,
new [Link]().toString()
});
});
[Link](dashboardPanel, "dashboard");
[Link](residentsPanel, "residents");
[Link](clearancePanel, "clearances");
[Link](compliancePanel, "compliance");
[Link](transPanel, "transactions");
[Link](blotterPanel, "blotter");
[Link](e -> {
updateAllDashboard(
complianceCountLabel,
totalResidentsLabel,
approvedClearancesLabel,
blotterCountLabel,compModel,
residentModel,
clerModel,
blotterModel
);
updateBlotterCount(blotterCountLabel, blotterModel);
[Link](contentPanel, "dashboard");
});
[Link](e -> [Link](contentPanel,
"residents"));
[Link](e -> [Link](contentPanel,
"clearances"));
[Link](e -> [Link](contentPanel,
"transactions"));
[Link](e -> [Link](contentPanel,
"compliance"));
[Link](e -> [Link](contentPanel,
"blotter"));
[Link](e -> {
[Link]();
showLogin();
});
JLabel title = new JLabel("Barangay Information System");
[Link](new EmptyBorder(10, 10, 10, 10));
[Link](new Font("Arial", [Link], 18));
[Link](sidebar, [Link]);
[Link](title, [Link]);
[Link](contentPanel, [Link]);
updateAllDashboard(
complianceCountLabel,
totalResidentsLabel,
approvedClearancesLabel,
blotterCountLabel, compModel,
residentModel,
clerModel,
blotterModel
);
[Link](true);
[Link](() -> {
updateAllDashboard(
complianceCountLabel,
totalResidentsLabel,
approvedClearancesLabel,
blotterCountLabel, compModel,
residentModel,
clerModel,
blotterModel
);
});
}
public static JPanel createInfoCard(String title, JLabel valueLabel, Color
color) {
JPanel card = new JPanel();
[Link](new BorderLayout());
[Link](color);
[Link](new Dimension(200, 100));
JLabel titleLabel = new JLabel(title);
[Link]([Link]);
[Link](new Font("Arial", [Link], 14));
[Link]([Link]);
[Link](new Font("Arial", [Link], 24));
[Link](titleLabel, [Link]);
[Link](valueLabel, [Link]);
return card;
public static int countApproved(DefaultTableModel model) {
int count = 0;
for (int i = 0; i < [Link](); i++) {
if ("Approved".equals([Link](i, 3))) {
count++;
}
}
return count;
}
public static void updateAllDashboard(
JLabel compLabel,
JLabel residentLabel,
JLabel clearanceLabel,
JLabel blotterLabel,
DefaultTableModel compModel,
DefaultTableModel resModel,
DefaultTableModel clerModel,
DefaultTableModel blotterModel
){
[Link]([Link]([Link]()));
[Link]([Link]([Link]()));
[Link]([Link](countApproved(clerModel)));
[Link]([Link]([Link]()));
}
public static int countCompliance(DefaultTableModel model) {
return [Link]();
}
public static int countActiveCompliance(DefaultTableModel model) {
int count = 0;
for (int i = 0; i < [Link](); i++) {
String status = [Link](i, 3).toString();
if ([Link]("Pending") || [Link]("Under Review")) {
count++;
}
}
return count;
}
public static void updateBlotterCount(JLabel label, DefaultTableModel
model) {
[Link]([Link]([Link]()));
}
}