📄 fpanel2.java
字号:
package src1;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.util.Calendar;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class FPanel2 extends FunctionPanel implements ActionListener{
private JLabel label = new JLabel(" FPanel 2");
private JLabel label1,label2,label3,label4,label5,label6,label7,label8,label9;
private JTextField tf1,tf2,tf3,tf4,tf5,tf6,tf7,tf8,tf9;
private JButton bt1,bt2;
private JPanel panel1,panel2,panel3,panel4;
private String productID="";
private String storageID ="";
private String outID;
private int amount2 ;
private String amount ="";
private String amountS = "";
private String sql;
private ConSqlServer exc;
private JTable table;
private int i;
public FPanel2() {
// TODO 自动生成构造函数存根
operationLabel.setText("操作:出库");
this.setLayout(null);
label1 = new JLabel("出库单号");
label2 = new JLabel("产品号 ");
label3 = new JLabel("仓库号 ");
label4 = new JLabel("出库量 ");
label1.setIcon(new ImageIcon("./src/icons/5.gif"));
label2.setIcon(new ImageIcon("./src/icons/5.gif"));
label3.setIcon(new ImageIcon("./src/icons/5.gif"));
label4.setIcon(new ImageIcon("./src/icons/5.gif"));
tf1 = new JTextField(12);
tf2 = new JTextField(12);
tf3 = new JTextField(12);
tf4 = new JTextField("",12);
bt1 = new JButton("提交");
bt2 = new JButton("取消");
bt1.setIcon(new ImageIcon("./src/icons/35.gif"));
bt2.setIcon(new ImageIcon("./src/icons/36.gif"));
panel1 =new JPanel();
panel2 = new JPanel();
panel3 =new JPanel();
//panel4 = new JPanel();
panel1.setBounds(0,20,260,120);
panel2.setBounds(260,20,260,120);
panel3.setBounds(-2,160,600,440);
panel3.setLayout(null);
table = new JTable(100,5);
initTable();
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setLocation(30,20);
scrollPane.setSize(550,360);
panel3.add(scrollPane,BorderLayout.CENTER);
this.add(panel1);
this.add(panel2);
this.add(panel3);
panel2.add(label1);panel2.add(tf1);
panel1.add(label2);panel1.add(tf2);
panel1.add(label3);panel1.add(tf3);
panel1.add(label4);panel1.add(tf4);
panel2.add(bt1);
panel2.add(bt2);
//panel1.setBorder(new OwnBorder(2,Color.green));
panel3.setBorder(new OwnBorder(2,Color.LIGHT_GRAY));
panel1.setBackground(new Color(240,255,255));
panel2.setBackground(new Color(240,255,255));
panel3.setBackground(new Color(240,255,255));
bt1.addActionListener(this);
bt2.addActionListener(this);
this.setVisible(false);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()== bt1)
{
getSql();
System.out.println(sql);
exc = new ConSqlServer(sql);
//exc.executeUpdate();
exc.close();
setTable();
reInitTf();
}
}
public void getSql()
{
getS();
sql = "insert into out " +
"values("+"'"+outID+"'"+","+"'"+productID+"'"+","+"'"+storageID+"'"+
","+amount2+","+"getDate()"+");";
}
public boolean isInt(String s)
{
if(s=="a") return false;
for(int i=0;s.charAt(i)>0&&s.charAt(i)!='a';i++)
{
if(s.charAt(i)<48||s.charAt(i)>57)
return false;
}
return true;
}
public void getS()
{
outID = tf1.getText();
productID = tf2.getText();
storageID = tf3.getText();
amount = tf4.getText(); System.out.println(" ok"+amount+"ok");
if(amount=="")
{
JOptionPane.showMessageDialog(null, "错误,有输入为空!");
}
else{
amountS = amount+"a";
if(isInt(amountS.trim())==false)
{
System.out.println("入库量输入错误,请重输!");
JOptionPane.showMessageDialog(null,"入库量输入错误,请重输!");
tf4.setText("");
return;
}
if(isInt(amountS.trim())==true)
{
amount2 = new Integer(amount.trim());
}
}
}
public void reInitTf()
{
tf1.setText("");
tf2.setText("");
tf3.setText("");
tf4.setText("");
}
private void setTable()
{
table.setValueAt(tf1.getText(), i, 0);
table.setValueAt(tf2.getText(), i, 1);
table.setValueAt(tf3.getText(), i, 2);
table.setValueAt(tf4.getText(), i, 3);
table.setValueAt(Calendar.getInstance().getTime(), i, 4);
table.setVisible(true);
i++;
}
private void initTable()
{
table.setValueAt("出库单号" ,i, 0);
table.setValueAt("产品号" ,i,1);
table.setValueAt("仓库号", i,2);
table.setValueAt("出库量", i,3);
table.setValueAt("出库时间", i,4);
table.setVisible(true);
i++;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -