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

📄 fpanel12.java

📁 丽婴房库存销售系统 描述:C/S构架
💻 JAVA
字号:
package src1;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;

import java.awt.*;
import java.awt.event.*;
import java.util.Calendar;

public class FPanel12 extends FunctionPanel implements ActionListener {

	private JLabel label = new JLabel(" FPanel 5");
	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;
	private String productID="";
	private String storageID ="";
	

    private int   amount2 ;
    private String amount ="";
    private String amountS = "";
    private String sql;
    private ConSqlServer exc;
	
	private JTable table;
	private int i;
	public FPanel12() {
		// 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();
		
		
		panel1.setBounds(0,20,260,120);
		panel2.setBounds(260,20,260,120);
		panel3.setBounds(-2,160,600,440);
		
		
		panel3.setLayout(null);
		
		table = new JTable(400,4);
		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);
	   // this.add(panel4);
	    
		panel1.add(label1);panel1.add(tf1);
		panel1.add(label2);panel1.add(tf2);
		panel1.add(label3);panel1.add(tf3);
		panel2.add(label4);panel2.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 入库表 " +
				"values("+"'"+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()
	{
		productID = tf1.getText();
		storageID   = tf2.getText();
	
		amount  = tf3.getText();
		amountS = amount+"a";
		 if(isInt(amountS.trim())==false)
		 {
			 
			 System.out.println("出库量输入错误,请重输!");
			 JOptionPane.showMessageDialog(null,"出库量输入错误,请重输!");
			 tf4.setText("");
			 return;
			
		 }
		amount2 = new Integer(amount.trim());
		
	}
	public void reInitTf()
	{
		tf1.setText("");
		tf2.setText("");
		
		tf3.setText("");
		
		
	}
	private void setTable()
	{
	   table.setValueAt(tf1.getText(), i, 0);
	   table.setValueAt(tf2.getText(), i, 1);
	   table.setValueAt(tf3.getText(), i, 2);
	  
	   table.setValueAt(Calendar.getInstance().getTime(), i, 3);
	   table.setVisible(true);
	   i++;
	}
	private void initTable()
	{
		table.setValueAt("产品号" ,i, 0);
		table.setValueAt("产品名称", i, 1);
		table.setValueAt("仓库号", i, 2);
		  
	    table.setValueAt("库存量", i, 3);
		table.setVisible(false);
	    i++;
	}
	

}

⌨️ 快捷键说明

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