Skip to content

Commit e918b31

Browse files
Merge pull request #346 from Ankit-3130/main
billing-system
2 parents fcc614c + 28ee9a7 commit e918b31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2368
-0
lines changed

Billing-system/.classpath

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="src" path="img"/>
5+
<classpathentry kind="src" path="res"/>
6+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
7+
<classpathentry kind="output" path="bin"/>
8+
</classpath>

Billing-system/.project

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>RestaurantBillingSystem</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?import javafx.scene.control.Button?>
4+
<?import javafx.scene.control.Label?>
5+
<?import javafx.scene.control.PasswordField?>
6+
<?import javafx.scene.control.TextField?>
7+
<?import javafx.scene.layout.AnchorPane?>
8+
<?import javafx.scene.text.Font?>
9+
10+
<AnchorPane id="pane" prefHeight="400" prefWidth="600" stylesheets="@login.css" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="billingsystem.MainController">
11+
<children>
12+
<Button fx:id="login" layoutX="254.0" layoutY="296.0" mnemonicParsing="false" onAction="#handleLogin" prefHeight="24.0" prefWidth="93.0" text="Login">
13+
<font>
14+
<Font name="System Bold" size="12.0" />
15+
</font></Button>
16+
<TextField fx:id="user" layoutX="226.0" layoutY="166.0" onAction="#handleLogin" />
17+
<PasswordField fx:id="pwdFld" layoutX="226.0" layoutY="216.0" onAction="#handleLogin" />
18+
<Label layoutX="226.0" layoutY="141.0" prefHeight="25.0" prefWidth="149.0" text="Username" textFill="IVORY" />
19+
<Label layoutX="226.0" layoutY="191.0" prefHeight="25.0" prefWidth="149.0" text="Password" textFill="IVORY" />
20+
<Label alignment="CENTER" layoutX="151.0" layoutY="52.0" prefHeight="54.0" prefWidth="299.0" text="Restaurant Billing System" textFill="IVORY">
21+
<font>
22+
<Font name="System Bold" size="20.0" />
23+
</font>
24+
</Label>
25+
</children>
26+
</AnchorPane>
4.32 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2.71 KB
Binary file not shown.
1.95 KB
Binary file not shown.
886 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#pane {
2+
-fx-background-image:url('login.jpg');
3+
}
22.6 KB
Loading

Billing-system/bin/login.jpg

22.6 KB
Loading

Billing-system/bin/main.jpg

304 KB
Loading

Billing-system/bin/main_area.jpg

890 KB
Loading
1.5 KB
Binary file not shown.

Billing-system/img/login.jpg

22.6 KB
Loading

Billing-system/img/main.jpg

304 KB
Loading

Billing-system/img/main_area.jpg

890 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?import javafx.scene.control.Button?>
4+
<?import javafx.scene.control.Label?>
5+
<?import javafx.scene.control.PasswordField?>
6+
<?import javafx.scene.control.TextField?>
7+
<?import javafx.scene.layout.AnchorPane?>
8+
<?import javafx.scene.text.Font?>
9+
10+
<AnchorPane id="pane" prefHeight="400" prefWidth="600" stylesheets="@login.css" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="billingsystem.MainController">
11+
<children>
12+
<Button fx:id="login" layoutX="254.0" layoutY="296.0" mnemonicParsing="false" onAction="#handleLogin" prefHeight="24.0" prefWidth="93.0" text="Login">
13+
<font>
14+
<Font name="System Bold" size="12.0" />
15+
</font></Button>
16+
<TextField fx:id="user" layoutX="226.0" layoutY="166.0" onAction="#handleLogin" />
17+
<PasswordField fx:id="pwdFld" layoutX="226.0" layoutY="216.0" onAction="#handleLogin" />
18+
<Label layoutX="226.0" layoutY="141.0" prefHeight="25.0" prefWidth="149.0" text="Username" textFill="IVORY" />
19+
<Label layoutX="226.0" layoutY="191.0" prefHeight="25.0" prefWidth="149.0" text="Password" textFill="IVORY" />
20+
<Label alignment="CENTER" layoutX="151.0" layoutY="52.0" prefHeight="54.0" prefWidth="299.0" text="Restaurant Billing System" textFill="IVORY">
21+
<font>
22+
<Font name="System Bold" size="20.0" />
23+
</font>
24+
</Label>
25+
</children>
26+
</AnchorPane>
+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
package billingsystem;
2+
3+
import java.io.FileInputStream;
4+
import java.io.FileOutputStream;
5+
import java.io.IOException;
6+
import java.io.ObjectInputStream;
7+
import java.io.ObjectOutputStream;
8+
import java.util.ArrayList;
9+
import java.util.logging.FileHandler;
10+
import java.util.logging.Level;
11+
import java.util.logging.Logger;
12+
import java.util.logging.SimpleFormatter;
13+
14+
import javafx.application.Application;
15+
import javafx.fxml.FXMLLoader;
16+
import javafx.stage.Stage;
17+
import javafx.scene.Parent;
18+
import javafx.scene.Scene;
19+
20+
/**
21+
*
22+
* @author Jason Li
23+
* @version 1.0
24+
* @since 19.12.2016
25+
*
26+
*
27+
* The Class Main.
28+
*/
29+
public class Main extends Application {
30+
31+
/** The Constant logger. */
32+
private static final Logger logger = Logger.getLogger(Main.class.getName());
33+
34+
/** The fh log. */
35+
private static FileHandler fhLog;
36+
37+
/** The user path. */
38+
private String userPath = "res/users.ser";
39+
40+
/** The log path. */
41+
private String logPath = "res/activity.log";
42+
43+
/** The root admin. */
44+
private final String rootAdmin = "admin";
45+
46+
/** The users list. */
47+
private ArrayList<User> usersList = null;
48+
49+
/** The jarpath. */
50+
private String jarpath;
51+
52+
/* (non-Javadoc)
53+
* @see javafx.application.Application#start(javafx.stage.Stage)
54+
*/
55+
@Override
56+
public void start(Stage primaryStage) {
57+
58+
try {
59+
fhLog = new FileHandler(logPath, true);
60+
logger.addHandler(fhLog);
61+
SimpleFormatter formatter = new SimpleFormatter();
62+
fhLog.setFormatter(formatter);
63+
} catch (SecurityException e) {
64+
logger.log(Level.SEVERE, "" + e);
65+
} catch (IOException e) {
66+
logger.log(Level.WARNING,
67+
"Logger could not be set up to log to activity log. Logs will only be displayed in the console. \n"
68+
+ e);
69+
}
70+
try {
71+
try {
72+
FileInputStream fileIn = new FileInputStream(userPath);
73+
ObjectInputStream in = new ObjectInputStream(fileIn);
74+
usersList = (ArrayList<User>) in.readObject();
75+
in.close();
76+
fileIn.close();
77+
} catch (IOException i) {
78+
logger.log(Level.INFO, "Root admin account 'admin' created on first time login.");
79+
// Create admin account if not existent
80+
User admin = new User(rootAdmin, "", true);
81+
usersList = new ArrayList<User>();
82+
usersList.add(admin);
83+
try {
84+
// Create user list with initial admin account
85+
FileOutputStream fileOut = new FileOutputStream(userPath);
86+
ObjectOutputStream out = new ObjectOutputStream(fileOut);
87+
out.writeObject(usersList);
88+
out.close();
89+
fileOut.close();
90+
} catch (IOException i2) {
91+
logger.log(Level.WARNING, "" + i2);
92+
}
93+
}
94+
95+
// Create Login Screen
96+
Parent root = FXMLLoader.load(getClass().getResource("/billingsystem/Login.fxml"));
97+
Scene scene = new Scene(root);
98+
scene.getStylesheets().add(getClass().getResource("login.css").toExternalForm());
99+
primaryStage.setScene(scene);
100+
primaryStage.setResizable(false);
101+
primaryStage.show();
102+
fhLog.close();
103+
104+
} catch (Exception e) {
105+
logger.log(Level.SEVERE,
106+
"Login Screen file has been deleted or is corrupted. Please restore 'Login.fxml' links. \n" + e);
107+
}
108+
}
109+
110+
/**
111+
* The main method.
112+
*
113+
* @param args the arguments
114+
*/
115+
public static void main(String[] args) {
116+
launch(args);
117+
}
118+
}

0 commit comments

Comments
 (0)