Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- **
- package com.hyundai;
- import java.awt.Image;
- import java.awt.Toolkit;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.ItemEvent;
- import java.awt.event.ItemListener;
- import java.awt.event.KeyEvent;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.Statement;
- import java.text.DateFormat;
- import java.text.SimpleDateFormat;
- import java.util.Calendar;
- import javax.swing.AbstractAction;
- import javax.swing.Action;
- import javax.swing.ActionMap;
- import javax.swing.InputMap;
- import javax.swing.JButton;
- import javax.swing.JCheckBox;
- import javax.swing.JComboBox;
- import javax.swing.JComponent;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JMenu;
- import javax.swing.JMenuBar;
- import javax.swing.JMenuItem;
- import javax.swing.JRootPane;
- import javax.swing.JTextField;
- import javax.swing.KeyStroke;
- public class EmptyIn
- {
- protected static String st1;
- public static void main(String[] args)
- {
- new EmptyIn();
- }
- final JFrame f;
- JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15,l16,l17,l18,l19;
- static JTextField tf1;
- JTextField tf2, tf3, tf4, tf5, tf6, tf7, tf8,tf9, tf10, tf11, tf12;
- String Import_Type[]={" ","Direct-Out","De-Stuffing","OutSide-Empty","Port-
- Cfs","Cfs-Bond","Lcl"};
- JComboBox cb;
- DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
- Calendar cal = Calendar.getInstance();
- JMenu Export,Import,Report,LogOff,Admin;
- JMenuItem In,Out,Daily,Monthly,Yearly,logoff,createuser,deleteuser;
- final JCheckBox
- check1,check2,check3,check4,check5,check6,check7,check8,check9,check10;
- JButton btn1,btn2,btn3,btn4,btn5,btn6;
- JMenuBar mb ;
- EmptyIn()
- {
- f = new JFrame("Empty-In");
- mb = new JMenuBar();
- Export = new JMenu("Export");
- Import = new JMenu("Import");
- Report = new JMenu("Report");
- Admin = new JMenu("Admin");
- LogOff = new JMenu("Log-Off");
- In = new JMenuItem("Empty-In");
- In.addActionListener(new ActionListener()
- { public void actionPerformed(ActionEvent e)
- {
- f.dispose();
- new EmptyIn();
- }
- });
- Out = new JMenuItem("Empty-Out");
- Out.addActionListener(new ActionListener()
- { public void actionPerformed(ActionEvent e)
- {
- f.dispose();
- new EmptyOut();
- }
- });
- Daily = new JMenuItem("Daily");
- Monthly = new JMenuItem("Monthly");
- Yearly = new JMenuItem("Yearly");
- mb.add(Import);
- mb.add(Export);
- mb.add(Report);
- mb.add(Admin);
- mb.add(LogOff);
- Import.add(In);
- Export.add(Out);
- Report.add(Daily);
- Report.addSeparator();
- Report.add(Monthly);
- Report.addSeparator();
- Report.add(Yearly);
- createuser = new JMenuItem("Add User");
- deleteuser = new JMenuItem("Delete User");
- Admin.add(createuser);
- createuser.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- f.dispose();
- new CreateUser();
- }
- });
- Admin.addSeparator();
- Admin.add(deleteuser);
- logoff = new JMenuItem("Log Off");
- logoff.addActionListener(new ActionListener()
- { public void actionPerformed(ActionEvent e)
- {
- f.dispose();
- new Login();
- }
- });
- LogOff.add(logoff);
- JRootPane rootPane = f.getRootPane();
- ActionMap actionMap = rootPane.getActionMap();
- Action menuAction = new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- JRootPane rootPane = f.getRootPane();
- JMenuBar jMenuBar = rootPane.getJMenuBar();
- JMenu menu = jMenuBar.getMenu(0);
- menu.doClick();
- }
- };
- final String MENU_ACTION_KEY = "expand_that_first_menu_please";
- actionMap.put(MENU_ACTION_KEY, menuAction);
- InputMap inputMap =
- rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ALT, 0, true),
- MENU_ACTION_KEY);
- f.setJMenuBar(mb);
- l1 = new JLabel("Receipt Number");
- l1.setBounds(250,75, 150,30);
- f.add(l1);
- tf1 = new JTextField(15);
- tf1.setBounds(400, 80, 250, 20);
- f.add(tf1);
- l2 = new JLabel("Container Number");
- l2.setBounds(250,100, 150,30);
- f.add(l2);
- tf2 = new JTextField();
- tf2.setBounds(400, 105, 150, 20);
- f.add(tf2);
- l10 = new JLabel();
- f.add(l10);
- check1 = new JCheckBox("20");
- check1.setBounds(560, 105, 50, 20);
- f.add(check1);
- check2 = new JCheckBox("40");
- check2.setBounds(615, 105, 50, 20);
- f.add(check2);
- check1.addItemListener(new ItemListener()
- {
- public void itemStateChanged(ItemEvent e) {
- l10.setText("20");
- }
- });
- check2.addItemListener(new ItemListener()
- {
- public void itemStateChanged(ItemEvent e) {
- l10.setText("40");
- }
- });
- tf3 = new JTextField();
- tf3.setBounds(400, 130, 150, 20);
- f.add(tf3);
- check3 = new JCheckBox("20");
- check3.setBounds(560, 130, 50, 20);
- f.add(check3);
- check4 = new JCheckBox("40");
- check4.setBounds(615, 130, 50, 20);
- f.add(check4);
- l11 = new JLabel();
- f.add(l11);
- check3.addItemListener(new ItemListener()
- {
- public void itemStateChanged(ItemEvent e)
- {
- l11.setText("20");
- }
- });
- check4.addItemListener(new ItemListener()
- {
- public void itemStateChanged(ItemEvent e) {
- l11.setText("40");
- }
- });
- tf4 = new JTextField();
- tf4.setBounds(400, 155, 150, 20);
- f.add(tf4);
- check5 = new JCheckBox("20");
- check5.setBounds(560, 155, 50, 20);
- f.add(check5);
- check6 = new JCheckBox("40");
- check6.setBounds(615, 155, 50, 20);
- f.add(check6);
- l12 = new JLabel();
- f.add(l12);
- check5.addItemListener(new ItemListener()
- {
- public void itemStateChanged(ItemEvent e) {
- l12.setText("20");
- }
- });
- check6.addItemListener(new ItemListener()
- {
- public void itemStateChanged(ItemEvent e) {
- l12.setText("40");
- }
- });
- tf5 = new JTextField();
- tf5.setBounds(400, 180, 150, 20);
- f.add(tf5);
- check7 = new JCheckBox("20");
- check7.setBounds(560, 180, 50, 20);
- f.add(check7);
- check8 = new JCheckBox("40");
- check8.setBounds(615, 180, 50, 20);
- f.add(check8);
- l13 = new JLabel();
- f.add(l13);
- check7.addItemListener(new ItemListener()
- {
- public void itemStateChanged(ItemEvent e) {
- l13.setText("20");
- }
- });
- check8.addItemListener(new ItemListener()
- {
- public void itemStateChanged(ItemEvent e) {
- l13.setText("40");
- }
- });
- tf6 = new JTextField();
- tf6.setBounds(400, 205, 150, 20);
- f.add(tf6);
- check9 = new JCheckBox("20");
- check9.setBounds(560, 205, 50, 20);
- f.add(check9);
- check10 = new JCheckBox("40");
- check10.setBounds(615, 205, 50, 20);
- f.add(check10);
- l14 = new JLabel();
- f.add(l14);
- check9.addItemListener(new ItemListener()
- {
- public void itemStateChanged(ItemEvent e)
- {
- if(check9.isSelected())
- {
- l14.setText("20");
- }
- }
- });
- check10.addItemListener(new ItemListener()
- {
- public void itemStateChanged(ItemEvent e)
- {
- if(check9.isSelected())
- {
- l14.setText("40");
- }
- }
- });
- l3 = new JLabel("CHA Name");
- l3.setBounds(250,230, 150,30);
- f.add(l3);
- tf7 = new JTextField();
- tf7.setBounds(400, 235, 250, 20);
- f.add(tf7);
- l4 = new JLabel("Liner Agent");
- l4.setBounds(250,255, 150,30);
- f.add(l4);
- tf8 = new JTextField();
- tf8.setBounds(400, 260, 250, 20);
- f.add(tf8);
- l5 = new JLabel("Vehicle No");
- l5.setBounds(250,280, 150,30);
- f.add(l5);
- tf9 = new JTextField();
- tf9.setBounds(400, 285, 250, 20);
- f.add(tf9);
- tf10 = new JTextField();
- tf10.setBounds(400, 310, 250, 20);
- f.add(tf10);
- l6 = new JLabel("Date & Time");
- l6.setBounds(250,330, 150,30);
- f.add(l6);
- tf11 = new JTextField();
- tf11.setBounds(400, 335, 250, 20);
- tf11.setText(dateFormat.format(cal.getTime()));
- f.add(tf11);
- l7 = new JLabel("Status");
- l7.setBounds(250,355, 150,30);
- f.add(l7);
- cb =new JComboBox(Import_Type);
- cb.setBounds(400,360,250,20);
- f.add(cb);
- l8 = new JLabel("Transport");
- l8.setBounds(250, 385, 150, 30);
- f.add(l8);
- tf12 = new JTextField();
- tf12.setBounds(400, 390, 250, 20);
- f.add(tf12);
- btn1 = new JButton("New");
- btn1.setBounds(270, 440, 70, 20);
- f.add(btn1);
- btn1.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- try
- {
- Class.forName("oracle.jdbc.driver.OracleDriver");
- Connection con =
- DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe",
- "system", "sufyan");
- Statement stmt = con.createStatement();
- ResultSet rs = stmt.executeQuery("select max(receiptno) from
- hyundaiemptytable");
- if(rs.next())
- {
- tf1.setText("EMTIN"+"-"+(cal.get(Calendar.MONTH)+1)+"-
- "+cal.get(Calendar.YEAR)+"-");
- }
- }
- catch (Exception e1)
- {
- e1.printStackTrace();
- }
- }
- });
- btn2 = new JButton("Save");
- btn2.setBounds(350, 440, 70, 20);
- f.add(btn2);
- btn3 = new JButton("Print");
- btn3.setBounds(430, 440, 70, 20);
- f.add(btn3);
- btn3.addActionListener(new ActionListener()
- { public void actionPerformed(ActionEvent e)
- {
- f.dispose();
- PrintEmptyIn.l4.setText(tf1.getText());
- PrintEmptyIn.l6.setText(tf10.getText());
- PrintEmptyIn.l8.setText(tf7.getText());
- PrintEmptyIn.l6.setText(tf11.getText());
- PrintEmptyIn.l12.setText(tf8.getText());
- PrintEmptyIn.l17.setText(tf2.getText());
- PrintEmptyIn.l18.setText(tf3.getText());
- PrintEmptyIn.l19.setText(tf4.getText());
- PrintEmptyIn.l20.setText(tf5.getText());
- PrintEmptyIn.l21.setText(tf6.getText());
- PrintEmptyIn.l24.setText((String)cb.getSelectedItem());
- PrintEmptyIn.l10.setText(tf12.getText());
- PrintEmptyIn.l25.setText(tf9.getText());
- PrintEmptyIn.l26.setText(tf10.getText());
- PrintEmptyIn.l27.setText(l10.getText());
- PrintEmptyIn.l28.setText(l11.getText());
- PrintEmptyIn.l29.setText(l12.getText());
- PrintEmptyIn.l30.setText(l13.getText());
- PrintEmptyIn.l31.setText(l14.getText());
- }
- });
- btn3.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- new PrintEmptyIn();
- }
- });
- btn4 = new JButton("Reset");
- btn4.setBounds(510, 440, 70, 20);
- f.add(btn4);
- btn4.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent e){
- tf1.setText(null);
- tf2.setText(null);
- tf3.setText(null);
- tf4.setText(null);
- tf5.setText(null);
- tf6.setText(null);
- tf7.setText(null);
- tf8.setText(null);
- tf9.setText(null);
- tf10.setText(null);
- tf12.setText(null);
- cb.setSelectedIndex(0);
- }
- });
- btn5 = new JButton("Back");
- btn5.setBounds(430, 480, 75, 20);
- f.add(btn5);
- btn5.addActionListener(new ActionListener()
- { public void actionPerformed(ActionEvent e)
- {
- f.dispose();
- new Hyundai_Home();
- }
- });
- btn6 = new JButton("Update");
- btn6.setBounds(590, 440, 75, 20);
- f.add(btn6);
- Image icon = Toolkit.getDefaultToolkit().getImage("D:\DESKTOP\logo-
- cwcnsl.png");
- f.setIconImage(icon);
- f. setLayout(null);
- f.setResizable(false);
- f.setBounds(200,50, 900, 600);
- f.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement