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

📄 ckguanli.java

📁 基于Java——SQL2005 的java课程设计 仓库管理系统。主要功能
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
						    write.close();  
						    photoLabel.setIcon(new   ImageIcon(b));// 显示照片
						    photoLabel.setText(null);// 取消提示文字							  
						                        }   						                      
						                          rs.close();
												   st.close();
												   cn.close();
												 
						  }   
						  catch(Exception   e2)   
						  {   
						  e2.printStackTrace();   
						  } 
						
						
					}   	
					else 
					{
						//JOptionPane.showMessageDialog(null, "dddddd2238");
					}
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
  
				
			}
		});
		
		//出库操作
		CK.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent e) {
				if (!(Eqp_Name.getSelectedItem() instanceof Item)) {
					JOptionPane.showConfirmDialog(CKGuanLi.this, "设备名称为空,请重新填入", "E时代仓库信息管理系统出库管理提示",JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
					Eqp_Name.requestFocus();
					return;
				}
				if(Out_Per.getText().equals(""))
				{
					JOptionPane.showConfirmDialog(CKGuanLi.this, "经手人为空,请重新填入", "E时代仓库信息管理系统出库管理提示",JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
					Out_Per.requestFocus();					
				}
				else if(Out_Num.getText().equals(""))
				{
					JOptionPane.showConfirmDialog(CKGuanLi.this, "出库数量为空,请重新填入", "E时代仓库信息管理系统出库管理提示",JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
					Out_Num.requestFocus();					
				}
				else
				{
					int i= Integer.parseInt(Out_Num.getText());
					if(i>NumSum) 
					{
						JOptionPane.showConfirmDialog(CKGuanLi.this, "库存不足,目前库存量为 "+NumSum+" ,请重新填入", "E时代仓库信息管理系统出库管理提示",JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
						Out_Num.setText(null);
						Out_Num.requestFocus();					
					}
					else{
						sql.insert("insert tb_Out( [Out_ID] , [Eqp_Name] , [Out_Num] ,  [Eqp_Style] , [Eqp_Para] , [Out_Time] , [Out_Oper] , [Out_Per] , [Out_Remark]) values('" + Out_ID.getText().trim() + "','"
								+ Eqp_Name.getItemAt(Eqp_Name.getSelectedIndex()) + "','" + Out_Num.getText().trim() + "','"
								+ Eqp_Style.getItemAt(Eqp_Style.getSelectedIndex()) + "','"
								+ Eqp_Para.getText().trim() + "','" + Out_Time.getText().trim() + "','"
								+ Out_Oper.getText().trim() + "','" + Out_Per.getText().trim() + "','"+ Out_Remark.getText().trim()+"')");
						int Num=NumSum - Integer.parseInt(Out_Num.getText().trim());
						if(Num>0)//对库存表的操作
						{
							sql.update("UPDATE tb_Stor SET [Stor_Num] = '"+ Num + "'" + "where "+ "Eqp_Name='" + Eqp_Name.getItemAt(Eqp_Name.getSelectedIndex()) +"'");//
						}
						else
						{
							String sqlyuju= "DELETE FROM tb_Stor where "+ "Eqp_Name='" + Eqp_Name.getItemAt(Eqp_Name.getSelectedIndex()) +"'";
							sql.delete(sqlyuju);
						}
							
						JOptionPane   j   =   new   JOptionPane("出库完成,是否继续执行出库操作?",   JOptionPane.QUESTION_MESSAGE,JOptionPane.YES_NO_OPTION,null,new   Object[]{"  是  ","  否  "});   
						Object[]   xx   =   j.getOptions();   
						int k=JOptionPane.showOptionDialog(CKGuanLi.this,"出库完成,是否继续执行出库操作??","E时代仓库信息管理系统出库管理提示",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,xx,"  否  ");  
						if(k==0)
						{
							CZ.doClick();
							
							List khInfo = sql.getEqp_name((String) Eqp_Style.getItemAt(Eqp_Style.getSelectedIndex()));
							List<Item> items = new ArrayList<Item>();
							Eqp_Name.removeAllItems();
							Iterator iter1 = khInfo.iterator();
							if(!iter1.hasNext())
							{
								CZ.doClick();
							}
							
							for (Iterator iter = khInfo.iterator(); iter.hasNext();) {
								List element = (List) iter.next();
								Item item = new Item();
								//item.setId(element.get(0).toString().trim());
								item.setName(element.get(0).toString().trim());
								if (items.contains(item))
									continue;
								items.add(item);
								Eqp_Name.addItem(item);
								}
										
							try {
								Out_ID.setText("E_OUT_"+dateStr+getMaxId());
							} catch (SQLException e1) {
								// TODO Auto-generated catch block
								e1.printStackTrace();
							}
						}
						else
						dispose();	
					}
					
				}
			}			
		});
		
		
		addInternalFrameListener(new initTasks());
		
		
	}
	
	

	
	
	
	private void initTimeField() {// 启动进货时间线程
		new Thread(new Runnable() {
			public void run() {
				try {
					while (true) {
						Date jhsjDate = new Date();
						Out_Time.setText(jhsjDate.toLocaleString());
						Thread.sleep(100);
					}
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}).start();
	}
	
	
	// 获取出库表中设备编号的14位后面的最大ID
	
	private static String getMaxId() throws SQLException {
		String MaxId=""+2;
		String sqlyuju = "select * from tb_Out";
		ResultSet set = sql.query(sqlyuju);
		if(!set.next())
		{
			MaxId="1";//表为空时从0001开始
			return MaxId;
		}
		
		int i=1;
		for(;set.next();)   
		{   
			String ID =set.getString("Out_ID");
			MaxId =ID.substring(14,ID.length());
			
			int j=Integer.parseInt(MaxId);
			if(j>i){
				i=j;				
			}			
			MaxId=""+(i+1);	
		}		
		return MaxId;
			
	}
	
	public class InputKeyListener extends KeyAdapter {
		public void keyTyped(KeyEvent e) {
			String key="0123456789"+(char)8;
			if(key.indexOf(e.getKeyChar())<0){
				e.consume();
			}
		}//只容许输入0到9的数字,键盘侦听
	}
	
	
	// 设置组件位置并添加到容器中
	private void setupComponet(JComponent component, int gridx, int gridy,
			int gridwidth, int gridheight,int ipadx, boolean fill) {
		final GridBagConstraints gridBagConstrains = new GridBagConstraints();
		gridBagConstrains.gridx = gridx;
		gridBagConstrains.gridy = gridy;
		if (gridwidth > 1)
			gridBagConstrains.gridwidth = gridwidth;
		if(gridheight >1)
			gridBagConstrains.gridheight = gridheight;
		if (ipadx > 0)
			gridBagConstrains.ipadx = ipadx;
		gridBagConstrains.insets = new Insets(5, 1, 3, 1);
		if (fill)
			gridBagConstrains.fill = GridBagConstraints.HORIZONTAL;
		getContentPane().add(component, gridBagConstrains);
	}
	
	 public void initComboBox() {

		 List khInfo = sql.getEqp_name((String) Eqp_Style.getItemAt(Eqp_Style.getSelectedIndex()));
			List<Item> items = new ArrayList<Item>();
			Eqp_Name.removeAllItems();
			Iterator iter1 = khInfo.iterator();
			if(!iter1.hasNext())
			{
				CZ.doClick();
			}
			
			for (Iterator iter = khInfo.iterator(); iter.hasNext();) {
				List element = (List) iter.next();
				Item item = new Item();
				//item.setId(element.get(0).toString().trim());
				item.setName(element.get(0).toString().trim());
				if (items.contains(item))
					continue;
				items.add(item);
				Eqp_Name.addItem(item);
				}
	 }
	
	
	// 窗体的初始化任务
	private final class initTasks extends InternalFrameAdapter {
		public void internalFrameActivated(InternalFrameEvent e) {
			super.internalFrameActivated(e);
			initTimeField();
			initComboBox();
			//initKehuField();
			//initPiaoHao();
			//initSpBox();
		}
	}
}

⌨️ 快捷键说明

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