📄 addorggoods_frm.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 AddOrgGoods_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();
JTextField jTextField6 = new JTextField();
JLabel jLabel8 = new JLabel();
JTextField jTextField7 = new JTextField();
JComboBox jComboBox2 = new JComboBox();
JLabel jLabel9 = new JLabel();
JLabel jLabel10 = new JLabel();
JComboBox jComboBox3 = new JComboBox();
JTextField jTextField8 = new JTextField();
JLabel jLabel11 = new JLabel();
JTextField jTextField9 = new JTextField();
JLabel jLabel12 = new JLabel();
Border border1;
TitledBorder titledBorder1;
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
//Construct the frame
public AddOrgGoods_Frm() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
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(430, 408));
this.setTitle("期初库存录入");
this.addMouseListener(new AddOrgGoods_Frm_this_mouseAdapter(this));
CbShowList buildC = new CbShowList();
//实现ComboBox1来显示货物代码列表
String goodsSQL = "select goodsid from goodsinfo";
buildC.load_Data(jComboBox1, goodsSQL);
//实现ComboBox2来显示仓库代码列表
String warehousesSQL = "select whid from warehouses";
buildC.load_Data(jComboBox2, warehousesSQL);
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("期初价格");
jTextField6.setBackground(SystemColor.inactiveCaptionText);
jTextField6.setEnabled(false);
jTextField6.setText("");
jLabel8.setText("期初数量");
jLabel9.setText("仓库代码");
jLabel10.setText("货位代码");
jLabel5.setText("进货价格");
jLabel11.setText("仓库名");
jTextField9.setBackground(SystemColor.inactiveCaptionText);
jTextField9.setEnabled(false);
jTextField9.setText("");
jLabel12.setText("货位名 ");
jButton1.setText("确定");
jButton1.addActionListener(new AddOrgGoods_Frm_jButton1_actionAdapter(this));
jButton2.setSelected(false);
jButton2.setText("返回");
jButton2.addActionListener(new AddOrgGoods_Frm_jButton2_actionAdapter(this));
jComboBox1.addActionListener(new AddOrgGoods_Frm_jComboBox1_actionAdapter(this));
jComboBox2.addActionListener(new AddOrgGoods_Frm_jComboBox2_actionAdapter(this));
jComboBox3.addActionListener(new AddOrgGoods_Frm_jComboBox3_actionAdapter(this));
jComboBox3.addMouseListener(new AddOrgGoods_Frm_jComboBox3_mouseAdapter(this));
jTextField8.setText("");
jTextField7.setText("");
jPanel1.add(jTextField1, new XYConstraints(260, 12, 92, -1));
jPanel1.add(jLabel4, new XYConstraints(204, 62, -1, -1));
jPanel1.add(jTextField3, new XYConstraints(260, 59, 92, -1));
jPanel1.add(jLabel1, new XYConstraints(22, 15, -1, -1));
jPanel1.add(jComboBox1, new XYConstraints(79, 12, 92, -1));
jPanel1.add(jLabel2, new XYConstraints(204, 16, -1, 15));
jPanel1.add(jLabel12, new XYConstraints(204, 252, -1, -1));
jPanel1.add(jLabel11, new XYConstraints(204, 205, -1, -1));
jPanel1.add(jLabel8, new XYConstraints(204, 157, -1, -1));
jPanel1.add(jTextField7, new XYConstraints(260, 154, 92, -1));
jPanel1.add(jLabel10, new XYConstraints(22, 252, -1, -1));
jPanel1.add(jTextField4, new XYConstraints(79, 107, 92, -1));
jPanel1.add(jLabel3, new XYConstraints(22, 62, -1, -1));
jPanel1.add(jLabel5, new XYConstraints(22, 110, -1, -1));
jPanel1.add(jLabel6, new XYConstraints(204, 110, -1, -1));
jPanel1.add(jTextField5, new XYConstraints(260, 107, 92, -1));
jPanel1.add(jTextField8, new XYConstraints(79, 154, 92, -1));
jPanel1.add(jLabel7, new XYConstraints(22, 157, -1, -1));
jPanel1.add(jLabel9, new XYConstraints(22, 205, -1, -1));
jPanel1.add(jTextField2, new XYConstraints(78, 59, 92, -1));
jPanel1.add(jComboBox2, new XYConstraints(79, 202, 92, -1));
jPanel1.add(jTextField6, new XYConstraints(260, 202, 92, -1));
jPanel1.add(jComboBox3, new XYConstraints(79, 249, 92, -1));
jPanel1.add(jTextField9, new XYConstraints(260, 249, 92, -1));
contentPane.add(jButton1, new XYConstraints(113, 337, -1, 22));
contentPane.add(jButton2, new XYConstraints(232, 336, -1, 22));
contentPane.add(jPanel1, new XYConstraints(5, 7, 415, 321));
}
//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) {
//实例化GetFrmCentershow,该类是由我们创建的用于实现窗口中心显示
GetFrmCenterShow gfc = new GetFrmCenterShow();
//实例化Main_frame
OrgStorageMan_Frm frame = new OrgStorageMan_Frm();
//让frame显示在屏幕中心
gfc.get_center(frame);
//frame的显示
frame.show();
//关闭本窗口
this.dispose();
}
void jButton1_actionPerformed(ActionEvent e) {
String goodsid = (String) jComboBox1.getSelectedItem();
String amount = jTextField7.getText();
String price = jTextField8.getText();
String whid = (String) jComboBox2.getSelectedItem();
String wsid = (String) jComboBox3.getSelectedItem();
ResultSet rs = null;
ConnectDBBean conn = new ConnectDBBean();
//sql语句
String sql = "select * from originalstorage where goodsid='" +
goodsid + "' and whid='" + whid + "' and wsid='" + wsid + "'";
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_InsertOriginalStorage(?,?,?,?,?)}";
//创建CallableStatement接口调用存储过程
CallableStatement cStatement = conndb.prepareCall(insertsql);
cStatement.setInt(1, Integer.parseInt(goodsid));
cStatement.setInt(2, Integer.parseInt(whid));
cStatement.setInt(3, Integer.parseInt(wsid));
cStatement.setInt(4, Integer.parseInt(amount));
cStatement.setFloat(5, 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) {
}
}
void jComboBox2_actionPerformed(ActionEvent e) {
String warehouseid = (String) jComboBox2.getSelectedItem();
ResultSet rs = null;
//实例化ConnectDBBean
ConnectDBBean conndb = new ConnectDBBean();
//sql查询语句
String sql =
"select whname from warehouses where whid='" +
Integer.parseInt(warehouseid) + "'";
try {
rs = conndb.executeQuery(sql);
if (rs.next()) {
String whname = String.valueOf(rs.getString(1));
jTextField6.setText(whname);
jComboBox3.removeAllItems();
//实现ComboBox3来显示货位代码列表
CbShowList buildC = new CbShowList();
String stallsSQL = "select wsid from warehousestalls where whid='" +
warehouseid + "'";
buildC.load_Data(jComboBox3, stallsSQL);
}
}
catch (Exception ex1) {
}
}
void jComboBox3_actionPerformed(ActionEvent e) {
}
void jComboBox3_mouseClicked(MouseEvent e) {
String whid = (String) jComboBox2.getSelectedItem();
String whstallid = (String) jComboBox3.getSelectedItem();
ResultSet rs = null;
//实例化ConnectDBBean
ConnectDBBean conndb = new ConnectDBBean();
//sql查询语句
String sql =
"select wsname from warehousestalls where whid='" +
Integer.parseInt(whid) + "' and wsid='" +
Integer.parseInt(whstallid) + "'";
try {
rs = conndb.executeQuery(sql);
if (rs.next()) {
String wsname = String.valueOf(rs.getString(1));
jTextField9.setText(wsname);
}
}
catch (Exception ex1) {
System.out.println(ex1.getMessage());
}
}
void this_mouseClicked(MouseEvent e) {
}
}
class AddOrgGoods_Frm_jButton2_actionAdapter
implements java.awt.event.ActionListener {
AddOrgGoods_Frm adaptee;
AddOrgGoods_Frm_jButton2_actionAdapter(AddOrgGoods_Frm adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
class AddOrgGoods_Frm_jButton1_actionAdapter
implements java.awt.event.ActionListener {
AddOrgGoods_Frm adaptee;
AddOrgGoods_Frm_jButton1_actionAdapter(AddOrgGoods_Frm adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
class AddOrgGoods_Frm_jComboBox1_actionAdapter
implements java.awt.event.ActionListener {
AddOrgGoods_Frm adaptee;
AddOrgGoods_Frm_jComboBox1_actionAdapter(AddOrgGoods_Frm adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jComboBox1_actionPerformed(e);
}
}
class AddOrgGoods_Frm_jComboBox2_actionAdapter
implements java.awt.event.ActionListener {
AddOrgGoods_Frm adaptee;
AddOrgGoods_Frm_jComboBox2_actionAdapter(AddOrgGoods_Frm adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jComboBox2_actionPerformed(e);
}
}
class AddOrgGoods_Frm_jComboBox3_actionAdapter
implements java.awt.event.ActionListener {
AddOrgGoods_Frm adaptee;
AddOrgGoods_Frm_jComboBox3_actionAdapter(AddOrgGoods_Frm adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jComboBox3_actionPerformed(e);
}
}
class AddOrgGoods_Frm_jComboBox3_mouseAdapter
extends java.awt.event.MouseAdapter {
AddOrgGoods_Frm adaptee;
AddOrgGoods_Frm_jComboBox3_mouseAdapter(AddOrgGoods_Frm adaptee) {
this.adaptee = adaptee;
}
public void mouseClicked(MouseEvent e) {
adaptee.jComboBox3_mouseClicked(e);
}
}
class AddOrgGoods_Frm_this_mouseAdapter
extends java.awt.event.MouseAdapter {
AddOrgGoods_Frm adaptee;
AddOrgGoods_Frm_this_mouseAdapter(AddOrgGoods_Frm adaptee) {
this.adaptee = adaptee;
}
public void mouseClicked(MouseEvent e) {
adaptee.this_mouseClicked(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -