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

📄 addingoods_frm.java

📁 库存管理信息系统
💻 JAVA
字号:
package KcglSys;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import javax.swing.border.*;
import java.sql.*;
import javax.swing.event.*;

/**
 * <p>Title: 库存管理信息系统</p>
 * <p>Description: 库存管理信息系统,企业好帮手</p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: ios</p>
 * @author dragon
 * @version 1.0
 */

public class AddInGoods_Frm
    extends JFrame {
  JPanel contentPane;
  XYLayout xYLayout1 = new XYLayout();
  JPanel jPanel1 = new JPanel();
  JLabel jLabel1 = new JLabel();
  XYLayout xYLayout2 = new XYLayout();
  JTextField jTextField1 = new JTextField();
  JComboBox jComboBox1 = new JComboBox();
  JLabel jLabel2 = new JLabel();
  JLabel jLabel3 = new JLabel();
  JTextField jTextField2 = new JTextField();
  JLabel jLabel4 = new JLabel();
  JTextField jTextField3 = new JTextField();
  JLabel jLabel5 = new JLabel();
  JTextField jTextField4 = new JTextField();
  JLabel jLabel6 = new JLabel();
  JTextField jTextField5 = new JTextField();
  JLabel jLabel7 = new JLabel();
  JLabel jLabel8 = new JLabel();
  JTextField jTextField7 = new JTextField();
  JTextField jTextField8 = new JTextField();
  Border border1;
  TitledBorder titledBorder1;
  JButton jButton1 = new JButton();
  JButton jButton2 = new JButton();
  //定义StrArray用于保存从AddInStorageTable中传递来的仓库名和货位名等参数
  String[] StrArray;
  //Construct the frame
  public AddInGoods_Frm(String[] StrArray) {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
      this.StrArray = StrArray;
      jbInit();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }

  //Component initialization
  private void jbInit() throws Exception {
    contentPane = (JPanel)this.getContentPane();
    border1 = BorderFactory.createEtchedBorder(Color.white,
                                               new Color(165, 163, 151));
    titledBorder1 = new TitledBorder(border1, "货物录入");
    contentPane.setLayout(xYLayout1);
    this.setSize(new Dimension(403, 305));
    this.setTitle("入库货物录入");
    CbShowList buildC = new CbShowList();
    //实现ComboBox1来显示货物代码列表
    String goodsSQL = "select goodsid from goodsinfo";
    buildC.load_Data(jComboBox1, goodsSQL);
    jPanel1.setBorder(titledBorder1);
    jPanel1.setLayout(xYLayout2);
    jLabel1.setText("货物代码");
    jTextField1.setBackground(SystemColor.inactiveCaptionText);
    jTextField1.setEnabled(false);
    jTextField1.setText("");
    jLabel2.setText("名 称");
    jLabel3.setText("型 号");
    jTextField2.setBackground(SystemColor.inactiveCaptionText);
    jTextField2.setEnabled(false);
    jTextField2.setText("");
    jLabel4.setText("计量单位");
    jTextField3.setBackground(SystemColor.inactiveCaptionText);
    jTextField3.setEnabled(false);
    jTextField3.setText("");
    jTextField4.setBackground(SystemColor.inactiveCaptionText);
    jTextField4.setEnabled(false);
    jTextField4.setText("");
    jLabel6.setText("销售价格");
    jTextField5.setBackground(SystemColor.inactiveCaptionText);
    jTextField5.setEnabled(false);
    jTextField5.setText("");
    jLabel7.setText("价 格");
    jLabel8.setText("数 量");
    jLabel5.setText("进货价格");
    jButton1.setText("确定");
    jButton1.addActionListener(new AddInGoods_Frm_jButton1_actionAdapter(this));
    jButton2.setSelected(false);
    jButton2.setText("返回");
    jButton2.addActionListener(new AddInGoods_Frm_jButton2_actionAdapter(this));
    jTextField8.setText("");
    jTextField7.setText("");
    jComboBox1.addActionListener(new AddInGoods_Frm_jComboBox1_actionAdapter(this));
    jPanel1.add(jLabel4, new XYConstraints(191, 62, -1, -1));
    jPanel1.add(jTextField3, new XYConstraints(247, 59, 92, -1));
    jPanel1.add(jLabel8, new XYConstraints(191, 157, -1, -1));
    jPanel1.add(jTextField7, new XYConstraints(247, 154, 92, -1));
    jPanel1.add(jTextField4, new XYConstraints(70, 107, 92, -1));
    jPanel1.add(jLabel3, new XYConstraints(13, 62, -1, -1));
    jPanel1.add(jLabel5, new XYConstraints(13, 110, -1, -1));
    jPanel1.add(jLabel6, new XYConstraints(191, 110, -1, -1));
    jPanel1.add(jTextField5, new XYConstraints(247, 107, 92, -1));
    jPanel1.add(jTextField8, new XYConstraints(70, 154, 92, -1));
    jPanel1.add(jLabel7, new XYConstraints(13, 157, -1, -1));
    jPanel1.add(jTextField2, new XYConstraints(70, 59, 92, -1));
    jPanel1.add(jLabel1, new XYConstraints(13, 15, -1, -1));
    jPanel1.add(jComboBox1, new XYConstraints(70, 12, 92, -1));
    jPanel1.add(jLabel2, new XYConstraints(191, 16, -1, 15));
    jPanel1.add(jTextField1, new XYConstraints(247, 12, 92, -1));
    contentPane.add(jButton1, new XYConstraints(94, 241, -1, 22));
    contentPane.add(jButton2, new XYConstraints(213, 241, -1, 22));
    contentPane.add(jPanel1, new XYConstraints(5, 7, 381, 224));
  }

  //Overridden so we can exit when window is closed
  protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      this.dispose();
    }
  }

  void jButton2_actionPerformed(ActionEvent e) {
    this.dispose();
  }

  void jButton1_actionPerformed(ActionEvent e) {
    String goodsid = (String) jComboBox1.getSelectedItem();
    String amount = jTextField7.getText();
    String price = jTextField8.getText();
    String isid = StrArray[0];
    String whid=StrArray[1];
    String wsid=StrArray[2];
    String proid=StrArray[3];
    ResultSet rs = null;
    ConnectDBBean conn = new ConnectDBBean();
    //sql语句
    String sql = "select * from isgoods where isid='" +
        isid + "' and goodsid='" + goodsid + "' and proid='"+
        proid+"'";
    try {
      rs = conn.executeQuery(sql);
      if (rs.next()) {
        JOptionPane.showMessageDialog(null, "您在该仓库货位已经录入过该货物了,请重新输入!");
      }
      else {
        Connection conndb = null;
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        conndb = DriverManager.getConnection("jdbc:odbc:KcglSys", "sa", "sa");
        //创建调用存储过程得SQL语句
        String insertsql = "{call sp_InsertIsGoods(?,?,?,?,?,?,?)}";
        //创建CallableStatement接口调用存储过程
        CallableStatement cStatement = conndb.prepareCall(insertsql);
        cStatement.setInt(1, Integer.parseInt(isid));
        cStatement.setInt(2, Integer.parseInt(goodsid));
        cStatement.setInt(3, Integer.parseInt(proid));
        cStatement.setInt(4, Integer.parseInt(whid));
        cStatement.setInt(5, Integer.parseInt(wsid));
        cStatement.setInt(6, Integer.parseInt(amount));
        cStatement.setFloat(7, Float.parseFloat(price));
        cStatement.executeUpdate();
        cStatement.close();
        JOptionPane.showMessageDialog(null, "货物录入操作成功!");
        rs.close();
      }
    }
    catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
  }

  void jComboBox1_actionPerformed(ActionEvent e) {
    String goodsid = (String) jComboBox1.getSelectedItem();
    ResultSet rs = null;
    //实例化ConnectDBBean
    ConnectDBBean conndb = new ConnectDBBean();
    //sql查询语句
    String sql =
        "select gname,gstyle,gunit,inprice,outprice" +
        " from goodsinfo  where goodsid='" +
        Integer.parseInt(goodsid) + "'";
    try {
      rs = conndb.executeQuery(sql);
      if (rs.next()) {
        String goodsname = String.valueOf(rs.getString(1));
        jTextField1.setText(goodsname);
        String gstyle = String.valueOf(rs.getString(2));
        jTextField2.setText(gstyle);
        String gunit = String.valueOf(rs.getString(3));
        jTextField3.setText(gunit);
        String inprice = String.valueOf(rs.getString(4));
        jTextField4.setText(inprice);
        String outprice = String.valueOf(rs.getString(5));
        jTextField5.setText(outprice);
      }
    }
    catch (Exception ex1) {
    }

  }
}

class AddInGoods_Frm_jButton2_actionAdapter
    implements java.awt.event.ActionListener {
  AddInGoods_Frm adaptee;

  AddInGoods_Frm_jButton2_actionAdapter(AddInGoods_Frm adaptee) {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e) {
    adaptee.jButton2_actionPerformed(e);
  }
}

class AddInGoods_Frm_jButton1_actionAdapter
    implements java.awt.event.ActionListener {
  AddInGoods_Frm adaptee;

  AddInGoods_Frm_jButton1_actionAdapter(AddInGoods_Frm adaptee) {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e) {
    adaptee.jButton1_actionPerformed(e);
  }
}

class AddInGoods_Frm_jComboBox1_actionAdapter
    implements java.awt.event.ActionListener {
  AddInGoods_Frm adaptee;

  AddInGoods_Frm_jComboBox1_actionAdapter(AddInGoods_Frm adaptee) {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e) {
    adaptee.jComboBox1_actionPerformed(e);
  }
}

⌨️ 快捷键说明

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