import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.scene.text.*;
import javafx.scene.text.Text.*;
import javafx.stage.Stage;
import javafx.scene.control.TextField;
import javafx.scene.layout.VBox;
import javafx.collections.*;
public class pointofsales extends Application
{
int harganya;
@Override
public void start (Stage stage) throws Exception
{
GridPane gridPane = new GridPane();
gridPane.setMinSize(200, 200);
gridPane.setPadding(new Insets(10, 10, 10, 10));
gridPane.setVgap(5);
gridPane.setHgap(5);
Text title = new Text ("Nama Kasir : ");
Text kodebarang = new Text ("Kode Barang : ");
Text namabarang = new Text ("Nama Barang : ");
Text harga = new Text ("Harga : ");
Text jumlahbeli = new Text ("jumlah beli : ");
Text totalbayar = new Text ("Total Bayar : ");
Button cetak = new Button("Cetak");
TextField textField1 = new TextField();
TextField textField2 = new TextField();
//Text final_box = new Text();
Text hargabar = new Text();
Text namabox = new Text();
Text hargatot = new Text();
//String kasir[]= {"Chintya", "Natasha", "Miranda", "Tanyaqila", "Fitriana"};
//ComboBox final_box =
// new ComboBox(FXCollections.observableArrayList(kasir));
gridPane.add(new Label("Nama Kasir: "), 0,1 );
//gridPane.add(final_box, 1,0);
gridPane.add(kodebarang, 0, 2);
gridPane.add(namabarang, 0, 3);
gridPane.add(harga, 0, 4);
gridPane.add(jumlahbeli, 0, 5);
gridPane.add(totalbayar, 0, 6);
gridPane.add(textField1, 1, 1);
gridPane.add(textField2, 1, 5);
gridPane.add(cetak,3,8);
String kodebar[] = {"S001","S002","S003","S004","S005", "S006", "S007", "S008",
"S009","S010"};
ComboBox combo_box =
new ComboBox(FXCollections.observableArrayList(kodebar));
gridPane.add(combo_box,1,2);
EventHandler<ActionEvent> event =
new EventHandler<ActionEvent>()
{
public void handle(ActionEvent e)
{
if (combo_box.getValue()=="S001")
{
namabox.setText ("Sabun");
hargabar.setText ( "Rp. 2500");
harganya=2500;
}
else if (combo_box.getValue()== "S002")
{
namabox.setText ("Sampo");
hargabar.setText ( "Rp. 3000");
harganya=3000;
}
else if (combo_box.getValue()== "S003")
{
namabox.setText ("Odol");
hargabar.setText ( "Rp. 15000");
harganya =15000;
}
else if (combo_box.getValue()== "S004")
{
namabox.setText ("Facewash");
hargabar.setText ( "Rp. 55000");
harganya=55000;
}
else if (combo_box.getValue()== "S005")
{
namabox.setText ("Sikat Gigi");
hargabar.setText ( "Rp. 25000");
harganya=25000;
}
else if (combo_box.getValue()== "S006")
{
namabox.setText ("Lulur");
hargabar.setText ( "Rp. 34000");
harganya=34000;
}
else if (combo_box.getValue()== "S007")
{
namabox.setText ("Conditioner");
hargabar.setText ( "Rp. 24000");
harganya=24000;
}
else if (combo_box.getValue()== "S008")
{
namabox.setText ("Toner");
hargabar.setText ( "Rp. 57000");
harganya=57000;
}
else if (combo_box.getValue()== "S009")
{
namabox.setText ("Cleature Vitamin E+");
hargabar.setText ( "Rp. 550000");
harganya=550000;
}
else if (combo_box.getValue()== "S010")
{
namabox.setText ("Cleanser Oil Free");
hargabar.setText ( "Rp. 170000");
harganya=170000;
}
}
};
combo_box.setOnAction(event);
gridPane.add(namabox,1,3);
gridPane.add(hargabar,1,4);
EventHandler<ActionEvent> event1 = new EventHandler<ActionEvent>()
{
public void handle(ActionEvent e)
{
int jumlah = Integer.parseInt(textField2.getText());
jumlah = jumlah * harganya;
hargatot.setText (String.valueOf("Rp. " + jumlah));
}
};
textField2.setOnAction(event1);
gridPane.add(hargatot,1,6);
EventHandler<ActionEvent> ebutton = new EventHandler<ActionEvent>()
{
public void handle(ActionEvent e)
{
VBox box = new VBox();
box.setPadding(new Insets(20));
box.setSpacing(20);
box.setAlignment(Pos.TOP_LEFT);
Text bukti = new Text("BUKTI PEMBAYARAN TOKO BERSIH POL");
//Text kasirkuq = new Text("Nama Kasir : "+kasir.getText());
Text nambar = new Text("Nama Barang : "+namabox.getText());
Text jumbar = new Text("Jumlah Barang : "+textField2.getText());
Text harpi = new Text(" Harga Barang : " +hargabar.getText());
Text harbar = new Text("Total Bayar : "+hargatot.getText());
Text ywd = new Text("Transaction :: Success");
Text yeddd = new Text ("Nama Kasir : " +textField1.getText());
Text bacot = new Text (" - Suwun Pol Pelangganku - ");
box.getChildren().add(bukti);
box.getChildren().add(yeddd);
box.getChildren().add(nambar);
box.getChildren().add(jumbar);
box.getChildren().add(harpi);
box.getChildren().add(harbar);
box.getChildren().add(ywd);
box.getChildren().add(bacot);
Scene scene1= new Scene(box,400,400);
stage.setTitle (" Point Of Sales");
stage.setScene(scene1);
stage.show();
}
};
cetak.setOnAction(ebutton);
Scene scene= new Scene(gridPane,400,400);
stage.setTitle (" Point Of Sales");
stage.setScene(scene);
stage.show();
}
}