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

📄 frmsupplier.java

📁 《JBuilder编程技术与实例》(2006 四维科技 人民邮电)赠送代码——库存管理系统(Access)
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package MainForm;

/*
********************************************************************************
*																			   *
* Note:																		   *
*      This is not intended to used in a big business because this system was  *
*      created for small business only.
* 																			   *
********************************************************************************
*/

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.table.*;
import java.awt.PrintJob;
import java.util.*;
import java.text.*;

public class FrmSupplier extends JInternalFrame{

        /************************ Variable declaration start **********************/

        //Start form variables
        public static JScrollPane SupTableJSP = new JScrollPane();

        public static JPanel JPContainer = new JPanel();

        public static JTable JTSupTable;

        JLabel JLPicture1 = new JLabel(new ImageIcon("images/helper.png"));
        JLabel JLHelpText = new JLabel("To display a certain  \n record click the 'search button' and look for the record that you want.");

        JFrame JFParentFrame;

        JButton JBAddNew = new JButton("Add New",new ImageIcon("images/new.png"));
        JButton JBModify = new JButton("Modify",new ImageIcon("images/modify.png"));
        JButton JBSearch = new JButton("Search",new ImageIcon("images/search.png"));
        JButton JBPrint = new JButton("Print",new ImageIcon("images/print.png"));
        JButton JBDelete = new JButton("Delete",new ImageIcon("images/delete.png"));
        JButton JBReload = new JButton("Reload",new ImageIcon("images/reload.png"));

        Connection cnSup;

        public static Statement stSup;

        public static ResultSet rsSup;

        public static String strSQL;
        public static String Content[][];

        public static int rowNum = 0;
        public static int total = 0;

        boolean goEOF;

        Dimension screen = 	Toolkit.getDefaultToolkit().getScreenSize();

        //End form variables

        /********************** End variable declaration start ********************/

        /********************* Start FrmSupplier constructor **********************/
        public FrmSupplier(Connection srcCN,JFrame getParentFrame) throws SQLException{
                //Set the form caption and some properties start
                super("Supplier Records",false,true,false,true);
                //End set the form caption and some properties

                //Start initialize variables
                JPContainer.setLayout(null);

                JFParentFrame = getParentFrame;

                cnSup = srcCN;
                stSup = cnSup.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                strSQL = "SELECT * FROM tblSupplier WHERE SupplierIndex = 0 ORDER BY CompanyName ASC";

                //-- Add the JLPicture1
                JLPicture1.setBounds(5,5,48,48);
                JPContainer.add(JLPicture1);

                //-- Add the JLHelpText
                JLHelpText.setBounds(55,5,570,48);
                JLHelpText.setFont(new Font("Dialog", Font.PLAIN, 12));
                JPContainer.add(JLHelpText);

                //-- Add the SupTable
                JTSupTable=CreateTable();
                SupTableJSP.getViewport().add(JTSupTable);
                SupTableJSP.setBounds(5,55,727,320);
                JPContainer.add(SupTableJSP);

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

                //-- Add the JBModify
                JBModify.setBounds(112,382,99,25);
                JBModify.setFont(new Font("Dialog", Font.PLAIN, 12));
                JBModify.setMnemonic(KeyEvent.VK_M);
                JBModify.addActionListener(JBActionListener);
                JBModify.setActionCommand("modify");
                JPContainer.add(JBModify);

                //-- Add the JBSearch
                JBSearch.setBounds(212,382,99,25);
                JBSearch.setFont(new Font("Dialog", Font.PLAIN, 12));
                JBSearch.setMnemonic(KeyEvent.VK_S);
                JBSearch.addActionListener(JBActionListener);
                JBSearch.setActionCommand("search");
                JPContainer.add(JBSearch);

                //-- Add the JBPrint
                JBPrint.setBounds(312,382,99,25);
                JBPrint.setFont(new Font("Dialog", Font.PLAIN, 12));
                JBPrint.setMnemonic(KeyEvent.VK_P);
                JBPrint.addActionListener(JBActionListener);
                JBPrint.setActionCommand("print");
                JPContainer.add(JBPrint);

                //-- Add the JBDelete
                JBDelete.setBounds(413,382,105,25);
                JBDelete.setFont(new Font("Dialog", Font.PLAIN, 12));
                JBDelete.setMnemonic(KeyEvent.VK_D);
                JBDelete.addActionListener(JBActionListener);
                JBDelete.setActionCommand("delete");
                JPContainer.add(JBDelete);

                //-- Add the JBReload
                JBReload.setBounds(627,382,105,25);
                JBReload.setFont(new Font("Dialog", Font.PLAIN, 12));
                JBReload.setMnemonic(KeyEvent.VK_R);
                JBReload.addActionListener(JBActionListener);
                JBReload.setActionCommand("reload");
                JPContainer.add(JBReload);

                //End initialize variables

                //Start set the form properties
                getContentPane().add(JPContainer);
                setSize(747,450);
                setLocation((screen.width - 747)/2,((screen.height-450)/2)-45);
                setFrameIcon(new ImageIcon("images/Supplier.png"));
                //End set the form properties

        }
        /********************** FrmSupplier constructor end ***********************/

        /************************** Start event handling **************************/

        ActionListener JBActionListener = new ActionListener(){
                public void actionPerformed(ActionEvent e){
                        String srcObj = e.getActionCommand();
                        //Add Record
                        if(srcObj=="add"){
                                JDialog JDAdd = new frm_add_edit_supplier(true,JFParentFrame,cnSup,"");
                                JDAdd.show();
                        //Modify Record
                        }else if(srcObj=="modify"){
                                if(total != 0){
                                        try{
                                                        if(JTSupTable.getValueAt(JTSupTable.getSelectedRow(),JTSupTable.getSelectedColumn()) != null){
                                                                JDialog JDEdit = new frm_add_edit_supplier(false,JFParentFrame,cnSup,"SELECT * FROM tblSupplier WHERE SupplierIndex = " + JTSupTable.getValueAt(JTSupTable.getSelectedRow(),0));
                                                                JDEdit.show();

                                                        }
                                        }catch(Exception sqlE){
                                                if(sqlE.getMessage() != null){
                                                        System.out.println(sqlE.getMessage());
                                                }else{
                                                        JOptionPane.showMessageDialog(null,"Please select a record in the list to modify.","No Record Selected",JOptionPane.INFORMATION_MESSAGE);
                                                }

⌨️ 快捷键说明

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