JF_view_hkgl.java
上传用户:whbcdz
上传日期:2008-08-04
资源大小:7683k
文件大小:11k
源码类别:

JavaScript

开发平台:

Java

  1. package appjxc.view;
  2. import javax.swing.*;
  3. import java.awt.BorderLayout;
  4. import java.awt.FlowLayout;
  5. import javax.swing.BorderFactory;
  6. import java.awt.Color;
  7. import javax.swing.table.DefaultTableModel;
  8. import java.awt.event.ActionEvent;
  9. import java.awt.event.ActionListener;
  10. import appjxc.model.Obj_Stock;
  11. import appjxc.model.obj_medicine;
  12. import java.awt.Font;
  13. import java.util.Calendar;
  14. import java.util.Locale;
  15. import java.awt.Dimension;
  16. import java.awt.event.KeyEvent;
  17. import java.awt.event.KeyAdapter;
  18. public class JF_view_hkgl extends JInternalFrame{//JFrame {
  19.     BorderLayout borderLayout1 = new BorderLayout();
  20.     JScrollPane jScrollPane1 = new JScrollPane();
  21.     JPanel jPanel1 = new JPanel();
  22.     JTable jTable1 = new JTable();
  23.     FlowLayout flowLayout1 = new FlowLayout();
  24.     JButton jBsave = new JButton();
  25.     JButton jBexit = new JButton();
  26.     DefaultTableModel tableModel = null;
  27.     JButton jBquery = new JButton();
  28.     JLabel jLabel1 = new JLabel();
  29.     JTextField jTdjh = new JTextField();
  30.     java.sql.Date hkrq = null;
  31.     java.util.Iterator iteratorupdate = null;
  32.     public JF_view_hkgl() {
  33.         try {
  34.             jbInit();
  35.             buildTable();
  36.         } catch (Exception ex) {
  37.             ex.printStackTrace();
  38.         }
  39.     }
  40.     public void buildTable(){
  41.         String[] tname = {"客户名称","销售单据号","销售日期","数目","销售总量","销售金额","折扣金额","应收金额","实收金额","未收金额","回款金额","回款日期"};
  42.         java.util.Vector vname = new java.util.Vector();
  43.         for (int i = 0 ; i < tname.length ; i++){
  44.             vname.addElement(tname[i]);
  45.         }
  46.         tableModel = new DefaultTableModel(vname,0);
  47.         jTable1.setModel(tableModel);
  48.     }
  49.     private void jbInit() throws Exception {
  50.         this.getContentPane().setLayout(borderLayout1);
  51.         jPanel1.setBorder(BorderFactory.createLineBorder(Color.black));
  52.         jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
  53.         jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.
  54.                                                 VERTICAL_SCROLLBAR_ALWAYS);
  55.         jBquery.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
  56.         jBquery.setText("查询");
  57.         jBquery.addActionListener(new JF_view_hkgl_jBquery_actionAdapter(this));
  58.         jBexit.addActionListener(new JF_view_hkgl_jBexit_actionAdapter(this));
  59.         jBsave.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
  60.         jBsave.addActionListener(new JF_view_hkgl_jBpd_actionAdapter(this));
  61.         jBexit.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
  62.         this.setClosable(true);
  63.         this.setMaximizable(true);
  64.         jLabel1.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
  65.         jLabel1.setText("输入客户编号:");
  66.         jTdjh.setPreferredSize(new Dimension(226, 27));
  67.         jTdjh.setText("");
  68.         jTdjh.addKeyListener(new JF_view_hkgl_jTdjh_keyAdapter(this));
  69.         flowLayout1.setAlignment(FlowLayout.RIGHT);
  70.         flowLayout1.setHgap(10);
  71.         this.getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
  72.         jBsave.setText("存盘");
  73.         jPanel1.setLayout(flowLayout1);
  74.         this.getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
  75.         jBexit.setText("退出");
  76.         jPanel1.add(jLabel1);
  77.         jPanel1.add(jTdjh);
  78.         jPanel1.add(jBquery);
  79.         jPanel1.add(jBsave);
  80.         jPanel1.add(jBexit);
  81.         jScrollPane1.getViewport().add(jTable1);
  82.         setSize(800,500);
  83.         setVisible(true);
  84.         UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
  85.         SwingUtilities.updateComponentTreeUI(this);
  86.     }
  87.     public void jBquery_actionPerformed(ActionEvent e) {
  88.         if (jTable1.getRowCount() > 0 ) return;
  89.         String khbh = null;
  90.         String queryStr = null;
  91.         khbh = jTdjh.getText().trim();
  92.         queryStr = "select khmc from Obj_client where khbh = '" + khbh + "'";
  93.         java.util.List listmc = null;
  94.         listmc = appjxc.dao.AdapterDao.QueryObject(queryStr);
  95.         if (listmc.size() == 0 ){
  96.             JOptionPane.showMessageDialog(null,"客户编号的数据不存在,请重新输入!!!","系统提示",JOptionPane.ERROR_MESSAGE);
  97.             jTdjh.requestFocus();
  98.             return;
  99.         }
  100.         Object khmc =  listmc.get(0);
  101.         java.util.Calendar calendar = null;
  102.         Locale loc = new Locale("CN");
  103.         calendar = Calendar.getInstance(loc);
  104.         calendar.setTimeInMillis(System.currentTimeMillis());
  105.         int year = calendar.get(Calendar.YEAR);
  106.         int month = calendar.get(Calendar.MONTH) + 1;
  107.         int day = calendar.get(Calendar.DAY_OF_MONTH);
  108.         String rqStr = year + "-" + month + "-" + day;
  109.         hkrq = java.sql.Date.valueOf(rqStr);
  110.         queryStr = "FROM Obj_SellMain where khbh = '" + khbh + "' and qssts = 'F'";
  111.         java.util.List list = null;
  112.         java.util.Iterator iterator = null;
  113.         list = appjxc.dao.AdapterDao.QueryObject(queryStr);
  114.         if (list.size() == 0 ){
  115.             JOptionPane.showMessageDialog(null,"没有满足条件的数据,请重新输入!!!","系统提示",JOptionPane.ERROR_MESSAGE);
  116.             jTdjh.requestFocus();
  117.             return;
  118.         }
  119.         iterator = list.iterator();
  120.         iteratorupdate = list.iterator();
  121.         while(iterator.hasNext()){
  122.             appjxc.model.Obj_SellMain objsell = (appjxc.model.Obj_SellMain)iterator.next();
  123.             java.util.Vector vdata = new java.util.Vector();
  124.             vdata.addElement(khmc);
  125.             vdata.addElement(objsell.getXsdjh());
  126.             vdata.addElement(objsell.getXsrq());
  127.             vdata.addElement(Integer.valueOf(String.valueOf(objsell.getPzs())));
  128.             vdata.addElement(Integer.valueOf(String.valueOf(objsell.getXszs())));
  129.             vdata.addElement(objsell.getXsje());
  130.             vdata.addElement(objsell.getXszk());
  131.             vdata.addElement(objsell.getYsje());
  132.             vdata.addElement(objsell.getSsje());
  133.             System.out.println("wsje = " + objsell.getWsje() );
  134.             vdata.addElement(objsell.getWsje());
  135.             vdata.addElement(objsell.getWsje());
  136.             vdata.addElement(hkrq);
  137.             tableModel.addRow(vdata);
  138.         }
  139.         jTable1.setRowHeight(20);
  140.     }
  141.     public void jBexit_actionPerformed(ActionEvent e) {
  142.         javax.swing.DefaultDesktopManager manger = new DefaultDesktopManager();
  143.         int result = JOptionPane.showOptionDialog(null,"是否真的退出客户回款情况?","系统提示",
  144.                                    JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,
  145.                                    null,new String[]  {"是","否"},"否");
  146.         if (result == JOptionPane.YES_OPTION) {
  147.             try{
  148.                 UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
  149.                 SwingUtilities.updateComponentTreeUI(this);
  150.             }catch(Exception ex){
  151.                 ex.printStackTrace();
  152.             }
  153.            manger.closeFrame(this);
  154.         }
  155.     }
  156.     public void jBsave_actionPerformed(ActionEvent e) {
  157.         if (jTable1.getRowCount() <= 0 ) return;
  158.         int result = JOptionPane.showOptionDialog(null,"是否存盘客户回款信息情况?","系统提示",
  159.                                    JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,
  160.                                    null,new String[]  {"是","否"},"否");
  161.         if (result == JOptionPane.NO_OPTION) return;
  162.         int i = 0;
  163.         while(iteratorupdate.hasNext()){
  164.             String sts = null;
  165.             Double whje = null, hkje = null;
  166.             if (jTable1.getValueAt(i,10)==null){
  167.                 JOptionPane.showMessageDialog(null, "回款金额不允许为空,请录入!!!", "系统提示",
  168.                                               JOptionPane.ERROR_MESSAGE);
  169.                 return;
  170.             }
  171.             try{
  172.                 whje = Double.valueOf(String.valueOf(jTable1.getValueAt(i,9)));
  173.                 hkje = Double.valueOf(String.valueOf(jTable1.getValueAt(i,10)));
  174.                 if (!whje.equals(hkje)) {
  175.                     JOptionPane.showMessageDialog(null, "回款金额必须一次性完成,请重新录入!!!", "系统提示",
  176.                                               JOptionPane.ERROR_MESSAGE);
  177.                     return;
  178.                 }
  179.                 sts = "T";
  180.              }catch (java.lang.NumberFormatException format) {
  181.                 JOptionPane.showMessageDialog(null,
  182.                                               "输入的数据格式有误,请重新录入!!n" +
  183.                                               format.getMessage(),
  184.                                               "系统提示", JOptionPane.ERROR_MESSAGE);
  185.                 System.out.println(format.getMessage());
  186.                 return;
  187.             }
  188.             appjxc.model.Obj_SellMain sell = (appjxc.model.Obj_SellMain)iteratorupdate.next();
  189.             sell.setHkrq(hkrq);
  190.             sell.setHkje(hkje);
  191.             sell.setQssts(sts);
  192.             appjxc.dao.AdapterDao.InsertSellMain(sell);
  193.             i++;
  194.         }
  195.         JOptionPane.showMessageDialog(null,"客户回款数据存盘成功!!!","系统提示",JOptionPane.OK_OPTION);
  196.         jTdjh.setText("");
  197.         String[] tname = {"客户名称","销售单据号","销售日期","数目","销售总量","销售金额","折扣金额","应收金额","实收金额","未收金额","回款金额","回款日期"};
  198.         java.util.Vector vname = new java.util.Vector();
  199.         for (int a = 0 ; a < tname.length ; a++){
  200.             vname.addElement(tname[i]);
  201.         }
  202.         tableModel = new DefaultTableModel(vname,0);
  203.         jTable1.setModel(tableModel);
  204.     }
  205.     public void jTdjh_keyPressed(KeyEvent e) {
  206.         if ( e.getKeyCode()==KeyEvent.VK_ENTER){
  207.             ActionEvent query = new ActionEvent(jBquery,0,null);
  208.             jBquery_actionPerformed(query);
  209.         }
  210.     }
  211. }
  212. class JF_view_hkgl_jBpd_actionAdapter implements ActionListener {
  213.     private JF_view_hkgl adaptee;
  214.     JF_view_hkgl_jBpd_actionAdapter(JF_view_hkgl adaptee) {
  215.         this.adaptee = adaptee;
  216.     }
  217.     public void actionPerformed(ActionEvent e) {
  218.         adaptee.jBsave_actionPerformed(e);
  219.     }
  220. }
  221. class JF_view_hkgl_jTdjh_keyAdapter extends KeyAdapter {
  222.     private JF_view_hkgl adaptee;
  223.     JF_view_hkgl_jTdjh_keyAdapter(JF_view_hkgl adaptee) {
  224.         this.adaptee = adaptee;
  225.     }
  226.     public void keyPressed(KeyEvent e) {
  227.         adaptee.jTdjh_keyPressed(e);
  228.     }
  229. }
  230. class JF_view_hkgl_jBexit_actionAdapter implements ActionListener {
  231.     private JF_view_hkgl adaptee;
  232.     JF_view_hkgl_jBexit_actionAdapter(JF_view_hkgl adaptee) {
  233.         this.adaptee = adaptee;
  234.     }
  235.     public void actionPerformed(ActionEvent e) {
  236.         adaptee.jBexit_actionPerformed(e);
  237.     }
  238. }
  239. class JF_view_hkgl_jBquery_actionAdapter implements ActionListener {
  240.     private JF_view_hkgl adaptee;
  241.     JF_view_hkgl_jBquery_actionAdapter(JF_view_hkgl adaptee) {
  242.         this.adaptee = adaptee;
  243.     }
  244.     public void actionPerformed(ActionEvent e) {
  245.         adaptee.jBquery_actionPerformed(e);
  246.     }
  247. }