lzq198491
发贴: 2
积分: 0
|
于 2008-06-08 15:51
import java.sql.*; import java.util.*; import java.awt.*; import java.io.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.border.*; import javax.swing.table.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener;
import javax.swing.AbstractButton; import javax.swing.ButtonGroup; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JRadioButton;
public class Cusfeedback extends JFrame{
JLabel l1 = new JLabel(" * 出货单编号:"); JComboBox cbx_research = new JComboBox(); JLabel empty1 = new JLabel(); JLabel empty2 = new JLabel(); JLabel empty3 = new JLabel(); JLabel empty4 = new JLabel(); JLabel empty5 = new JLabel(); JLabel empty6 = new JLabel(); JLabel empty7 = new JLabel(); JLabel empty8 = new JLabel(); JLabel empty9 = new JLabel(); JLabel empty10 = new JLabel(); JLabel empty11 = new JLabel(); JLabel empty12 = new JLabel(); String integrality = "null",usablity = "null",eligibly = "null",design = "null"; JRadioButton rb_integrality1 = new JRadioButton("产品无生产缺陷"); JRadioButton rb_integrality2 = new JRadioButton("产品有细微生产缺陷"); JRadioButton rb_integrality3 = new JRadioButton("产品有一些生产缺陷"); JRadioButton rb_integrality4 = new JRadioButton("产品有重大生产缺陷");
JRadioButton rb_usablity1 = new JRadioButton("非常好用"); JRadioButton rb_usablity2 = new JRadioButton("很好用"); JRadioButton rb_usablity3 = new JRadioButton("满足要求"); JRadioButton rb_usablity4 = new JRadioButton("不好用");
JRadioButton rb_eligibly1 = new JRadioButton("90%以上合格"); JRadioButton rb_eligibly2 = new JRadioButton("80%以上合格"); JRadioButton rb_eligibly3 = new JRadioButton("50%以上合格"); JRadioButton rb_eligibly4 = new JRadioButton("50%以下合格"); JRadioButton rb_design1 = new JRadioButton("与设计要求完全相符"); JRadioButton rb_design2 = new JRadioButton("与设计要求有细微不符"); JRadioButton rb_design3 = new JRadioButton("与设计要求有部分出路"); JRadioButton rb_design4 = new JRadioButton("完全不符合要求"); JLabel fax = new JLabel(" 备 注:");
JTextArea messageShow = new JTextArea(20,20); JScrollPane messageShowScrollPane = new JScrollPane(messageShow,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
ButtonGroup bg_integrality = new ButtonGroup(); ButtonGroup bg_usablity = new ButtonGroup(); ButtonGroup bg_eligibly = new ButtonGroup(); ButtonGroup bg_design = new ButtonGroup(); JPanel npanel = new JPanel(); JPanel cpanel = new JPanel(); JPanel cpanel1 = new JPanel(); JPanel spanel = new JPanel(); JButton btn1 = new JButton("确 定"); JButton btn2 = new JButton("返 回");
public Cusfeedback(){ this.setTitle("客户反馈信息录入界面"); setSize(700,600); setVisible(true); setLocation(100,100); setResizable(false); setLayout(new BorderLayout()); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); l1.setFont(new java.awt.Font("Dialog",0,20)); npanel.add(l1); npanel.add(cbx_research); npanel.add(empty1); npanel.add(empty2); npanel.add(empty3); npanel.add(empty4); npanel.setLayout(new GridLayout(2,3)); cpanel.add(rb_integrality1); cpanel.add(rb_integrality2); cpanel.add(rb_integrality3); cpanel.add(rb_integrality4);
bg_integrality.add(rb_integrality1); bg_integrality.add(rb_integrality2); bg_integrality.add(rb_integrality3); bg_integrality.add(rb_integrality4); cpanel.add(rb_usablity1); cpanel.add(rb_usablity2); cpanel.add(rb_usablity3); cpanel.add(rb_usablity4); bg_usablity.add(rb_usablity1); bg_usablity.add(rb_usablity2); bg_usablity.add(rb_usablity3); bg_usablity.add(rb_usablity4); cpanel.add(rb_eligibly1); cpanel.add(rb_eligibly2); cpanel.add(rb_eligibly3); cpanel.add(rb_eligibly4); bg_eligibly.add(rb_eligibly1); bg_eligibly.add(rb_eligibly2); bg_eligibly.add(rb_eligibly3); bg_eligibly.add(rb_eligibly4); cpanel.add(rb_design1); cpanel.add(rb_design2); cpanel.add(rb_design3); cpanel.add(rb_design4); bg_design.add(rb_design1); bg_design.add(rb_design2); bg_design.add(rb_design3); bg_design.add(rb_design4); cpanel1.add(fax); cpanel1.add(messageShowScrollPane); // cpanel.add(empty5); // cpanel.add(empty6); // cpanel.add(empty7); // cpanel.add(empty8); cpanel.add(cpanel1); spanel.add(btn1); spanel.add(btn2); cpanel1.setLayout(new GridLayout(2,1)); cpanel.setLayout(new GridLayout(5,4)); spanel.setLayout(new GridLayout(2,2)); add(npanel,BorderLayout.NORTH); add(cpanel,BorderLayout.CENTER); add(spanel,BorderLayout.SOUTH);
btn1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ database_connection(); } }); btn2.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ JFrame dialog = new MainFrame(); dialog.show(); setVisible(false); } }); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch (ClassNotFoundException e1) { e1.printStackTrace(); } try{ Connection Customersconnection = DriverManager.getConnection("jdbc:odbc:CRM");
Statement stmt = Customersconnection.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE); String query = "select output_id from product_output"; ResultSet rs=stmt.executeQuery(query); while(rs.next()){ cbx_research.addItem(rs.getString("output_id")); }
}catch(SQLException e1){ e1.getStackTrace(); }
}
private void database_connection(){ if(rb_integrality1.isSelected()){integrality = "产品无生产缺陷";} if(rb_integrality2.isSelected()){integrality = "产品有细微生产缺陷";} if(rb_integrality3.isSelected()){integrality = "产品有一些生产缺陷";} if(rb_integrality4.isSelected()){integrality = "产品有重大生产缺陷";}
if(rb_usablity1.isSelected()){usablity = "非常好用";} if(rb_usablity2.isSelected()){usablity = "很好用";} if(rb_usablity3.isSelected()){usablity = "满足要求";} if(rb_usablity4.isSelected()){usablity = "不好用";}
if(rb_eligibly1.isSelected()){eligibly = "90%以上合格";} if(rb_eligibly2.isSelected()){eligibly = "80%以上合格";} if(rb_eligibly3.isSelected()){eligibly = "50%以上合格";} if(rb_eligibly4.isSelected()){eligibly = "50%以下合格";}
if(rb_design1.isSelected()){design = "与设计要求完全相符";} if(rb_design2.isSelected()){design = "与设计要求有细微不符";} if(rb_design3.isSelected()){design = "与设计要求有部分出路";} if(rb_design4.isSelected()){design = "完全不符合要求";}
if((eligibly == "")||(integrality =="")||(usablity =="")||(design =="")) { JOptionPane.showMessageDialog( this,"请把所有的选项都勾选完毕后,再按确认!" ); return; }
try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch (ClassNotFoundException e1) { e1.printStackTrace(); } try{ Connection Customersconnection = DriverManager.getConnection("jdbc:odbc:CRM"); Statement stmt = Customersconnection.createStatement(); String query = "insert into product_condition_feedback values('" +cbx_research.getSelectedItem()+"','" +integrality+"','" +usablity+"','" +eligibly+"','" +design+"','" +messageShow.getText()+"')"; int insert = stmt.executeUpdate(query); if (insert == 1){ JOptionPane.showMessageDialog( this,"客户反馈信息,已存入数据库中!" ); }
}catch(SQLException e1){ e1.getStackTrace(); }
}
public static void main(String args[]){ new Cusfeedback(); } }
|