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

📄 clientaddform.java

📁 一个货物管理系
💻 JAVA
字号:
package good;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class ClientAddform extends JFrame implements ActionListener{

	private static final int CENTER = 0;
	/**
	 * @param args
	 */
	  Client client=new Client();
	 
  public ClientAddform()
  {	
	 //DataConn Con = new DataConn();
	 Container container=this.getContentPane();
	 JPanel staticPanel=new JPanel(new GridLayout(3,2),true);
	 JPanel staticPanel1=new JPanel(new FlowLayout(),true);
	 JLabel nameL= new JLabel("客户名称",CENTER);
	 JLabel numberL= new JLabel("客户电话",CENTER);
	 JLabel addressL= new JLabel("客户地址",CENTER);
	 //JLabel priceL= new JLabel("货物价格",CENTER);
	 //final JTextField  codeField=new JTextField("",10);
	 final JTextField  nameField=new JTextField("",10); 
	 final JTextField  numberField=new JTextField("",10); 
	 final JTextField  addressField=new JTextField("",10);
	 JButton okButton=new JButton("确定");
	 JButton cancelButton=new JButton("取消");
	 //jj.getContentPane().add(container);
	 
	 container.add(staticPanel,"Center");	  
	 container.add(staticPanel1,"South");	
	//staticPanel.add(codeL);
	 //staticPanel.add(codeField);
	 staticPanel.add(nameL);
	 staticPanel.add(nameField);
	 staticPanel.add(numberL);
	 staticPanel.add(numberField);
	 staticPanel.add(addressL);
	 staticPanel.add(addressField);
	 staticPanel1.add(okButton);
	 staticPanel1.add(cancelButton);
	 
	 okButton.addActionListener(new ActionListener(){
		 public void actionPerformed(ActionEvent e) {   		
 			
	    	    try {  
	    	    	
	    	     if (nameField.getText().trim().length()>0 && numberField.getText().trim().length()>0 && addressField.getText().trim().length()>0 )
	    	     {
	    	    	 	    	    	 
	    	    	 client.setClientName(nameField.getText());
	    	    	 //System.out.println(StrToint(numberField.getText())) ;
	    	    	 client.setClientNumber(numberField.getText());	    	    	 
	    	    	 client.setClientAddress(addressField.getText());
	    	    	// client.clientAdd();
	    	    	    	
	    	    	
	    	        if (client.checkData()){    	    			
	    	    	 client.clientAdd();
    	    		 if (JOptionPane.OK_OPTION!= JOptionPane.showConfirmDialog(ClientAddform.this,"成功!是否继续添加?","提示",0))
	    	    	 {
	            		dispose();
    	    			 
	    	    	 }	
    	    		 else
	    	    	 {
	    	    		
	    	    		 nameField.setText(""); 
	    	    		 numberField.setText(""); 
	    	    		 addressField.setText(""); 
	    	    	 }	
    	    		 
    	    	 }
	    	     else
    	    	 {
    	    		JOptionPane.showConfirmDialog(ClientAddform.this,"该货物编号已经存在!","提示",0) ; 
    	    		 nameField.setText(""); 
    	    		 numberField.setText(""); 
    	    		 addressField.setText(""); 
                  } 
	    	    }
	    	     else
	   	         {
	    	    	JOptionPane.showConfirmDialog(ClientAddform.this,"请输入完整信息!!","提示",0);
	    	     }  
    	       }
	    	    
	    	    catch(Exception ex)
	    	    {
	    	      ex.printStackTrace();
	    	    }
	    	}

		private int StrToint(String text) {
			int number,i,len,j,unit,qul;			
			len=text.length();
			number=0;
			for (i=len-1;i>=0;i--)
			{
				if (i>=-1) 
				{
				  unit=text.charAt(i)-48;				
				  System.out.println(unit);
				  qul=1;
				  for (j=1;j<len-i;j++)
					  qul=qul*10;
				   number=number+unit*qul;		
				}
			}
			
			return number;
			// TODO Auto-generated method stub		
		};
	    	
	    }); 
	    cancelButton.addActionListener(new ActionListener(){

			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				dispose();
			}
	    	
	    });
	    this.setTitle("添加客户");
	   this.setSize(300,300);
	   this.setBounds(0,50,310,200);
	   this.show();
	  }
	 

	public void actionPerformed(ActionEvent actionEvent) {	  
	  }
	public static void main(String[] args)
	{
		ClientAddform gg=new ClientAddform();
	}

}

⌨️ 快捷键说明

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