Advertisement
Guest User

Untitled

a guest
Jan 24th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.96 KB | None | 0 0
  1. import javafx.application.Application;
  2. import javafx.collections.FXCollections;
  3. import javafx.collections.ObservableList;
  4. import javafx.geometry.Insets;
  5. import javafx.geometry.Pos;
  6. import javafx.scene.Scene;
  7. import javafx.scene.chart.PieChart;
  8. import javafx.scene.control.*;
  9. import javafx.scene.layout.GridPane;
  10. import javafx.scene.layout.HBox;
  11. import javafx.scene.layout.VBox;
  12. import javafx.scene.paint.Color;
  13. import javafx.scene.text.Font;
  14. import javafx.scene.text.FontWeight;
  15. import javafx.scene.text.Text;
  16. import javafx.stage.Stage;
  17.  
  18. import java.io.*;
  19. import java.net.Socket;
  20. import java.util.regex.Pattern;
  21.  
  22. public class Client extends Application {
  23.  
  24. private Socket socket;
  25. private BufferedReader in;
  26. private PrintStream out;
  27.  
  28. @Override
  29. public void start(Stage primaryStage) {
  30.  
  31. // Panel wyboru portu i serwera
  32. //***********************************************************************************
  33. GridPane grid = new GridPane();
  34. grid.setAlignment(Pos.CENTER);
  35. grid.setHgap(10);
  36. grid.setVgap(10);
  37. grid.setPadding(new Insets(25, 25, 25, 25));
  38.  
  39. final Text sceneTitle = new Text("Panel Klienta");
  40. sceneTitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
  41. grid.add(sceneTitle, 0, 0, 2, 1);
  42.  
  43. final Label serverPort = new Label("Podaj port: ");
  44. grid.add(serverPort, 0, 2);
  45.  
  46. TextField portField = new TextField();
  47. grid.add(portField, 1, 2);
  48.  
  49. final Label serverHost = new Label("Podaj adres servera: ");
  50. grid.add(serverHost, 0, 3);
  51.  
  52. TextField hostField = new TextField();
  53. grid.add(hostField, 1, 3);
  54.  
  55. final Label errorMessage = new Label();
  56. grid.add(errorMessage, 1, 7);
  57.  
  58. Button turnOnButton = new Button("Polacz");
  59. HBox hBox = new HBox(10);
  60. hBox.setAlignment(Pos.BOTTOM_RIGHT);
  61. hBox.getChildren().add(turnOnButton);
  62. grid.add(hBox, 1, 5);
  63.  
  64. //****************
  65. //*Wyglad ekranów*
  66. //****************
  67.  
  68. //Przyciski do opuszczenia programu
  69. //**************************************************************************
  70. Button exitt = new Button("Wyjdz");
  71. Button exitt2 = new Button("Wyjdz");
  72. Button exitt3 = new Button("Wyjdz");
  73. Button exitt4 = new Button("Wyjdz");
  74. Button exitt5 = new Button("Wyjdz");
  75. Button exitt6 = new Button("Wyjdz");
  76. Button exitt7 = new Button("Wyjdz");
  77. Button exitt8 = new Button("Wyjdz");
  78. Button exitt9 = new Button("Wyjdz");
  79. Button exitt10 = new Button("Wyjdz");
  80.  
  81. //Przycisko do powrotu
  82. //***************************************************************************
  83. Button back = new Button("Powrot");
  84. Button back2 = new Button("Powrot");
  85. Button back3 = new Button("Powrot");
  86. Button back4 = new Button("Powrot");
  87. Button back5 = new Button("Powrot");
  88. Button back6 = new Button("Powrot");
  89. Button back7 = new Button("Powrot");
  90. Button back8 = new Button("Powrot");
  91. Button back9 = new Button("Powrot");
  92.  
  93. //Wybór trybu użytkownika
  94. //*****************************************************************************
  95. VBox logowanie = new VBox(20);
  96. Label kto = new Label();
  97. RadioButton hurt = new RadioButton();
  98. RadioButton klient = new RadioButton();
  99. Button button2 = new Button("Wybierz");
  100.  
  101. kto.setFont(Font.font(null, FontWeight.BOLD, 20));
  102. hurt.setFont(new Font(16));
  103. klient.setFont(new Font(16));
  104.  
  105. ToggleGroup abc = new ToggleGroup();
  106. hurt.setToggleGroup(abc);
  107. klient.setToggleGroup(abc);
  108.  
  109. button2.setDisable(true);
  110. hurt.setOnAction(e -> button2.setDisable(false));
  111. klient.setOnAction(e -> button2.setDisable(false));
  112. button2.setDisable(true);
  113. exitt3.setDisable(false);
  114.  
  115. logowanie.getChildren().addAll(kto, hurt, klient, button2, exitt3);
  116. logowanie.setAlignment(Pos.CENTER_LEFT);
  117.  
  118. //Panel hurtownii
  119. //***************************************************************************
  120. VBox hurtownia = new VBox(20);
  121. Label akcja = new Label();
  122. RadioButton cennik = new RadioButton();
  123. RadioButton magazyn = new RadioButton();
  124. RadioButton zamawianie = new RadioButton();
  125. Button button3 = new Button("Wybierz");
  126.  
  127. akcja.setFont(Font.font(null, FontWeight.BOLD, 20));
  128. cennik.setFont(new Font(16));
  129. magazyn.setFont(new Font(16));
  130. zamawianie.setFont(new Font(16));
  131.  
  132. ToggleGroup abcd = new ToggleGroup();
  133. cennik.setToggleGroup(abcd);
  134. magazyn.setToggleGroup(abcd);
  135. zamawianie.setToggleGroup(abcd);
  136.  
  137. button3.setDisable(true);
  138. cennik.setOnAction(e -> button3.setDisable(false));
  139. magazyn.setOnAction(e -> button3.setDisable(false));
  140. zamawianie.setOnAction(e -> button3.setDisable(false));
  141. button3.setDisable(true);
  142. back.setDisable(false);
  143. exitt4.setDisable(false);
  144.  
  145.  
  146. hurtownia.getChildren().addAll(akcja, cennik, magazyn, zamawianie, button3, back, exitt4);
  147. hurtownia.setAlignment(Pos.CENTER_LEFT);
  148.  
  149. //Cennik
  150. //******************************************************************
  151. VBox layout = new VBox(20);
  152. Label tytul = new Label();
  153. Label[] produkt = new Label[10];
  154. for (int i = 0; i < 10; i++) {
  155. produkt[i] = new Label();
  156. }
  157.  
  158.  
  159. tytul.setFont(Font.font(null, FontWeight.BOLD, 20));
  160. for (int i = 0; i < 10; i++) {
  161. produkt[i].setFont(Font.font(null, FontWeight.BOLD, 14));
  162. }
  163.  
  164. back2.setDisable(false);
  165. exitt2.setDisable(false);
  166.  
  167. layout.getChildren().addAll(tytul);
  168. for (int i = 0; i < 10; i++) {
  169. layout.getChildren().addAll(produkt[i]);
  170. }
  171. layout.getChildren().addAll(back2, exitt2);
  172.  
  173. layout.setAlignment(Pos.CENTER_LEFT);
  174.  
  175. //Magazyn
  176. //******************************************************************************
  177. VBox magazyn2 = new VBox(20);
  178. Label lab = new Label();
  179. RadioButton stan = new RadioButton();
  180. RadioButton dodaj = new RadioButton();
  181. Button button4 = new Button("Wybierz");
  182.  
  183. lab.setFont(Font.font(null, FontWeight.BOLD, 20));
  184. stan.setFont(new Font(16));
  185. dodaj.setFont(new Font(16));
  186.  
  187. ToggleGroup abcde = new ToggleGroup();
  188. stan.setToggleGroup(abcde);
  189. dodaj.setToggleGroup(abcde);
  190.  
  191. button4.setDisable(true);
  192. stan.setOnAction(e -> button4.setDisable(false));
  193. dodaj.setOnAction(e -> button4.setDisable(false));
  194. button4.setDisable(true);
  195. back3.setDisable(false);
  196. exitt5.setDisable(false);
  197.  
  198. magazyn2.getChildren().addAll(lab, stan, dodaj, button4, back3, exitt5);
  199. magazyn2.setAlignment(Pos.CENTER_LEFT);
  200.  
  201. //Stan magazynu
  202. //******************************************************************************************
  203. VBox stanMag = new VBox(20);
  204. Label tytul2 = new Label();
  205. Label[] produkt2 = new Label[10];
  206. for (int i = 0; i < 10; i++) {
  207. produkt2[i] = new Label();
  208. }
  209.  
  210. tytul2.setFont(Font.font(null, FontWeight.BOLD, 20));
  211. for (int i = 0; i < 10; i++) {
  212. produkt2[i].setFont(Font.font(null, FontWeight.BOLD, 14));
  213. }
  214.  
  215. back4.setDisable(false);
  216. exitt.setDisable(false);
  217.  
  218. stanMag.getChildren().addAll(tytul2);
  219. for (int i = 0; i < 10; i++) {
  220. stanMag.getChildren().addAll(produkt2[i]);
  221. }
  222. stanMag.getChildren().addAll(back4, exitt);
  223.  
  224. stanMag.setAlignment(Pos.CENTER_LEFT);
  225.  
  226. //Dodawanie produktu do magazynu
  227. //******************************************************************************************
  228. VBox dodPro = new VBox(20);
  229. Label tytul3 = new Label();
  230. RadioButton[] produkt3 = new RadioButton[10];
  231. for (int i = 0; i < 10; i++) {
  232. produkt3[i] = new RadioButton();
  233. }
  234. Label ilosc = new Label();
  235. TextField ilosc2 = new TextField();
  236. Button button5 = new Button("Dodaj");
  237.  
  238. tytul3.setFont(Font.font(null, FontWeight.BOLD, 20));
  239. for (int i = 0; i < 10; i++) {
  240. produkt3[i].setFont(new Font(14));
  241. }
  242. ilosc.setFont(Font.font(null, FontWeight.BOLD, 14));
  243.  
  244. ToggleGroup cda = new ToggleGroup();
  245. for (int i = 0; i < 10; i++) {
  246. produkt3[i].setToggleGroup(cda);
  247. }
  248.  
  249. button5.setDisable(true);
  250. for (int i = 0; i < 10; i++) {
  251. produkt3[i].setOnAction(e -> button5.setDisable(false));
  252. }
  253. button5.setDisable(true);
  254. back5.setDisable(false);
  255. exitt6.setDisable(false);
  256.  
  257. dodPro.getChildren().addAll(tytul3);
  258. for (int i = 0; i < 10; i++) {
  259. dodPro.getChildren().addAll(produkt3[i]);
  260. }
  261. dodPro.getChildren().addAll(ilosc, ilosc2, button5, back5, exitt6);
  262.  
  263. dodPro.setAlignment(Pos.CENTER_LEFT);
  264.  
  265. //Zamawianie towarów przez hurtownie
  266. //***************************************************************
  267.  
  268. VBox zamow = new VBox(20);
  269. Label tytul4 = new Label();
  270. RadioButton[] produkt4 = new RadioButton[10];
  271. for (int i = 0; i < 10; i++) {
  272. produkt4[i] = new RadioButton();
  273. }
  274. Label ilosc3 = new Label();
  275. TextField ilosc4 = new TextField();
  276. Button button6 = new Button("Zamów");
  277.  
  278. tytul4.setFont(Font.font(null, FontWeight.BOLD, 20));
  279. for (int i = 0; i < 10; i++) {
  280. produkt4[i].setFont(new Font(14));
  281. }
  282. ilosc3.setFont(Font.font(null, FontWeight.BOLD, 14));
  283.  
  284. ToggleGroup cdac = new ToggleGroup();
  285. for (int i = 0; i < 10; i++) {
  286. produkt4[i].setToggleGroup(cdac);
  287. }
  288.  
  289. button6.setDisable(true);
  290. for (int i = 0; i < 10; i++) {
  291. produkt4[i].setOnAction(e -> button6.setDisable(false));
  292. }
  293. button6.setDisable(true);
  294. back6.setDisable(false);
  295. exitt7.setDisable(false);
  296.  
  297. zamow.getChildren().addAll(tytul4);
  298. for (int i = 0; i < 10; i++) {
  299. zamow.getChildren().addAll(produkt4[i]);
  300. }
  301. zamow.getChildren().addAll(ilosc3, ilosc4, button6, back6, exitt7);
  302.  
  303. zamow.setAlignment(Pos.CENTER_LEFT);
  304.  
  305.  
  306. //Panel klienta
  307. //**************************************************************************
  308. VBox klient2 = new VBox(20);
  309. Label akcja2 = new Label();
  310. RadioButton cennik2 = new RadioButton();
  311. RadioButton zamawianie2 = new RadioButton();
  312. Button button7 = new Button("Wybierz");
  313.  
  314. akcja2.setFont(Font.font(null, FontWeight.BOLD, 20));
  315. cennik2.setFont(new Font(16));
  316. zamawianie2.setFont(new Font(16));
  317.  
  318. ToggleGroup q = new ToggleGroup();
  319. cennik2.setToggleGroup(q);
  320. zamawianie2.setToggleGroup(q);
  321.  
  322. button7.setDisable(true);
  323. cennik2.setOnAction(e -> button7.setDisable(false));
  324. zamawianie2.setOnAction(e -> button7.setDisable(false));
  325. button7.setDisable(true);
  326. back7.setDisable(false);
  327. exitt8.setDisable(false);
  328.  
  329. klient2.getChildren().addAll(akcja2, cennik2, zamawianie2, button7, back7, exitt8);
  330. klient2.setAlignment(Pos.CENTER_LEFT);
  331.  
  332. //Cennik u klienta
  333. //****************************************************************************8
  334.  
  335. VBox layout8 = new VBox(20);
  336. Label tytul8 = new Label();
  337. Label[] produkt8 = new Label[10];
  338. for (int i = 0; i < 10; i++) {
  339. produkt8[i] = new Label();
  340. }
  341.  
  342.  
  343. tytul8.setFont(Font.font(null, FontWeight.BOLD, 20));
  344. for (int i = 0; i < 10; i++) {
  345. produkt8[i].setFont(Font.font(null, FontWeight.BOLD, 14));
  346. }
  347.  
  348. back8.setDisable(false);
  349. exitt9.setDisable(false);
  350.  
  351. layout8.getChildren().addAll(tytul8);
  352. for (int i = 0; i < 10; i++) {
  353. layout8.getChildren().addAll(produkt8[i]);
  354. }
  355. layout8.getChildren().addAll(back8, exitt9);
  356.  
  357. layout8.setAlignment(Pos.CENTER_LEFT);
  358.  
  359. //Zamawianie towarów przez klienta
  360. //***************************************************************
  361.  
  362. VBox zamow9 = new VBox(20);
  363. Label tytul9 = new Label();
  364. RadioButton[] produkt9 = new RadioButton[10];
  365. for (int i = 0; i < 10; i++) {
  366. produkt9[i] = new RadioButton();
  367. }
  368. Label ilosc9 = new Label();
  369. TextField ilosc10 = new TextField();
  370. Button button9 = new Button("Zamów");
  371.  
  372. tytul9.setFont(Font.font(null, FontWeight.BOLD, 20));
  373. for (int i = 0; i < 10; i++) {
  374. produkt9[i].setFont(new Font(14));
  375. }
  376. ilosc9.setFont(Font.font(null, FontWeight.BOLD, 14));
  377.  
  378. ToggleGroup qw = new ToggleGroup();
  379. for (int i = 0; i < 10; i++) {
  380. produkt9[i].setToggleGroup(qw);
  381. }
  382.  
  383. button9.setDisable(true);
  384. for (int i = 0; i < 10; i++) {
  385. produkt9[i].setOnAction(e -> button9.setDisable(false));
  386. }
  387. button9.setDisable(true);
  388. back9.setDisable(false);
  389. exitt10.setDisable(false);
  390.  
  391. zamow9.getChildren().addAll(tytul9);
  392. for (int i = 0; i < 10; i++) {
  393. zamow9.getChildren().addAll(produkt9[i]);
  394. }
  395. zamow9.getChildren().addAll(ilosc9, ilosc10, button9, back9, exitt10);
  396.  
  397. zamow9.setAlignment(Pos.CENTER_LEFT);
  398.  
  399.  
  400.  
  401. //********************
  402. //*Działanie buttonów*
  403. //********************
  404.  
  405. turnOnButton.setOnAction(e -> { //zatwierdzanie wyboru portu i serwera
  406. String portRegex = "[0-9]+";
  407. String hostRegex = "([0-9]{1,3}.){3}[0-9]{1,3}";
  408. if (Pattern.matches(portRegex, portField.getText().toString()) && Pattern.matches(hostRegex, hostField.getText().toString())) {
  409. try {
  410. socket = new Socket(hostField.getText().toString(), Integer.parseInt(portField.getText().toString()));
  411. in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
  412. out = new PrintStream(socket.getOutputStream());
  413. hBox.getChildren().remove(turnOnButton);
  414. grid.getChildren().removeAll(sceneTitle, serverPort, portField, serverHost, hostField, hBox, errorMessage);
  415.  
  416. kto.setText("Jako kto chcesz sie zalogowac?");
  417. hurt.setText("Hurtowania");
  418. klient.setText("Klient");
  419.  
  420. grid.getChildren().setAll(logowanie);
  421.  
  422. } catch (IOException e1) {
  423. errorMessage.setText("Nie udalo sie polaczyc z serverem!");
  424. errorMessage.setTextFill(Color.RED);
  425. }
  426. } else {
  427. errorMessage.setText("Podano bledne dane!");
  428. errorMessage.setTextFill(Color.RED);
  429. }
  430. });
  431.  
  432. button2.setOnAction(e -> { //zatwierdzenie wyboru hurtowni/klienta
  433.  
  434. int a=0;
  435. if (hurt.isSelected()) {
  436. a=1;
  437. } else if(klient.isSelected()) {
  438. a=2;
  439. }
  440.  
  441. logowanie.getChildren().remove(button2);
  442. grid.getChildren().removeAll(kto, hurt, klient, logowanie);
  443.  
  444. if (a==1) { //panel hurtownii
  445. akcja.setText("Co chcesz zrobic?");
  446. cennik.setText("Otworz cennik");
  447. magazyn.setText("Sprawdz zawartosc magazynu");
  448. zamawianie.setText("Zamow towary");
  449.  
  450. grid.getChildren().setAll(hurtownia);
  451. } else if (a==2) { //panel klienta
  452. akcja2.setText("Co chcesz zrobic?");
  453. cennik2.setText("Otworz cennik hurtowni");
  454. zamawianie2.setText("Zamow towary z hurtowni");
  455.  
  456. grid.getChildren().setAll(klient2);
  457. }
  458. });
  459.  
  460. button3.setOnAction(e -> { //zatwierdzenie wyboru cennika/magazynu/zamawiania
  461.  
  462. int i=0;
  463. try {
  464.  
  465. if (cennik.isSelected()) {
  466. i=1;
  467. } else if (magazyn.isSelected()) {
  468. i=2;
  469. } else if (zamawianie.isSelected()) {
  470. i=3;
  471. }
  472.  
  473. hurtownia.getChildren().remove(button3);
  474. grid.getChildren().removeAll(akcja, cennik, magazyn, zamawianie, hurtownia);
  475.  
  476. if (i==1) { //cennik
  477.  
  478. out.println("cennik");
  479. tytul.setText("Cennik");
  480. for (int j = 0; j < 10; j++) {
  481. produkt[j].setText(in.readLine() + " - " + in.readLine() + "zl/kg");
  482. }
  483. grid.getChildren().setAll(layout);
  484.  
  485. } else if (i==2) { //magazyn
  486.  
  487. lab.setText("Co chcesz zrobic?");
  488. stan.setText("Sprawdz stan magazynu");
  489. dodaj.setText("Dodaj produkt");
  490.  
  491. grid.getChildren().setAll(magazyn2);
  492.  
  493. } else if (i==3) { //zamawianie
  494.  
  495. out.println("zamow");
  496.  
  497. tytul4.setText("Wybierz produkt który chcesz zamówić");
  498.  
  499. for (int j = 0; j < 10; j++) {
  500. produkt4[j].setText(in.readLine() + " | " + in.readLine() + "zl/kg");
  501. }
  502.  
  503. ilosc3.setText("Podaj ilosc produktu(w kg)");
  504.  
  505.  
  506. grid.getChildren().setAll(zamow);
  507. ilosc4.getText();
  508. }
  509.  
  510. } catch (IOException e1) {
  511. errorMessage.setText("Nie udalo sie polaczyc z serverem!");
  512. errorMessage.setTextFill(Color.RED);
  513. }
  514.  
  515. });
  516.  
  517. button4.setOnAction(e -> { // zatwierdzenie wyboru stanMagazynu/dodawanieProduktów
  518. int i=0;
  519. try {
  520.  
  521. if (stan.isSelected()) {
  522. i=1;
  523. } else if (dodaj.isSelected()) {
  524. i=2;
  525. }
  526. magazyn2.getChildren().remove(button4);
  527. grid.getChildren().removeAll(lab, stan, dodaj, magazyn2);
  528. if (i==1) { //stan magazynu
  529.  
  530. out.println("magazyn");
  531. tytul2.setText("Stan magazynu");
  532. for (int j = 0; j < 10; j++) {
  533. produkt2[j].setText(in.readLine() + " - " + in.readLine() + "kg");
  534.  
  535. }
  536.  
  537. grid.getChildren().setAll(stanMag);
  538.  
  539. } else if (i==2) { //dodawanie produktow
  540.  
  541. out.println("dodaj");
  542.  
  543. tytul3.setText("Wybierz produkt z listy");
  544.  
  545. for (int j = 0; j < 10; j++) {
  546. produkt3[j].setText(in.readLine());
  547. }
  548.  
  549. ilosc.setText("Podaj ilosc produktu(w kg)");
  550.  
  551.  
  552. grid.getChildren().setAll(dodPro);
  553. ilosc2.getText();
  554. }
  555.  
  556. } catch (IOException e1) {
  557. errorMessage.setText("Nie udalo sie polaczyc z serverem!");
  558. errorMessage.setTextFill(Color.RED);
  559. }
  560.  
  561. });
  562.  
  563.  
  564. button5.setOnAction(e -> { //zatwierdzenie dodania produktu
  565.  
  566. if (produkt3[0].isSelected()) {
  567. out.println("1");
  568. out.println(ilosc2.getText().toString());
  569.  
  570. } else if (produkt3[1].isSelected()) {
  571.  
  572. out.println("2");
  573. out.println(ilosc2.getText().toString());
  574.  
  575. } else if (produkt3[2].isSelected()) {
  576.  
  577. out.println("3");
  578. out.println(ilosc2.getText().toString());
  579.  
  580. } else if (produkt3[3].isSelected()) {
  581.  
  582. out.println("4");
  583. out.println(ilosc2.getText().toString());
  584.  
  585. } else if (produkt3[4].isSelected()) {
  586.  
  587. out.println("5");
  588. out.println(ilosc2.getText().toString());
  589.  
  590. } else if (produkt3[5].isSelected()) {
  591.  
  592. out.println("6");
  593. out.println(ilosc2.getText().toString());
  594.  
  595. } else if (produkt3[6].isSelected()) {
  596.  
  597. out.println("7");
  598. out.println(ilosc2.getText().toString());
  599.  
  600. } else if (produkt3[7].isSelected()) {
  601.  
  602. out.println("8");
  603. out.println(ilosc2.getText().toString());
  604.  
  605. } else if (produkt3[8].isSelected()) {
  606.  
  607. out.println("9");
  608. out.println(ilosc2.getText().toString());
  609.  
  610. } else if (produkt3[9].isSelected()) {
  611.  
  612. out.println("10");
  613. out.println(ilosc2.getText().toString());
  614. }
  615.  
  616. });
  617.  
  618. button6.setOnAction(e -> { //zatwierdzenie dodania produktu
  619.  
  620. if (produkt4[0].isSelected()) {
  621. out.println("1");
  622. out.println(ilosc4.getText().toString());
  623.  
  624. } else if (produkt4[1].isSelected()) {
  625.  
  626. out.println("2");
  627. out.println(ilosc4.getText().toString());
  628.  
  629. } else if (produkt4[2].isSelected()) {
  630.  
  631. out.println("3");
  632. out.println(ilosc4.getText().toString());
  633.  
  634. } else if (produkt4[3].isSelected()) {
  635.  
  636. out.println("4");
  637. out.println(ilosc4.getText().toString());
  638.  
  639. } else if (produkt4[4].isSelected()) {
  640.  
  641. out.println("5");
  642. out.println(ilosc4.getText().toString());
  643.  
  644. } else if (produkt4[5].isSelected()) {
  645.  
  646. out.println("6");
  647. out.println(ilosc4.getText().toString());
  648.  
  649. } else if (produkt4[6].isSelected()) {
  650.  
  651. out.println("7");
  652. out.println(ilosc4.getText().toString());
  653.  
  654. } else if (produkt4[7].isSelected()) {
  655.  
  656. out.println("8");
  657. out.println(ilosc4.getText().toString());
  658.  
  659. } else if (produkt4[8].isSelected()) {
  660.  
  661. out.println("9");
  662. out.println(ilosc4.getText().toString());
  663.  
  664. } else if (produkt4[9].isSelected()) {
  665.  
  666. out.println("10");
  667. out.println(ilosc4.getText().toString());
  668. }
  669.  
  670. });
  671.  
  672. button7.setOnAction(e -> {
  673.  
  674. int b=0;
  675. try {
  676.  
  677. if (cennik2.isSelected()) {
  678. b=1;
  679. } else if (zamawianie2.isSelected()) {
  680. b=2;
  681. }
  682.  
  683. klient2.getChildren().remove(button7);
  684. grid.getChildren().removeAll(akcja2, cennik2, zamawianie2, klient2);
  685.  
  686. if (b==1) { //cennik klienta
  687.  
  688. out.println("cennik2");
  689. tytul8.setText("Cennik");
  690. for (int j = 0; j < 10; j++) {
  691. produkt8[j].setText(in.readLine() + " - " + in.readLine() + "zl/kg");
  692. }
  693. grid.getChildren().setAll(layout8);
  694.  
  695. } else if (b==2) { //zamawianie
  696.  
  697. out.println("zamow2");
  698.  
  699. tytul9.setText("Wybierz produkt który chcesz zamówić");
  700.  
  701. for (int j = 0; j < 10; j++) {
  702. produkt9[j].setText(in.readLine() + " | " + in.readLine() + "zl/kg");
  703. }
  704.  
  705. ilosc9.setText("Podaj ilosc produktu(w kg)");
  706.  
  707.  
  708. grid.getChildren().setAll(zamow9);
  709. ilosc10.getText();
  710. }
  711.  
  712. } catch (IOException e1) {
  713. errorMessage.setText("Nie udalo sie polaczyc z serverem!");
  714. errorMessage.setTextFill(Color.RED);
  715. }
  716.  
  717. });
  718.  
  719. back.setOnAction(e -> {
  720.  
  721. hurtownia.getChildren().remove(button3);
  722. grid.getChildren().removeAll(akcja, cennik, magazyn, zamawianie, hurtownia);
  723.  
  724. kto.setText("Jako kto chcesz sie zalogowac?");
  725. hurt.setText("Hurtowania");
  726. klient.setText("Klient");
  727.  
  728. grid.getChildren().setAll(logowanie);
  729.  
  730. });
  731. back2.setOnAction(e -> {
  732.  
  733. grid.getChildren().removeAll(layout);
  734.  
  735. akcja.setText("Co chcesz zrobic?");
  736. cennik.setText("Otworz cennik");
  737. magazyn.setText("Sprawdz zawartosc magazynu");
  738. zamawianie.setText("Zamow towary");
  739.  
  740. grid.getChildren().setAll(hurtownia);
  741.  
  742. });
  743.  
  744. back3.setOnAction(e -> {
  745.  
  746. grid.getChildren().removeAll(magazyn2);
  747.  
  748. akcja.setText("Co chcesz zrobic?");
  749. cennik.setText("Otworz cennik");
  750. magazyn.setText("Sprawdz zawartosc magazynu");
  751. zamawianie.setText("Zamow towary");
  752.  
  753. grid.getChildren().setAll(hurtownia);
  754.  
  755. });
  756.  
  757. back4.setOnAction(e -> {
  758.  
  759. grid.getChildren().removeAll(stanMag);
  760.  
  761. lab.setText("Co chcesz zrobic?");
  762. stan.setText("Sprawdz stan magazynu");
  763. dodaj.setText("Dodaj produkt");
  764.  
  765. grid.getChildren().setAll(magazyn2);
  766. });
  767.  
  768. back5.setOnAction(e -> {
  769.  
  770. grid.getChildren().removeAll(dodPro);
  771.  
  772. lab.setText("Co chcesz zrobic?");
  773. stan.setText("Sprawdz stan magazynu");
  774. dodaj.setText("Dodaj produkt");
  775.  
  776. grid.getChildren().setAll(magazyn2);
  777.  
  778. });
  779.  
  780. back6.setOnAction(e -> {
  781.  
  782. grid.getChildren().removeAll(zamow);
  783.  
  784. akcja.setText("Co chcesz zrobic?");
  785. cennik.setText("Otworz cennik");
  786. magazyn.setText("Sprawdz zawartosc magazynu");
  787. zamawianie.setText("Zamow towary");
  788.  
  789. grid.getChildren().setAll(hurtownia);
  790.  
  791. });
  792.  
  793. back7.setOnAction(e -> {
  794.  
  795. klient2.getChildren().remove(button7);
  796. grid.getChildren().removeAll(akcja2, cennik2, zamawianie2, klient2);
  797.  
  798. kto.setText("Jako kto chcesz sie zalogowac?");
  799. hurt.setText("Hurtowania");
  800. klient.setText("Klient");
  801.  
  802. grid.getChildren().setAll(logowanie);
  803.  
  804. });
  805.  
  806. back8.setOnAction(e -> {
  807.  
  808. grid.getChildren().removeAll(layout8);
  809.  
  810. akcja2.setText("Co chcesz zrobic?");
  811. cennik2.setText("Otworz cennik hurtowni");
  812. zamawianie2.setText("Zamow towary z hurtowni");
  813.  
  814. grid.getChildren().setAll(klient2);
  815. });
  816.  
  817. back9.setOnAction(e -> {
  818.  
  819. grid.getChildren().removeAll(zamow9);
  820.  
  821. akcja2.setText("Co chcesz zrobic?");
  822. cennik2.setText("Otworz cennik hurtowni");
  823. zamawianie2.setText("Zamow towary z hurtowni");
  824.  
  825. grid.getChildren().setAll(klient2);
  826.  
  827. });
  828.  
  829. exitt.setOnAction(e -> {
  830.  
  831. out.println("exit");
  832. System.exit(0);
  833.  
  834. });
  835. exitt2.setOnAction(e -> {
  836.  
  837. out.println("exit");
  838. System.exit(0);
  839.  
  840. });
  841.  
  842. exitt3.setOnAction(e -> {
  843.  
  844. out.println("exit");
  845. System.exit(0);
  846.  
  847. });
  848.  
  849. exitt4.setOnAction(e -> {
  850.  
  851. out.println("exit");
  852. System.exit(0);
  853.  
  854. });
  855.  
  856. exitt5.setOnAction(e -> {
  857.  
  858. out.println("exit");
  859. System.exit(0);
  860.  
  861. });
  862.  
  863. exitt6.setOnAction(e -> {
  864.  
  865. out.println("exit");
  866. System.exit(0);
  867.  
  868. });
  869.  
  870. exitt7.setOnAction(e -> {
  871.  
  872. out.println("exit");
  873. System.exit(0);
  874.  
  875. });
  876.  
  877. exitt8.setOnAction(e -> {
  878.  
  879. out.println("exit");
  880. System.exit(0);
  881.  
  882. });
  883.  
  884. exitt9.setOnAction(e -> {
  885.  
  886. out.println("exit");
  887. System.exit(0);
  888.  
  889. });
  890.  
  891. exitt10.setOnAction(e -> {
  892.  
  893. out.println("exit");
  894. System.exit(0);
  895.  
  896. });
  897.  
  898. Scene scene = new Scene(grid, 1200, 700);
  899. primaryStage.setScene(scene);
  900. primaryStage.setTitle("Hurtownia");
  901. primaryStage.show();
  902. }
  903.  
  904. @Override
  905. public void stop() throws Exception {
  906. super.stop();
  907. out.close();
  908. in.close();
  909. socket.close();
  910. }
  911.  
  912. public static void main(String[] args) throws IOException {
  913. launch(args);
  914. }
  915.  
  916. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement