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

📄 fpanel5.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 FPanel5 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 name  ="";
	
	private String brand ="";
	
    private String 产地 ="";
    private String sql;
    private ConSqlServer exc;
	
	private JTable table;
	private int i;
	public FPanel5() {
		// TODO 自动生成构造函数存根
		
		//this.add(label);
		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,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 getS()
	{
		productID = tf1.getText();
		name   = tf2.getText();
		
		brand   = tf3.getText();
		
		产地    = tf4.getText();
		
		 
		
		
	}
	
	public void getSql()
	{
		getS();
		sql = "update  product  set " + "产品名称="+ "'"+name+"'"+
				
		" where 产品号="+productID;
				
	}
	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(true);
	    i++;
	}
	

}

⌨️ 快捷键说明

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