📄 stock_frame.java~90~
字号:
package project1;
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JPanel;
import java.awt.*;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
public class Stock_Frame extends JFrame {
ImageIcon image11 = new ImageIcon(project1.MainFrame.class.getResource("image12.png"));
ImageIcon image12 = new ImageIcon(project1.MainFrame.class.getResource("image14.png"));
ImageIcon image13 = new ImageIcon(project1.MainFrame.class.getResource("image15.png"));
ImageIcon image14 = new ImageIcon(project1.MainFrame.class.getResource("image16.png"));
ImageIcon image15 = new ImageIcon(project1.MainFrame.class.getResource("image17.png"));
ImageIcon image16 = new ImageIcon(project1.MainFrame.class.getResource("image18.png"));
ImageIcon image17 = new ImageIcon(project1.MainFrame.class.getResource("image19.png"));
ImageIcon image18 = new ImageIcon(project1.MainFrame.class.getResource("image20.png"));
ImageIcon image19 = new ImageIcon(project1.MainFrame.class.getResource("image21.png"));
ImageIcon image20 = new ImageIcon(project1.MainFrame.class.getResource("image22.png"));
ImageIcon image21 = new ImageIcon(project1.MainFrame.class.getResource("image23.png"));
ImageIcon image22 = new ImageIcon(project1.MainFrame.class.getResource("image24.png"));
ImageIcon image23 = new ImageIcon(project1.MainFrame.class.getResource("image25.png"));
ImageIcon image24 = new ImageIcon(project1.MainFrame.class.getResource("image26.png"));
ImageIcon image25 = new ImageIcon(project1.MainFrame.class.getResource("image27.png"));
ImageIcon image26 = new ImageIcon(project1.MainFrame.class.getResource("image28.png"));
ImageIcon image27 = new ImageIcon(project1.MainFrame.class.getResource("image13.png"));
JMenuBar jMenuBar1 = new JMenuBar();
JMenu jMenu1 = new JMenu();
JMenu jMenu2 = new JMenu();
JMenu jMenu3 = new JMenu();
JMenu jMenu4 = new JMenu();
JPanel jPanel1 = new JPanel();
JPanel panel1 = new JPanel();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JTextField jTextField1 = new JTextField(8);
JLabel jLabel3 = new JLabel();
JTextField jTextField2 = new JTextField(8);
JLabel jLabel4 = new JLabel();
JTextField jTextField3 = new JTextField(8);
JLabel jLabel5 = new JLabel();
JTextField jTextField4 = new JTextField(8);
JLabel jLabel6 = new JLabel();
JTextField jTextField5 = new JTextField();
JPanel panel2 = new JPanel();
JPanel panel3 = new JPanel();
JLabel jLabel7 = new JLabel();
JTextField jTextField6 = new JTextField();
JLabel jLabel8 = new JLabel();
JTextField jTextField7 = new JTextField();
JLabel jLabel9 = new JLabel();
JTextField jTextField8 = new JTextField(8);
JLabel jLabel10 = new JLabel();
JTextField jTextField9 = new JTextField(40);
JLabel jLabel11 = new JLabel();
JTextField jTextField10 = new JTextField(8);
JLabel jLabel12 = new JLabel();
JTextField jTextField11 = new JTextField(6);
JLabel jLabel13 = new JLabel();
JTextField jTextField12 = new JTextField(10);
JLabel jLabel14 = new JLabel();
JTextField jTextField13 = new JTextField(10);
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JLabel jLabel15 = new JLabel();
JTextField jTextField14 = new JTextField(10);
JMenuItem jMenuItem1 = new JMenuItem();
JMenuItem jMenuItem2 = new JMenuItem();
JMenuItem jMenuItem3 = new JMenuItem();
JMenuItem jMenuItem4 = new JMenuItem();
JMenuItem jMenuItem5 = new JMenuItem();
JMenuItem jMenuItem6 = new JMenuItem();
JMenuItem jMenuItem7 = new JMenuItem();
JMenu jMenu5 = new JMenu();
JMenuItem jMenuItem8 = new JMenuItem();
JMenuItem jMenuItem9 = new JMenuItem();
JMenuItem jMenuItem10 = new JMenuItem();
public Stock_Frame() {
super();
setSize(715, 550);
setLocation(150,90);
setResizable(false);
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(null);
this.setJMenuBar(jMenuBar1);
this.setTitle("采购单生成");
jMenu1.setText("删除");
jMenu2.setText("查看");
jMenu3.setText("修改");
jMenu4.setText("导出Excel");
jPanel1.setBackground(Color.white);
jPanel1.setBounds(new Rectangle(0, 2, 748, 515));
jPanel1.setLayout(null);
panel1.setBackground(Color.white);
panel1.setBounds(new Rectangle(1, 1, 708, 178));
panel1.setLayout(null);
jLabel1.setIcon(image11);
jLabel1.setText("jLabel1");
jLabel1.setBounds(new Rectangle(269, 2, 172, 30));
jLabel2.setIcon(image12);
jLabel2.setBounds(new Rectangle(25, 55, 102, 29));
jTextField1.setText("");
jTextField1.setBounds(new Rectangle(138, 51, 189, 27));
jLabel3.setIcon(image13);
jLabel3.setBounds(new Rectangle(384, 57, 97, 30));
jTextField2.setText("");
jTextField2.setBounds(new Rectangle(484, 51, 174, 27));
jLabel4.setIcon(image14);
jLabel4.setBounds(new Rectangle(40, 105, 79, 26));
jTextField3.setText("");
jTextField3.setBounds(new Rectangle(138, 98, 189, 27));
jLabel5.setIcon(image19);
jLabel5.setBounds(new Rectangle(387, 103, 84, 28));
jTextField4.setText("");
jTextField4.setBounds(new Rectangle(484, 97, 174, 27));
jLabel6.setIcon(image27);
jLabel6.setBounds(new Rectangle(61, 148, 60, 24));
jTextField5.setBounds(new Rectangle(138, 146, 189, 27));
panel2.setBounds(new Rectangle(3, 189, 705, 202));
panel2.setLayout(null);
panel2.setBackground(Color.white);
panel2.setBorder(BorderFactory.createTitledBorder("采购清单"));
panel3.setBackground(Color.white);
panel3.setBounds(new Rectangle(1, 391, 704, 121));
panel3.setLayout(null);
jLabel7.setIcon(image15);
jLabel7.setText("");
jLabel7.setBounds(new Rectangle(27, 22, 86, 27));
jTextField6.setText("");
jTextField6.setBounds(new Rectangle(138, 16, 189, 27));
jLabel8.setIcon(image16);
jLabel8.setText("");
jLabel8.setBounds(new Rectangle(379, 25, 98, 25));
jTextField7.setText("");
jTextField7.setBounds(new Rectangle(484, 16, 174, 27));
jLabel9.setIcon(image17);
jLabel9.setText("");
jLabel9.setBounds(new Rectangle(25, 73, 98, 28));
jTextField8.setText("");
jTextField8.setBounds(new Rectangle(138, 69, 189, 27));
jLabel10.setIcon(image18);
jLabel10.setText("");
jLabel10.setBounds(new Rectangle(380, 70, 101, 32));
jTextField9.setText("");
jTextField9.setBounds(new Rectangle(484, 67, 174, 27));
jLabel11.setIcon(image20);
jLabel11.setText("");
jLabel11.setBounds(new Rectangle(27, 42, 88, 26));
jTextField10.setText("");
jTextField10.setBounds(new Rectangle(138, 35, 189, 27));
jTextField10.addFocusListener(new Stock_Frame_jTextField10_focusAdapter(this));
jLabel12.setIcon(image21);
jLabel12.setText("");
jLabel12.setBounds(new Rectangle(39, 94, 74, 28));
jTextField11.setText("");
jTextField11.setBounds(new Rectangle(138, 92, 189, 27));
jLabel13.setIcon(image24);
jLabel13.setText("");
jLabel13.setBounds(new Rectangle(36, 155, 69, 26));
jTextField12.setText("");
jTextField12.setBounds(new Rectangle(138, 150, 189, 27));
jLabel14.setIcon(image22);
jLabel14.setText("");
jLabel14.setBounds(new Rectangle(396, 43, 79, 26));
jTextField13.setText("");
jTextField13.setBounds(new Rectangle(484, 35, 174, 27));
jTextField13.addFocusListener(new Stock_Frame_jTextField13_focusAdapter(this));
jButton1.setBounds(new Rectangle(429, 153, 93, 34));
jButton1.setIcon(null);
jButton1.setText("添加");
jButton1.addActionListener(new Stock_Frame_jButton1_actionAdapter(this));
jButton2.setBounds(new Rectangle(566, 153, 93, 34));
jButton2.setText("重置");
jButton2.addActionListener(new Stock_Frame_jButton2_actionAdapter(this));
jLabel15.setIcon(image23);
jLabel15.setText("");
jLabel15.setBounds(new Rectangle(393, 95, 76, 29));
jTextField14.setText("");
jTextField14.setBounds(new Rectangle(484, 92, 174, 27));
jMenuItem2.setText("采购单");
jMenuItem2.addActionListener(new Stock_Frame_jMenuItem2_actionAdapter(this));
jMenuItem3.setText("缺货单");
jMenuItem3.addActionListener(new Stock_Frame_jMenuItem3_actionAdapter(this));
jMenuItem4.setText("供应商商品信息");
jMenuItem4.addActionListener(new Stock_Frame_jMenuItem4_actionAdapter(this));
jMenuItem6.setText("删除采购清单项");
jMenuItem7.setText("删除采购单项");
jMenu5.addActionListener(new Stock_Frame_jMenu5_actionAdapter(this));
jMenuItem8.setText("修改采购清单项");
jMenuItem8.addActionListener(new Stock_Frame_jMenuItem8_actionAdapter(this));
jMenuItem9.setText("修改采购单项");
jMenuItem9.addActionListener(new Stock_Frame_jMenuItem9_actionAdapter(this));
jMenuItem5.setText("商品信息");
jMenuItem5.addActionListener(new Stock_Frame_jMenuItem5_actionAdapter(this));
jMenuItem1.addActionListener(new Stock_Frame_jMenuItem1_actionAdapter(this));
jMenuItem1.setText("采购清单");
jMenuItem10.setText("保存");
jMenuItem10.addActionListener(new Stock_Frame_jMenuItem10_actionAdapter(this));
jMenu5.setText("保存采购单");
jMenuBar1.add(jMenu1);
jMenuBar1.add(jMenu2);
jMenuBar1.add(jMenu3);
jMenuBar1.add(jMenu4);
jMenuBar1.add(jMenu5);
this.getContentPane().add(jPanel1);
jPanel1.add(panel1);
panel2.add(jTextField13);
panel2.add(jLabel13);
panel2.add(jTextField12);
panel2.add(jTextField11);
panel2.add(jLabel12);
panel2.add(jTextField10);
panel2.add(jTextField14);
panel2.add(jLabel15);
panel2.add(jButton2);
panel2.add(jButton1);
panel2.add(jLabel14);
panel2.add(jLabel11);
jPanel1.add(panel3);
panel3.add(jTextField6);
panel3.add(jLabel7);
panel3.add(jTextField8);
panel3.add(jTextField7);
panel3.add(jTextField9);
panel3.add(jLabel8);
panel3.add(jLabel10);
panel3.add(jLabel9);
jPanel1.add(panel2);
panel1.add(jLabel2);
panel1.add(jLabel1);
panel1.add(jTextField1);
panel1.add(jTextField5);
panel1.add(jTextField3);
panel1.add(jTextField2);
panel1.add(jTextField4);
panel1.add(jLabel5);
panel1.add(jLabel4);
panel1.add(jLabel6);
panel1.add(jLabel3);
jMenu2.add(jMenuItem1);
jMenu2.add(jMenuItem2);
jMenu2.add(jMenuItem3);
jMenu2.add(jMenuItem4);
jMenu2.add(jMenuItem5);
jMenu1.add(jMenuItem6);
jMenu1.add(jMenuItem7);
jMenu3.add(jMenuItem8);
jMenu3.add(jMenuItem9);
jMenu5.add(jMenuItem10);
}
public void jTextField10_focusLost(FocusEvent e) {
String RL = "jdbc:microsoft:sqlserver://localhost;DatabaseName=pos_mis";
String user ="sa";
String password = "220300124";
String str=jTextField10.getText();
String sqlStr = "select 单位,单价 from 供应商商品信息 where 商品编码='"+str+"'";
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection con = DriverManager.getConnection(RL,user,password);
Statement st = con.createStatement();
ResultSet rs = st.executeQuery( sqlStr );
while(rs.next())
{
String str1 = rs.getString("单位");
String str2 = rs.getString("单价");
jTextField11.setText(str1);
jTextField14.setText(str2);
}
rs.close();
st.close();
con.close();
}catch(Exception err){
err.printStackTrace(System.out);
}
}
public void jButton2_actionPerformed(ActionEvent e) {
jTextField10.setText("");
jTextField11.setText("");
jTextField12.setText("");
jTextField13.setText("");
jTextField14.setText("");
}
public void jTextField13_focusLost(FocusEvent e) {
String am1=jTextField13.getText();
int amount1= Integer.parseInt(am1);
String am2=jTextField14.getText();
float amount2=Float.parseFloat(am2);
float sum=amount1*amount2;
String money=String.valueOf(sum);
jTextField12.setText(money);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -