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

📄 frm_add_edit_salesrep.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.sql.*;
import java.awt.*;
import java.awt.event.*;

public class frm_add_edit_salesrep extends JDialog{
        JButton JBUpdate = new JButton(new ImageIcon("images/save.png"));
        JButton JBReset = new JButton("Reset",new ImageIcon("images/reset.png"));
        JButton JBCancel = new JButton("Cancel",new ImageIcon("images/cancel.png"));

        JLabel JLPic1 = new JLabel();
        JLabel JLBanner = new JLabel("Please fill-up all the required fields.");

        JLabel JLId = new JLabel("Sales Rep. ID:");
        JLabel JLName = new JLabel("Name:");
        JLabel JLAddr = new JLabel("Address:");
        JLabel JLCity = new JLabel("City:");
        JLabel JLStateProv = new JLabel("State/Province:");
        JLabel JLZipCode = new JLabel("ZipCode:");
        JLabel JLContNo = new JLabel("Contact No:");
        JLabel JLEmerContName = new JLabel("Emer. Cont. Name:");
        JLabel JLEmerContNo = new JLabel("Emer. Contact No:");

        JTextField JTFId = new JTextField();
        JTextField JTFName = new JTextField();
        JTextField JTFAddr = new JTextField();
        JTextField JTFCity = new JTextField();
        JTextField JTFStateProv = new JTextField();
        JTextField JTFZipCode = new JTextField();
        JTextField JTFContNo = new JTextField();
        JTextField JTFEmerContName = new JTextField();
        JTextField JTFEmerContNo = new JTextField();

        Connection cnAES;
        Statement stAES;
        ResultSet rsAES;

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

        boolean ADDING_STATE;

        public frm_add_edit_salesrep(boolean ADD_STATE,JFrame OwnerForm,Connection srcCN,String srcSQL){
                super(OwnerForm,true);
                cnAES = srcCN;
                ADDING_STATE = ADD_STATE;
                try{
                        stAES = cnAES.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
                }catch( SQLException sqlEx){

                }
                if(ADD_STATE==true){
                        JLPic1.setIcon(new ImageIcon("images/bNew.png"));
                        setTitle("Add New SalesRep ");
                        JBUpdate.setText("Update");
                }else{
                        JLPic1.setIcon(new ImageIcon("images/bModify.png"));
                        setTitle("Modify SalesRep ");
                        JBUpdate.setText("Save");
                        try{
                                rsAES = stAES.executeQuery(srcSQL);
                                rsAES.next();
                                        JTFId.setText("" + rsAES.getString("SalesRepID"));
                                        JTFName.setText("" + rsAES.getString("Name"));
                                        JTFAddr.setText("" + rsAES.getString("Address"));
                                        JTFCity.setText("" + rsAES.getString("CityTown"));
                                        JTFStateProv.setText("" + rsAES.getString("StateProvince"));
                                        JTFZipCode.setText("" + rsAES.getString("ZipCode"));
                                        JTFContNo.setText("" + rsAES.getString("ContactNo"));
                                        JTFEmerContNo.setText("" + rsAES.getString("EmerContactNo"));
                                        JTFEmerContName.setText("" + rsAES.getString("EmerContactName"));
                        }catch(SQLException sqlEx){
                                System.out.println(sqlEx.getMessage());
                        }
                }
                JPanel JPContainer = new JPanel();
                JPContainer.setLayout(null);
                //-- Add the JLPic1
                JLPic1.setBounds(5,5,32,32);
                JPContainer.add(JLPic1);

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

                //******************** Start adding of input field
                //-- Add Id Input Field
                JLId.setBounds(5,50,105,20);
                JLId.setFont(new Font("Dialog",Font.PLAIN,12));

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

                JPContainer.add(JLId);
                JPContainer.add(JTFId);

                //-- Add Name Input Field
                JLName.setBounds(5,72,105,20);
                JLName.setFont(new Font("Dialog",Font.PLAIN,12));

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

                JPContainer.add(JLName);
                JPContainer.add(JTFName);
                //-- Add Primary Address Input Field
                JLAddr.setBounds(5,94,105,20);
                JLAddr.setFont(new Font("Dialog",Font.PLAIN,12));

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

                JPContainer.add(JLAddr);
                JPContainer.add(JTFAddr);

                //-- Add Secondary Address Input Field
                JLCity.setBounds(5,116,105,20);
                JLCity.setFont(new Font("Dialog",Font.PLAIN,12));

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

                JPContainer.add(JLCity);
                JPContainer.add(JTFCity);

                //-- Add StateProv Input Field
                JLStateProv.setBounds(5,138,105,20);
                JLStateProv.setFont(new Font("Dialog",Font.PLAIN,12));

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

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

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

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

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

                //-- Add Zip Code Input Field

⌨️ 快捷键说明

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