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

📄 appmain.java

📁 小中型超市的管理系统! JAVA完整的源码!
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
				        }catch(java.sql.SQLException sqls){
				            sqls.printStackTrace();
				            } catch (Exception a) {
							// TODO 自动生成 catch 块
							a.printStackTrace();
						}
				    
						
				        
					
				}
			});
		}
		return jMenuItem3;
	}
	/**
	 * This method initializes jMenuItem4	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */    
	private JMenuItem getJMenuItem4() {
		if (jMenuItem4 == null) {
			jMenuItem4 = new JMenuItem();
			jMenuItem4.setText("销售商品");
			jMenuItem4.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) {    
					Xiaoshou xiaoshou=new Xiaoshou();
					jPanel.add("two",xiaoshou);
					myc.show(jPanel,"two");
				}
			});
		}
		return jMenuItem4;
	}
	/**
	 * This method initializes jMenuItem5	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */    
	private JMenuItem getJMenuItem5() {
		if (jMenuItem5 == null) {
			jMenuItem5 = new JMenuItem();
			jMenuItem5.setText("销售报表");
			jMenuItem5.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) {    
					
					String sql="select * from tb_sellHistory";
				
					try{
				        Connection con=CommonaJdbc.connection;
				        PreparedStatement pstmt=con.prepareStatement(sql);
				        ResultSet rs=null;
						rs=pstmt.executeQuery();
						
						resultSetToExcel(rs,1);
						Runtime.getRuntime().exec("cmd /c start .\\bb.xls");
				        }catch(java.sql.SQLException sqls){
				           sqls.printStackTrace();
				            } catch (Exception a) {
							 //TODO 自动生成 catch 块
							a.printStackTrace();
						}
				}
			});
		}
		return jMenuItem5;
	}
	/**
	 * This method initializes jMenuItem6	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */    
	private JMenuItem getJMenuItem6() {
		if (jMenuItem6 == null) {
			jMenuItem6 = new JMenuItem();
			jMenuItem6.setText("销售历史");
			jMenuItem6.addActionListener(new java.awt.event.ActionListener() {   
				public void actionPerformed(java.awt.event.ActionEvent e) {    
					XiaoshouLS ls=new XiaoshouLS();
					jPanel.add("four",ls);
					myc.show(jPanel,"four");
				} 
			
			});
		}
		return jMenuItem6;
	}
	/**
	 * This method initializes jMenuItem7	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */    
	private JMenuItem getJMenuItem7() {
		if (jMenuItem7 == null) {
			jMenuItem7 = new JMenuItem();
			jMenuItem7.setText("销售盘点");
			jMenuItem7.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) {    
					Pandian pd=new Pandian();
					pd.setVisible(true);
					pd.setBounds(200,200,400,200);
				}
			});
		}
		return jMenuItem7;
	}
	/**
	 * This method initializes jMenuItem8	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */    
	private JMenuItem getJMenuItem8() {
		if (jMenuItem8 == null) {
			jMenuItem8 = new JMenuItem();
			jMenuItem8.setText("用户管理");
			jMenuItem8.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) {    
					YH yh=new YH();
					jPanel.add("six",yh);
					myc.show(jPanel,"six");
					yh.pack();
				}
			});
		}
		return jMenuItem8;
	}
	/**
	 * This method initializes jMenuItem9	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */    
	private JMenuItem getJMenuItem9() {
		if (jMenuItem9 == null) {
			jMenuItem9 = new JMenuItem();
			jMenuItem9.setText("关于软件");
			jMenuItem9.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) {    
			   if(gy)
			   {jPanel.add("zero",jLabel);
			   myc.show(jPanel,"zero");
				Guanyu gy=new Guanyu();
				gy.setVisible(true);
				gy.setBounds(300,200,408,342);
			   }
				}
			});
		}
		return jMenuItem9;
	}
	/**
	 * This method initializes jToolBar	
	 * 	
	 * @return javax.swing.JToolBar	
	 */    
	private JToolBar getJToolBar() {
		if (jToolBar == null) {
			jToolBar = new JToolBar();
			jToolBar.setComponentOrientation(java.awt.ComponentOrientation.LEFT_TO_RIGHT);
			jToolBar.setOrientation(javax.swing.JToolBar.HORIZONTAL);
			jToolBar.add(getJButton());
			jToolBar.add(getJButton1());
			jToolBar.add(getJButton2());
			jToolBar.add(getJButton3());
		}
		return jToolBar;
	}
	/**
	 * This method initializes jButton	
	 * 	
	 * @return javax.swing.JButton	
	 */    
	private JButton getJButton() {
		if (jButton == null) {
			jButton = new JButton();
			jButton.setIcon(new ImageIcon("./images/ImageBar12.jpg"));
			jButton.setPreferredSize(new java.awt.Dimension(78,66));
			jButton.setActionCommand("");  // Generated
			jButton.addActionListener(new java.awt.event.ActionListener() {   
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					
					if(bl)
					{jPanel.add("zero",jLabel);
					myc.show(jPanel,"zero");
					Beifen bf=new Beifen();
					bf.setVisible(true);
					bf.setBounds(300,200,500,400);
					}
					
				    
				}   
			 
			
			});
		}
		return jButton;
	}
	/**
	 * This method initializes jButton1	
	 * 	
	 * @return javax.swing.JButton	
	 */    
	private JButton getJButton1() {
		if (jButton1 == null) {
			jButton1 = new JButton();
			jButton1.setIcon(new ImageIcon("./images/ImageBar21.jpg"));
			jButton1.setPreferredSize(new java.awt.Dimension(78,66));
			jButton1.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) {  
					
					ShangpinGL shangpin= new ShangpinGL();
					jPanel.add("one",shangpin);
					myc.show(jPanel,"one");	
				}
			});
		}
		return jButton1;
	}
	/**
	 * This method initializes jButton2	
	 * 	
	 * @return javax.swing.JButton	
	 */    
	private JButton getJButton2() {
		if (jButton2 == null) {
			jButton2 = new JButton();
			jButton2.setToolTipText("");
			jButton2.setIcon(new ImageIcon("./images/antispyX.png"));
			jButton2.setPreferredSize(new java.awt.Dimension(78,66));  // Generated
			jButton2.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) {    
					Xiaoshou xiaoshou=new Xiaoshou();
					jPanel.add("two",xiaoshou);
					myc.show(jPanel,"two");
				}
			});
		}
		return jButton2;
	}
	/**
	 * This method initializes jButton3	
	 * 	
	 * @return javax.swing.JButton	
	 */    
	private JButton getJButton3() {
		if (jButton3 == null) {
			jButton3 = new JButton();
			jButton3.setIcon(new ImageIcon("./images/ImageBar22_en.jpg"));
			jButton3.setPreferredSize(new java.awt.Dimension(78,66));  // Generated
			jButton3.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) {    
					try {
						CommonaJdbc.connection.close();
					} catch (SQLException e1) {
						// TODO 自动生成 catch 块
						e1.printStackTrace();
					}
					System.exit(0);
				}
			});
		}
		return jButton3;
	}
	/**
	 * This method initializes jPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */    
	private JPanel getJPanel() {
		if (jPanel == null) {
			try {
				jLabel = new JLabel();
				jPanel = new JPanel();
				jPanel.setLayout(myc);  // Generated
				jLabel.setName("jLabel");  // Generated
				jLabel.setText("JLabel");  // Generated
				jLabel.setIcon(new ImageIcon("./images/main.jpg"));  // Generated
				jPanel.setPreferredSize(new java.awt.Dimension(751,595));  // Generated
				jPanel.add(jLabel, jLabel.getName());  // Generated
			}
			catch (java.lang.Throwable e) {
				// TODO: Something
			}
		}
		return jPanel;
	}
	public  void resultSetToExcel(ResultSet rs,int index) throws Exception
	{
	HSSFSheet  sheet = workbook.getSheetAt(index);
	HSSFRow row ;
    HSSFCell cell ;
    HSSFFont f  = workbook.createFont(); 
    HSSFCellStyle style = workbook.createCellStyle(); 
    style.setFont(f);
    f.setFontHeightInPoints((short) 8);//字号    
    style.setAlignment(HSSFCellStyle.ALIGN_CENTER);//左右居中    
    style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//上下居中    

	ResultSetMetaData md=rs.getMetaData();
	int nColumn=md.getColumnCount();
	int iRow=3;
	//写入各条记录,每条记录对应Excel中的一行
    while(rs.next())
    {
    row = sheet.createRow(iRow);
    row.setHeight((short)450);
    for(int j=1;j<=nColumn;j++)
	{ 
	cell =row.createCell((short)(j-1));  
	cell.setCellStyle(style);
	cell.setCellType(HSSFCell.CELL_TYPE_STRING);
	cell.setEncoding(HSSFCell.ENCODING_UTF_16);
	cell.setCellValue(rs.getObject(j).toString());
	}
	iRow++;
	}
    FileOutputStream fOut = new FileOutputStream("bb.xls");
	workbook.write(fOut);
	fOut.flush();
	fOut.close();
	
	 


	}
	public void DataToExcelSheetAt() throws Exception
    {
		POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("./Book1.xls"));  
        workbook = new HSSFWorkbook(fs);
    }
    

	
}//  @jve:decl-index=0:visual-constraint="29,-65"

⌨️ 快捷键说明

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