sql = sql + "" + jText42.getText() + ",";
sql = sql + "" + jText43.getText() + ",";
sql = sql + "" + jText44.getText() + "";
sql = sql + ")";
//使用DBManager对象执行操作 ,并返回成功或失败信息
if(db.executeSql(sql)){
//执行操作后清空文本框
reSetAllTextbox();
JOptionPane.showMessageDialog(null,"操作成功!");
}
else
{
JOptionPane.showMessageDialog(null,"操作失败 !");
}
}
这部分要实现将产品数量信息更新到数据库的功能,用户需要提供产品的数量和其他相关信息。
还要实现对产品出库的历史记录进行查询及修改的操作。我们所要显示的信息包括:款型、出库日期、颜色、操作员、备注和相应鞋码的鞋的数量。由于查询结果是多条的,因此要可以显示查询结果集中的所有记录。
4.3.1此部分功能代码
void jButtonAdd_mouseClicked(MouseEvent e) {
//判断款型和颜色是否为空,若有为空的弹出警告信息
if(jTextkuanxing.getText().trim().equals("")&&jTextkuanxing.getText().trim().equals(""))
{
JOptionPane.showMessageDialog(null," 款型和颜色不许为空!");
return;
}
String sql;
//生成sql语句
sql="select * from ProductStore ";
sql=sql+" where Model='"+jTextkuanxing.getText().trim()+"'";
sql=sql+" and Color='"+jCombocolor.getSelectedItem().toString().trim() +"'";
//执行搜索,检验此款型和颜色对应的鞋是否已存在
rs =db.getResult(sql);
try {
//如果已存在,则将原数据库中的数目加上新加入的数目并执行更新操作
if (rs.first() ) {
sql = "update ProductStore set Number36= Number36+" +jText36.getText().trim()+",";
sql = sql + " Number37 =Number37+" + jText37.getText().trim() + ",";
sql = sql + " Number38 =Number38 +" + jText38.getText().trim() + ",";
sql = sql + " Number39=Number39 +" + jText39.getText().trim() + ",";
sql = sql + " Number40=Number40+" + jText40.getText().trim() +",";
sql = sql + " Number41=Number41+" + jText41.getText().trim() +",";
sql = sql + " Number42=Number42+" + jText42.getText().trim() +",";
sql = sql + " Number43=Number43+" + jText43.getText().trim() +",";
sql = sql + " Number44=Number44+"+ jText44.getText().trim() +" ";
sql = sql + " where Model='" + jTextkuanxing.getText().trim() + "'";
sql = sql + " and Color ='" + jCombocolor.getSelectedItem().toString().trim() + "'";
}
//如果不存在,则执行插入操作,插入新信息
else {
sql="insertinto ProductStore(Model,Color,Number36,Number37,Number38,Number39,Number40,Number41,Number42,Number43,Number44)values( ";
sql = sql + "'" + jTextkuanxing.getText() + "',";
sql = sql + "'" + jCombocolor.getSelectedItem().toString() + "',";
sql = sql + "" + jText36.getText() + ",";
sql = sql + "" + jText37.getText() + ",";
sql = sql + "" + jText38.getText() + ",";
sql = sql + "" + jText39.getText() + ",";
sql = sql + "" + jText40.getText() + ",";
sql = sql + "" + jText41.getText() + ",";
sql = sql + "" + jText42.getText() + ",";
sql = sql + "" + jText43.getText() + ",";
sql = sql + "" + jText44.getText() + "";
sql = sql + ")";
}
}
catch (SQLException ex) {
}
//使用DBManager对象执行操作 ,并返回成功或失败信息
(null,"操作成功!");
}
//当然对于产品入库信息表始终是插入新值
sql="insertintoProductIn(Model,Color,Datein,Operator, Comment,Number36,Number37,Number38,Number39,Number40,Number41,Number42,Number43,Number44)values( ";
sql = sql + "'" + jTextkuanxing.getText() + "',";
sql = sql + "'" + jCombocolor.getSelectedItem().toString() + "',";
sql = sql + "" + jText39.getText() + ",";
sql = sql + "" + jText40.getText() + ",";
sql = sql + "" + jText41.getText() + ",";
sql = sql + "" + jText42.getText() + ",";
sql = sql + "" + jText43.getText() + ",";
sql = sql + "" + jText44.getText() + "";
sql = sql + ")";
else
{
JOptionPane.showMessageDialog(null,"操作失败 !");
}
}
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>