Advertisement
Guest User

Untitled

a guest
Feb 13th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.42 KB | None | 0 0
  1. **
  2.  
  3. package com.hyundai;
  4. import java.awt.Image;
  5. import java.awt.Toolkit;
  6. import java.awt.event.ActionEvent;
  7. import java.awt.event.ActionListener;
  8. import java.awt.event.ItemEvent;
  9. import java.awt.event.ItemListener;
  10. import java.awt.event.KeyEvent;
  11. import java.sql.Connection;
  12. import java.sql.DriverManager;
  13. import java.sql.ResultSet;
  14. import java.sql.Statement;
  15. import java.text.DateFormat;
  16. import java.text.SimpleDateFormat;
  17. import java.util.Calendar;
  18. import javax.swing.AbstractAction;
  19. import javax.swing.Action;
  20. import javax.swing.ActionMap;
  21. import javax.swing.InputMap;
  22. import javax.swing.JButton;
  23. import javax.swing.JCheckBox;
  24. import javax.swing.JComboBox;
  25. import javax.swing.JComponent;
  26. import javax.swing.JFrame;
  27. import javax.swing.JLabel;
  28. import javax.swing.JMenu;
  29. import javax.swing.JMenuBar;
  30. import javax.swing.JMenuItem;
  31. import javax.swing.JRootPane;
  32. import javax.swing.JTextField;
  33. import javax.swing.KeyStroke;
  34. public class EmptyIn
  35. {
  36. protected static String st1;
  37. public static void main(String[] args)
  38. {
  39. new EmptyIn();
  40. }
  41. final JFrame f;
  42. JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15,l16,l17,l18,l19;
  43. static JTextField tf1;
  44. JTextField tf2, tf3, tf4, tf5, tf6, tf7, tf8,tf9, tf10, tf11, tf12;
  45. String Import_Type[]={" ","Direct-Out","De-Stuffing","OutSide-Empty","Port-
  46. Cfs","Cfs-Bond","Lcl"};
  47. JComboBox cb;
  48. DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
  49. Calendar cal = Calendar.getInstance();
  50. JMenu Export,Import,Report,LogOff,Admin;
  51. JMenuItem In,Out,Daily,Monthly,Yearly,logoff,createuser,deleteuser;
  52. final JCheckBox
  53. check1,check2,check3,check4,check5,check6,check7,check8,check9,check10;
  54. JButton btn1,btn2,btn3,btn4,btn5,btn6;
  55. JMenuBar mb ;
  56. EmptyIn()
  57. {
  58. f = new JFrame("Empty-In");
  59. mb = new JMenuBar();
  60. Export = new JMenu("Export");
  61. Import = new JMenu("Import");
  62. Report = new JMenu("Report");
  63. Admin = new JMenu("Admin");
  64. LogOff = new JMenu("Log-Off");
  65. In = new JMenuItem("Empty-In");
  66. In.addActionListener(new ActionListener()
  67. { public void actionPerformed(ActionEvent e)
  68. {
  69. f.dispose();
  70. new EmptyIn();
  71. }
  72. });
  73. Out = new JMenuItem("Empty-Out");
  74. Out.addActionListener(new ActionListener()
  75. { public void actionPerformed(ActionEvent e)
  76. {
  77. f.dispose();
  78. new EmptyOut();
  79. }
  80. });
  81. Daily = new JMenuItem("Daily");
  82. Monthly = new JMenuItem("Monthly");
  83. Yearly = new JMenuItem("Yearly");
  84. mb.add(Import);
  85. mb.add(Export);
  86. mb.add(Report);
  87. mb.add(Admin);
  88. mb.add(LogOff);
  89. Import.add(In);
  90. Export.add(Out);
  91. Report.add(Daily);
  92. Report.addSeparator();
  93. Report.add(Monthly);
  94. Report.addSeparator();
  95. Report.add(Yearly);
  96. createuser = new JMenuItem("Add User");
  97. deleteuser = new JMenuItem("Delete User");
  98. Admin.add(createuser);
  99. createuser.addActionListener(new ActionListener()
  100. {
  101. @Override
  102. public void actionPerformed(ActionEvent e)
  103. {
  104. f.dispose();
  105. new CreateUser();
  106. }
  107. });
  108. Admin.addSeparator();
  109. Admin.add(deleteuser);
  110. logoff = new JMenuItem("Log Off");
  111. logoff.addActionListener(new ActionListener()
  112. { public void actionPerformed(ActionEvent e)
  113. {
  114. f.dispose();
  115. new Login();
  116. }
  117. });
  118. LogOff.add(logoff);
  119. JRootPane rootPane = f.getRootPane();
  120. ActionMap actionMap = rootPane.getActionMap();
  121. Action menuAction = new AbstractAction() {
  122. @Override
  123. public void actionPerformed(ActionEvent e) {
  124. JRootPane rootPane = f.getRootPane();
  125. JMenuBar jMenuBar = rootPane.getJMenuBar();
  126. JMenu menu = jMenuBar.getMenu(0);
  127. menu.doClick();
  128. }
  129. };
  130. final String MENU_ACTION_KEY = "expand_that_first_menu_please";
  131. actionMap.put(MENU_ACTION_KEY, menuAction);
  132. InputMap inputMap =
  133. rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
  134. inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ALT, 0, true),
  135. MENU_ACTION_KEY);
  136. f.setJMenuBar(mb);
  137. l1 = new JLabel("Receipt Number");
  138. l1.setBounds(250,75, 150,30);
  139. f.add(l1);
  140. tf1 = new JTextField(15);
  141. tf1.setBounds(400, 80, 250, 20);
  142. f.add(tf1);
  143. l2 = new JLabel("Container Number");
  144. l2.setBounds(250,100, 150,30);
  145. f.add(l2);
  146. tf2 = new JTextField();
  147. tf2.setBounds(400, 105, 150, 20);
  148. f.add(tf2);
  149. l10 = new JLabel();
  150. f.add(l10);
  151. check1 = new JCheckBox("20");
  152. check1.setBounds(560, 105, 50, 20);
  153. f.add(check1);
  154. check2 = new JCheckBox("40");
  155. check2.setBounds(615, 105, 50, 20);
  156. f.add(check2);
  157. check1.addItemListener(new ItemListener()
  158. {
  159. public void itemStateChanged(ItemEvent e) {
  160. l10.setText("20");
  161. }
  162. });
  163. check2.addItemListener(new ItemListener()
  164. {
  165. public void itemStateChanged(ItemEvent e) {
  166. l10.setText("40");
  167. }
  168. });
  169. tf3 = new JTextField();
  170. tf3.setBounds(400, 130, 150, 20);
  171. f.add(tf3);
  172. check3 = new JCheckBox("20");
  173. check3.setBounds(560, 130, 50, 20);
  174. f.add(check3);
  175. check4 = new JCheckBox("40");
  176. check4.setBounds(615, 130, 50, 20);
  177. f.add(check4);
  178. l11 = new JLabel();
  179. f.add(l11);
  180. check3.addItemListener(new ItemListener()
  181. {
  182. public void itemStateChanged(ItemEvent e)
  183. {
  184. l11.setText("20");
  185. }
  186. });
  187. check4.addItemListener(new ItemListener()
  188. {
  189. public void itemStateChanged(ItemEvent e) {
  190. l11.setText("40");
  191. }
  192. });
  193. tf4 = new JTextField();
  194. tf4.setBounds(400, 155, 150, 20);
  195. f.add(tf4);
  196. check5 = new JCheckBox("20");
  197. check5.setBounds(560, 155, 50, 20);
  198. f.add(check5);
  199. check6 = new JCheckBox("40");
  200. check6.setBounds(615, 155, 50, 20);
  201. f.add(check6);
  202. l12 = new JLabel();
  203. f.add(l12);
  204. check5.addItemListener(new ItemListener()
  205. {
  206. public void itemStateChanged(ItemEvent e) {
  207. l12.setText("20");
  208. }
  209. });
  210. check6.addItemListener(new ItemListener()
  211. {
  212. public void itemStateChanged(ItemEvent e) {
  213. l12.setText("40");
  214. }
  215. });
  216. tf5 = new JTextField();
  217. tf5.setBounds(400, 180, 150, 20);
  218. f.add(tf5);
  219. check7 = new JCheckBox("20");
  220. check7.setBounds(560, 180, 50, 20);
  221. f.add(check7);
  222. check8 = new JCheckBox("40");
  223. check8.setBounds(615, 180, 50, 20);
  224. f.add(check8);
  225. l13 = new JLabel();
  226. f.add(l13);
  227. check7.addItemListener(new ItemListener()
  228. {
  229. public void itemStateChanged(ItemEvent e) {
  230. l13.setText("20");
  231. }
  232. });
  233. check8.addItemListener(new ItemListener()
  234. {
  235. public void itemStateChanged(ItemEvent e) {
  236. l13.setText("40");
  237. }
  238. });
  239.  
  240. tf6 = new JTextField();
  241. tf6.setBounds(400, 205, 150, 20);
  242. f.add(tf6);
  243. check9 = new JCheckBox("20");
  244. check9.setBounds(560, 205, 50, 20);
  245. f.add(check9);
  246. check10 = new JCheckBox("40");
  247. check10.setBounds(615, 205, 50, 20);
  248. f.add(check10);
  249. l14 = new JLabel();
  250. f.add(l14);
  251. check9.addItemListener(new ItemListener()
  252. {
  253. public void itemStateChanged(ItemEvent e)
  254. {
  255. if(check9.isSelected())
  256. {
  257. l14.setText("20");
  258. }
  259. }
  260. });
  261. check10.addItemListener(new ItemListener()
  262. {
  263. public void itemStateChanged(ItemEvent e)
  264. {
  265. if(check9.isSelected())
  266. {
  267. l14.setText("40");
  268. }
  269. }
  270. });
  271. l3 = new JLabel("CHA Name");
  272. l3.setBounds(250,230, 150,30);
  273. f.add(l3);
  274. tf7 = new JTextField();
  275. tf7.setBounds(400, 235, 250, 20);
  276. f.add(tf7);
  277. l4 = new JLabel("Liner Agent");
  278. l4.setBounds(250,255, 150,30);
  279. f.add(l4);
  280. tf8 = new JTextField();
  281. tf8.setBounds(400, 260, 250, 20);
  282. f.add(tf8);
  283. l5 = new JLabel("Vehicle No");
  284. l5.setBounds(250,280, 150,30);
  285. f.add(l5);
  286. tf9 = new JTextField();
  287. tf9.setBounds(400, 285, 250, 20);
  288. f.add(tf9);
  289. tf10 = new JTextField();
  290. tf10.setBounds(400, 310, 250, 20);
  291. f.add(tf10);
  292. l6 = new JLabel("Date & Time");
  293. l6.setBounds(250,330, 150,30);
  294. f.add(l6);
  295. tf11 = new JTextField();
  296. tf11.setBounds(400, 335, 250, 20);
  297. tf11.setText(dateFormat.format(cal.getTime()));
  298. f.add(tf11);
  299. l7 = new JLabel("Status");
  300. l7.setBounds(250,355, 150,30);
  301. f.add(l7);
  302. cb =new JComboBox(Import_Type);
  303. cb.setBounds(400,360,250,20);
  304. f.add(cb);
  305. l8 = new JLabel("Transport");
  306. l8.setBounds(250, 385, 150, 30);
  307. f.add(l8);
  308. tf12 = new JTextField();
  309. tf12.setBounds(400, 390, 250, 20);
  310. f.add(tf12);
  311. btn1 = new JButton("New");
  312. btn1.setBounds(270, 440, 70, 20);
  313. f.add(btn1);
  314. btn1.addActionListener(new ActionListener()
  315. {
  316.  
  317. @Override
  318. public void actionPerformed(ActionEvent e)
  319. {
  320. try
  321. {
  322. Class.forName("oracle.jdbc.driver.OracleDriver");
  323. Connection con =
  324. DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe",
  325. "system", "sufyan");
  326. Statement stmt = con.createStatement();
  327. ResultSet rs = stmt.executeQuery("select max(receiptno) from
  328. hyundaiemptytable");
  329. if(rs.next())
  330. {
  331. tf1.setText("EMTIN"+"-"+(cal.get(Calendar.MONTH)+1)+"-
  332. "+cal.get(Calendar.YEAR)+"-");
  333. }
  334. }
  335. catch (Exception e1)
  336. {
  337. e1.printStackTrace();
  338. }
  339. }
  340. });
  341. btn2 = new JButton("Save");
  342. btn2.setBounds(350, 440, 70, 20);
  343. f.add(btn2);
  344. btn3 = new JButton("Print");
  345. btn3.setBounds(430, 440, 70, 20);
  346. f.add(btn3);
  347. btn3.addActionListener(new ActionListener()
  348. { public void actionPerformed(ActionEvent e)
  349. {
  350. f.dispose();
  351. PrintEmptyIn.l4.setText(tf1.getText());
  352. PrintEmptyIn.l6.setText(tf10.getText());
  353. PrintEmptyIn.l8.setText(tf7.getText());
  354. PrintEmptyIn.l6.setText(tf11.getText());
  355. PrintEmptyIn.l12.setText(tf8.getText());
  356. PrintEmptyIn.l17.setText(tf2.getText());
  357. PrintEmptyIn.l18.setText(tf3.getText());
  358. PrintEmptyIn.l19.setText(tf4.getText());
  359. PrintEmptyIn.l20.setText(tf5.getText());
  360. PrintEmptyIn.l21.setText(tf6.getText());
  361. PrintEmptyIn.l24.setText((String)cb.getSelectedItem());
  362. PrintEmptyIn.l10.setText(tf12.getText());
  363. PrintEmptyIn.l25.setText(tf9.getText());
  364. PrintEmptyIn.l26.setText(tf10.getText());
  365. PrintEmptyIn.l27.setText(l10.getText());
  366. PrintEmptyIn.l28.setText(l11.getText());
  367. PrintEmptyIn.l29.setText(l12.getText());
  368. PrintEmptyIn.l30.setText(l13.getText());
  369. PrintEmptyIn.l31.setText(l14.getText());
  370. }
  371. });
  372. btn3.addActionListener(new ActionListener()
  373. {
  374.  
  375. @Override
  376. public void actionPerformed(ActionEvent e)
  377. {
  378. new PrintEmptyIn();
  379. }
  380. });
  381. btn4 = new JButton("Reset");
  382. btn4.setBounds(510, 440, 70, 20);
  383. f.add(btn4);
  384. btn4.addActionListener(new ActionListener(){
  385. public void actionPerformed(ActionEvent e){
  386. tf1.setText(null);
  387. tf2.setText(null);
  388. tf3.setText(null);
  389. tf4.setText(null);
  390. tf5.setText(null);
  391. tf6.setText(null);
  392. tf7.setText(null);
  393. tf8.setText(null);
  394. tf9.setText(null);
  395. tf10.setText(null);
  396. tf12.setText(null);
  397. cb.setSelectedIndex(0);
  398. }
  399. });
  400. btn5 = new JButton("Back");
  401. btn5.setBounds(430, 480, 75, 20);
  402. f.add(btn5);
  403. btn5.addActionListener(new ActionListener()
  404. { public void actionPerformed(ActionEvent e)
  405. {
  406. f.dispose();
  407. new Hyundai_Home();
  408. }
  409. });
  410. btn6 = new JButton("Update");
  411. btn6.setBounds(590, 440, 75, 20);
  412. f.add(btn6);
  413. Image icon = Toolkit.getDefaultToolkit().getImage("D:\DESKTOP\logo-
  414. cwcnsl.png");
  415. f.setIconImage(icon);
  416. f. setLayout(null);
  417. f.setResizable(false);
  418. f.setBounds(200,50, 900, 600);
  419. f.setVisible(true);
  420. }
  421. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement