⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frm_add_edit_warehouse.java

📁 《JBuilder编程技术与实例》(2006 四维科技 人民邮电)赠送代码——库存管理系统(Access)
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                JTFStateProv.setFont(new Font("Dialog",Font.PLAIN,12));

                JPContainer.add(JLStateProv);
                JPContainer.add(JTFStateProv);

                //-- Add Zip Code Input Field
                JLZipCode.setBounds(5,204,105,20);
                JLZipCode.setFont(new Font("Dialog",Font.PLAIN,12));

                JTFZipCode.setBounds(110,204,200,20);
                JTFZipCode.setFont(new Font("Dialog",Font.PLAIN,12));

                JPContainer.add(JLZipCode);
                JPContainer.add(JTFZipCode);

                //-- Add Contact Number Input Field
                JLPhone.setBounds(5,226,105,20);
                JLPhone.setFont(new Font("Dialog",Font.PLAIN,12));

                JTFPhone.setBounds(110,226,200,20);
                JTFPhone.setFont(new Font("Dialog",Font.PLAIN,12));

                JPContainer.add(JLPhone);
                JPContainer.add(JTFPhone);

                //-- Add E-mail Address Input Field
                JLFax.setBounds(5,248,105,20);
                JLFax.setFont(new Font("Dialog",Font.PLAIN,12));

                JTFFax.setBounds(110,248,200,20);
                JTFFax.setFont(new Font("Dialog",Font.PLAIN,12));

                JPContainer.add(JLFax);
                JPContainer.add(JTFFax);

                //******************** End adding of input field

                //-- Add the JBUpdate
                JBUpdate.setBounds(5,292,105,25);
                JBUpdate.setFont(new Font("Dialog", Font.PLAIN, 12));
                JBUpdate.setMnemonic(KeyEvent.VK_A);
                JBUpdate.addActionListener(JBActionListener);
                JBUpdate.setActionCommand("update");
                JPContainer.add(JBUpdate);

                //-- Add the JBReset
                JBReset.setBounds(112,292,99,25);
                JBReset.setFont(new Font("Dialog", Font.PLAIN, 12));
                JBReset.setMnemonic(KeyEvent.VK_R);
                JBReset.addActionListener(JBActionListener);
                JBReset.setActionCommand("reset");
                JPContainer.add(JBReset);

                //-- Add the JBCancel
                JBCancel.setBounds(212,292,99,25);
                JBCancel.setFont(new Font("Dialog", Font.PLAIN, 12));
                JBCancel.setMnemonic(KeyEvent.VK_C);
                JBCancel.addActionListener(JBActionListener);
                JBCancel.setActionCommand("cancel");
                JPContainer.add(JBCancel);

                getContentPane().add(JPContainer);
                setSize(325,357);
                setResizable(false);
                setLocation((screen.width - 325)/2,((screen.height-357)/2));
        }
        private boolean RequiredFieldEmpty(){
                if(JTFId.getText().equals("") || JTFName.getText().equals("") || JTFCPerson.getText().equals("")){
                        JOptionPane.showMessageDialog(null,"Some required fields is/are empty.\nPlease check it and try again.","Naparansoft Inventory System",JOptionPane.WARNING_MESSAGE);
                        JTFId.requestFocus();
                        return true;
                }else{
                        return false;
                }
        }
        private void clearFields(){
                JTFId.setText("");
                JTFName.setText("");
                JTFCPerson.setText("");
                JTFCTitle.setText("");
                JTFAddr.setText("");
                JTFCity.setText("");
                JTFStateProv.setText("");
                JTFZipCode.setText("");
                JTFPhone.setText("");
                JTFFax.setText("");
        }

        ActionListener JBActionListener = new ActionListener(){
                public void actionPerformed(ActionEvent e){
                        String srcObj = e.getActionCommand();
                        if(srcObj=="update"){
                                if(RequiredFieldEmpty()==false){
                                        if(ADDING_STATE == true){
                                                try{

                                                        stAEW.executeUpdate("INSERT INTO tblWarehouse(WarehouseID,WarehouseName,ContactPerson,ContactTitle,Address,CityTown,StateProvince,ZipCode,Phone,Fax) " +
                                                                                        "VALUES ('" +
                                                                                        JTFId.getText() + "', '" +
                                                                                        JTFName.getText() + "', '" +
                                                                                        JTFCPerson.getText() + "', '" +
                                                                                        JTFCTitle.getText() + "', '" +
                                                                                        JTFAddr.getText() + "', '" +
                                                                                        JTFCity.getText() + "', '" +
                                                                                        JTFStateProv.getText() + "', '" +
                                                                                        JTFZipCode.getText() + "', '" +
                                                                                        JTFPhone.getText() + "', '" +
                                                                                        JTFFax.getText() +
                                                                                        "')");
                                                        // Start Display the new record
                                                        int total =0;
                                                        total = clsPublicMethods.getMaxNum("SELECT * FROM tblWarehouse ORDER BY WarehouseIndex ASC",cnAEW,"WarehouseIndex");
                                                        if(total != 0){
                                                                FrmWarehouse.reloadRecord("SELECT * FROM tblWarehouse WHERE WarehouseIndex = " + total + " ORDER BY WarehouseName ASC");
                                                        }else{
                                                                FrmWarehouse.reloadRecord("SELECT * FROM tblWarehouse ORDER BY WarehouseName ASC");
                                                        }
                                                        total =0;
                                                        // End Display the new record
                                                        JOptionPane.showMessageDialog(null,"New record has been successfully added.","Naparansoft Inventory System",JOptionPane.INFORMATION_MESSAGE);
                                                        String ObjButtons[] = {"Yes","No"};
                                                        int PromptResult = JOptionPane.showOptionDialog(null,"Do you want add another record?","Naparansoft Inventory System",JOptionPane.DEFAULT_OPTION,JOptionPane.QUESTION_MESSAGE,null,ObjButtons,ObjButtons[0]);
                                                        if(PromptResult==0){
                                                                clearFields();
                                                                JTFId.requestFocus(true);
                                                        }else{
                                                                dispose();
                                                        }
                                                }catch(SQLException sqlEx){
                                                        System.out.println(sqlEx.getMessage());
                                                }
                                        }else{
                                                try{
                                                        String RowIndex;
                                                        RowIndex = rsAEW.getString("WarehouseIndex");
                                                        stAEW.executeUpdate("UPDATE tblWarehouse SET WarehouseID = '" +
                                                                                        JTFId.getText() + "', WarehouseName = '" +
                                                                                        JTFName.getText() + "', ContactPerson = '" +
                                                                                        JTFCPerson.getText() + "', ContactTitle = '" +
                                                                                        JTFCTitle.getText()  + "', Address = '" +
                                                                                        JTFAddr.getText()  + "', CityTown = '" +
                                                                                        JTFCity.getText()   + "', StateProvince = '" +
                                                                                        JTFStateProv.getText()   + "', ZipCode = '" +
                                                                                        JTFZipCode.getText()   + "', Phone = '" +
                                                                                        JTFPhone.getText()  + "', Fax = '" +
                                                                                        JTFFax.getText() +
                                                                                        "' WHERE WarehouseIndex = " + RowIndex);
                                                        FrmWarehouse.reloadRecord("SELECT * FROM tblWarehouse WHERE WarehouseIndex = " + RowIndex + " ORDER BY WarehouseName ASC");
                                                        JOptionPane.showMessageDialog(null,"Changes in the record has been successfully save.","Naparansoft Inventory System",JOptionPane.INFORMATION_MESSAGE);
                                                        dispose();
                                                }catch(SQLException sqlEx){
                                                        System.out.println(sqlEx.getMessage());
                                                }
                                        }
                                }
                        }else if(srcObj=="reset"){
                                clearFields();
                        }else if(srcObj=="cancel"){
                                dispose();
                        }
                }
        };

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -