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

📄 soft.java

📁 软件工程作业的一个库房模拟系统 库房内容自己数组定义 主要体现各层数据流图特性
💻 JAVA
字号:
import java.awt.*;
import java.io.*; 
import java.util.*;
import java.net.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.JOptionPane;
import javax.swing.*;
class myframe extends Frame  implements ActionListener
{
			        String daimas[]=new String[20],
			        names[]=new String[20],
			        nums[]=new String[20],
			        peoples[]=new String[20],
			        riqis[]=new String[20];
			        int i=5;
			        
			        
			        
	Image bg;
	Button bt1,bt2,bt3,bt4,bt5,bt6;
	TextField daima,name,num,people,riqi;
	URL pos;
	TextArea t1=new TextArea (null,12,90,TextArea.SCROLLBARS_BOTH);
	
	public myframe()
	{
		
		t1.append("代码"+"\t"+"\t"+"品名"+"\t"+"\t"+"数量"+"\t"+"\t"+"人员"+"\t"+"\t"+"日期"+"\n");
		//----------------chushiwenjian
		names[0]="shuju";
			        names[1]="离散";
			        names[2]="高数";
			        names[3]="英语";
			        names[4]="模电";
			        names[5]="数逻";
			        daimas[0]="00001";
			        daimas[1]="00002";
			        daimas[2]="00003";
			        daimas[3]="00004";
			        daimas[4]="00005";
			        daimas[5]="00006";
			        nums[0]="100";
			        nums[1]="100";
			        nums[2]="100";
			        nums[3]="100";
			        nums[4]="100";
			        nums[5]="100";
			        for(int j=0;j<=i;++j)
			        {
			        	peoples[j]="任国立";
			        	riqis[j]="04-10-11";
			        	}
		//Frame f=new Frame("库房管理系统");
		Panel p1,p2,p21,p22,p3,p4,p5,p6;
		Label l1,l2,l3,l4,l5,l6,l7;
		//TextArea t1=new TextArea (null,5,30,TextArea.SCROLLBARS_BOTH);
		TextArea t2=new TextArea (null,5,30,TextArea.SCROLLBARS_BOTH);
		l1=new Label("任国立的仓库管理模拟下系统");
		l2=new Label("操作区域",Label.CENTER);
		l3=new Label("代码");
		l4=new Label("物料品名");
		l5=new Label("数量");
		l6=new Label("人员");
		l7=new Label("日期");
		daima=new TextField(20);
		//daima.addTextListener(this);
		name=new TextField(20);
		num=new TextField(20);
		people=new TextField(20);
		riqi=new TextField(20);
		setLayout(new BorderLayout());
		//---------------------------------------------
		p1=new Panel();
		p2=new Panel();
		p3=new Panel();
		p4=new Panel();
		p5=new Panel();
		p6=new Panel();
		p21=new Panel();
		p22=new Panel();
		//------------------------------------------------
		bt1=new Button("提交入库单");
		bt1.addActionListener(this);
		bt2=new Button("查询当前库存");
		bt2.addActionListener(this);
		bt3=new Button("清除工作区域");
		bt3.addActionListener(this);
		bt4=new Button("提交出库单");
		bt4.addActionListener(this);
		bt5=new Button("保存更新仓库");
		bt5.addActionListener(this);
		
		
		bt2.setSize(20,10);
		//--------------------------------------------
		p1.setBackground(Color.blue);
		//---------------------------------------
		p2.setBackground(Color.red);
		p2.setLayout(new GridLayout(6,1));
		p2.add(l2);
		p2.add(bt1);
		p2.add(bt2);
		p2.add(bt3);
		p2.add(bt4);
		p2.add(bt5);
		
		//------------------------------------------
		p3.setBackground(Color.yellow);
		p3.add(t1);
		//----------------------------------------------
		p4.setBackground(Color.gray);
		p4.setLayout(new GridLayout(10,1));
		p4.add(l3);
		p4.add(daima);
		p4.add(l4);
		p4.add(name);
		p4.add(l5);
		p4.add(num);
		p4.add(l6);
		p4.add(people);
		p4.add(l7);
		p4.add(riqi);
		//p4.add(t2);
		//---------------------------------------------
		p5.setBackground(Color.green);
		p5.add(l1);
		//------------------------------------------------
		p6.setBackground(Color.blue);
		//-------------------------------------------
		setSize(400,300);
		add(p1,BorderLayout.CENTER);
		add(p2,BorderLayout.WEST);
		add(p5,BorderLayout.NORTH);
		add(p6,BorderLayout.EAST);
		//p5.add(bt2);
		p1.setLayout(new GridLayout(2,1));
		//p5.setLayout(new GridLayout(1,3));
	
		//p5.setSize(30,10);
		//p1.add(p5);
		//
		p5.setLocation(50,50);
		p1.add(p3);
		p1.add(p4);
		//*********************************************
		
		
		      this.addWindowListener(new WindowAdapter()
      {
          public void windowClosing(WindowEvent e)
          {
              System.exit(0);
          }
      });
      
		show();
		
			 
		//f.pack();
		//f.setVisible(true);

		}
		//************************************
				//************************************************
		public void actionPerformed(ActionEvent e)
{
//-----------------------------------------------
/*JOptionPane.showMessageDialog(this,"数字输入完全了吗???","提示对话框",JOptionPane.WARNING_MESSAGE);
try{x1=Integer.parseInt(t1.getText());}
catch(NumberFormatException ee)
{
x1=0;
}
try{x2=Integer.parseInt(t2.getText());}
catch(NumberFormatException ee)
{
x2=0;
}*/

if(e.getSource()==bt1)//入库
    {
    	int x1=0,x2=0,total=0;
    	//int flag[]=new int[50];
    	int flag=0;
    	int n=-1;
    	for(int m=0;m<=i;++m)
    	{
    		if(daima.getText().equals(daimas[m]))
    	{flag=1;
    	n=m;
    	break;}
      }
      if(flag==0)//非法
    	{JOptionPane.showMessageDialog(this,"你提交的领料单错误!!!请核对检查","警告对话框",JOptionPane.WARNING_MESSAGE);}
    	else
    	{
    		try{
    		x1=Integer.parseInt(num.getText());
    		x2=Integer.parseInt(nums[n]);
    		}
        catch(NumberFormatException ee)
        {
        x1=0;
        x2=0;
        }   
       total=x1+x2;
       nums[n]=Integer.toString(total);
       daimas[19]=daima.getText();
			 names[19]=name.getText();
			 nums[19]=num.getText();
			 peoples[19]=people.getText();
			 riqis[19]=riqi.getText();
			 t1.append("你最近提交成功的领料单为:"+"\n");
    	t1.append(daimas[19]+"\t"+"\t"+names[19]+"\t"+"\t"+nums[19]+"\t"+"\t"+peoples[19]+"\t"+"\t"+riqis[19]+"\n");
    	JOptionPane.showMessageDialog(this,"你提交的领料单成功通过验证!!!请查询后核对验证","提示对话框",JOptionPane.WARNING_MESSAGE);
    	++i;
    }
    	};
	   if(e.getSource()==bt2)
	   {
	   	t1.append("-------------------------------------------------------------------------------"+"\n");
	   	t1.append("当前库存查询结果为"+"\n");
	   	
	   	for(int k=0;k<=i;++k)
	   	{
	   		t1.append("-------------------------------------------------------------------------------"+"\n");
	   		t1.append(daimas[k]+"\t"+"\t"+names[k]+"\t"+"\t"+nums[k]+"\t"+"\t"+peoples[k]+"\t"+"\t"+riqis[k]+"\n");}
	   	}
	   if(e.getSource()==bt3)
	   {
	   	t1.setText("");
	   	t1.append("代码"+"\t"+"\t"+"品名"+"\t"+"\t"+"数量"+"\t"+"\t"+"人员"+"\t"+"\t"+"日期"+"\n");
	   	}
	   	//-----------------出库
	   	if(e.getSource()==bt4)
	   {
	   	int x1=0,x2=0,total=0;
    	//int flag[]=new int[50];
    	int flag=0;
    	int n=-1;
    	for(int m=0;m<=i;++m)
    	{
    		if(daima.getText().equals(daimas[m]))
    	{flag=1;
    	n=m;
    	break;}
      }
      if(flag==0)//非法
    	{JOptionPane.showMessageDialog(this,"你提交的出库单错误!!!请核对检查","警告对话框",JOptionPane.WARNING_MESSAGE);}
    	else
    	{
    		try{
    		x1=Integer.parseInt(num.getText());
    		x2=Integer.parseInt(nums[n]);
    		}
        catch(NumberFormatException ee)
        {
        x1=0;
        x2=0;
        }   
       total=x2-x1;
       if(total>=0)//有货
       {
       nums[n]=Integer.toString(total);
       daimas[19]=daima.getText();
			 names[19]=name.getText();
			 nums[19]=num.getText();
			 peoples[19]=people.getText();
			 riqis[19]=riqi.getText();
			 t1.append("你最近提交成功的出库单为:"+"\n");
    	t1.append(daimas[19]+"\t"+"\t"+names[19]+"\t"+"\t"+nums[19]+"\t"+"\t"+peoples[19]+"\t"+"\t"+riqis[19]+"\n");
    	JOptionPane.showMessageDialog(this,"你提交的出库单成功通过验证!!!请查询后核对验证","提示对话框",JOptionPane.WARNING_MESSAGE);
    	}
    else//缺货
    {
    	int que=0;
    	que=-total; 
    	JOptionPane.showMessageDialog(this,"仓库货存不足!!!已向领料人发出缺货单!!"+"\n"+"缺货物品为"+names[n]+"\n"+"缺货数量为"+que,"提示对话框",JOptionPane.WARNING_MESSAGE);}
    }
	  }
	  if(e.getSource()==bt5)
	   {
	   	//t1.append("代码"+"\t"+"\t"+"品名"+"\t"+"\t"+"数量"+"\t"+"\t"+"人员"+"\t"+"\t"+"日期"+"\n");
	   	try{

			//File savefile= new File("e:\\jdk\\cangku.txt");

			//RandomAccessFile r=new RandomAccessFile(savefile,"rw");
        FileOutputStream fout=new FileOutputStream ("e:\\jdk\\cangku.txt");
        byte buf[]=t1.getText().getBytes();
        fout.write(buf);
        fout.close();
        JOptionPane.showMessageDialog(this,"保存更新成功","提示对话框",JOptionPane.WARNING_MESSAGE);
        //FileWriter fout=new FileWriter("e:\\jdk\\cangku.txt");
        //fout.write(t1.getText());*/

			//for(int k=0;k<i;k++)
      //{
      //	r.writeUTF(daimas[k]+"\t"+"\t"+names[k]+"\t"+"\t"+nums[k]+"\t"+"\t"+peoples[k]+"\t"+"\t"+riqis[k]+"\n");
      //}

			

		}catch(IOException ie){	}
	   	}
	  
}
			}
		
		/*class churuku extends myframe
		{
		public void chuku()
		{
			 
			 //s[1]=s[1].concat(daimas);
			 //s[1].insert(9,names);
			 
			}
			
		}*/
		public class soft extends JFrame
		{
			JPanel panel = new JPanel(new FlowLayout());
			
			public static void main(String args[])
			{
				JFrame frame = new JFrame("");
				JPanel p = new JPanel(new GridLayout(0,1));    JTextField tfUserName = new JTextField();    JPasswordField tfPassword = new JPasswordField();    p.add(new JLabel("Username: "));    p.add(tfUserName);    p.add(new JLabel("Password: "));    p.add(tfPassword);
    /*JOptionPane.showConfirmDialog(frame // may want to pass your application frame here                               ,p                               ,"Login"                               ,JOptionPane.OK_CANCEL_OPTION                               ,JOptionPane.PLAIN_MESSAGE);*/
				/*String input;
	
					input=JOptionPane.showInputDialog("1-??\n"+"2-??\n"+"3-???\n"+"4-???\n"); 
				
			//JOptionPane.showMessageDialog(null,"????");//System.exit(0); 
				*/
				if (JOptionPane.showConfirmDialog(frame // may want to pass your application frame here                               ,p                               ,"Login"                               ,JOptionPane.OK_CANCEL_OPTION                               ,JOptionPane.PLAIN_MESSAGE                                ) == JOptionPane.OK_OPTION)	
                                		
            {
            	if(tfUserName.getText().equalsIgnoreCase("rgl") && tfPassword.getText().equalsIgnoreCase("123"))
            	
            	{new myframe();}
            
            else
            {
         JOptionPane.showMessageDialog(null,"对不起,你的密码错误!!!"+"\n"+"请与管理员联系!!!","警告对话框",JOptionPane.WARNING_MESSAGE);
         	  System.exit(0);}
         	  }
				//chuku();
				}}

⌨️ 快捷键说明

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