代码拉取完成,页面将自动刷新
同步操作将从 Larkkkkkkk1/仓储管理系统 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/ *创建类,该类中只有属性值,并且属性值对应数据表中的所有字段*/
/*bean包中的将功能、处理、值、数据库访问和其他任何可以用java代码创造的对象进行打包*/
/*1.商品表:*/ ..
public class Goods {
private int id;
private String goodsname;
private String goodsstyle;
private int goodsnumber;
private String storageID;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getGoodsname() {
return goodsname;
}
public void setGoodsname(String goodsname) {
this.goodsname = goodsname;
}
public String getGoodsstyle() {
return goodsstyle;
}
public void setGoodsstyle(String goodsstyle) {
this.goodsstyle = goodsstyle;
}
public int getGoodsnumber() {
return goodsnumber;
}
public void setGoodsnumber(int goodsnumber) {
this.goodsnumber = goodsnumber;
}
public String getStorageID() {
return storageID;
}
public void setStorageID(String storageID) {
this.storageID = storageID;
}
}
/*2.仓库表:*/
public class Storage {
private int id;
private String storagename;
private String storagestyle;
private int storageID;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getStoragename() {
return storagename;
}
public void setStoragename(String storagename) {
this.storagename = storagename;
}
public String getStoragestyle() {
return storagestyle;
}
public void setStoragestyle(String storagestyle) {
this.storagestyle = storagestyle;
}
public int getStorageID() {
return storageID;
}
public void setStorageID(int storageID) {
this.storageID = storageID;
}
}
/*3.人员表:*/
public class User {
private int id;
private String username;
private String userpwd;
private String flag;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getusername() {
return username;
}
public void setusername(String username) {
this.username = username;
}
public String getuserpwd() {
return userpwd;
}
public void setuserpwd(String userpwd) {
this.userpwd = userpwd;
}
public String getFlag() {
return flag;
}
public void setFlag(String flag) {
this.flag = flag;
}
}
/*dao包:接口中有对数据库进行操作的方法;接口的实现类:具体封装了对数据库的操作方法*/
//1.创建一个Goodsmanagement接口:用于商品管理
import java.sql.SQLException;
import net.wms.bean.Goods;
public interface Goodsmanagement {
//查询
public void Query(String sql) throws SQLException;
//增加
public void Add(Goods goods,String sql)throws SQLException;
//删除
public void Delete(String sql)throws SQLException;
//修改
public void Update(Goods goods,String sql)throws SQLException;
}
/*2.创建一个LoginUse接口:*/
import java.sql.SQLException;
import net.wms.bean.User;
public interface LoginUse {
//查询
public boolean
Query(User user,String sql) throws SQLException;
//增加
public void
Add(User user,String sql)throws SQLException;
//删除
public void Delete(User user,String sql)throws SQLException;
//修改
public void
Update(User user,String sql)throws SQLException;
}
/*3.创建一个Storagemanagement接口:*/
import java.sql.SQLException;
import net.wms.bean.Storage;
public interface Storagemanagement {
//查询
public void Query(String sql) throws SQLException;
//增加
public void Add(Storage storage,String sql)throws SQLException;
//删除
public void Delete(String sql)throws SQLException;
//修改
public void
Update(Storage storage,String sql)throws SQLException;
}
/*4.创建一个GoodsmanagementImp类实现Goodsmanagement接口:*/
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import net.wms.bean.Goods;
import net.wms.util.DB;
public class GoodsmanagementImp implements Goodsmanagement{
public static Vector vec = new Vector();
//获取数据库连接
Connection conn = DB.getConnection();
//查询方法
public void Query(String sql) throws SQLException {
// TODO Auto-generated method stub
//加载SQL语句
PreparedStatement pra = conn.prepareStatement(sql);
//放入结果集
ResultSet rs = pra.executeQuery();
vec.removeAllElements();
while(rs.next()) {
Vector v = new Vector();
v.add(rs.getInt("id"));
v.add(rs.getString("goodsname"));
v.add(rs.getString("goodsstyle"));
v.add(rs.getInt("goodsnumber"));
v.add(rs.getInt("storageID"));
vec.add(v);
}
}
public boolean Query1(Goods goods, String sql) throws SQLException {
// TODO Auto-generated method stub
//加载SQL语句
PreparedStatement pra = conn.prepareStatement(sql);
//放入结果集
ResultSet rs = pra.executeQuery();
//遍历结果集
return false;
}
public void Add(Goods goods, String sql) throws SQLException {
// TODO Auto-generated method stub
PreparedStatement pra = conn.prepareStatement(sql);
pra.setString(1, goods.getGoodsname());
pra.setString(2, goods.getGoodsstyle());
pra.setInt(3, goods.getGoodsnumber());
pra.setString(4, goods.getStorageID());
pra.executeUpdate();
pra.close();
}
public void Delete(String sql) throws SQLException {
// TODO Auto-generated method stub
PreparedStatement pra = conn.prepareStatement(sql);
pra.executeUpdate();
pra.close();
}
public void Update(Goods goods, String sql) throws SQLException {
// TODO Auto-generated method stub
PreparedStatement pra = conn.prepareStatement(sql);
pra.setString(1, goods.getGoodsname());
pra.setString(2, goods.getGoodsstyle());
pra.setInt(3, goods.getGoodsnumber());
pra.setString(4, goods.getStorageID());
pra.executeUpdate();
pra.close();
}
}
/*5.创建一个LoginUseImp实现LoginUse接口*/
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import javax.swing.text.html.HTMLDocument.HTMLReader.ParagraphAction;
import net.wms.bean.User;
import net.wms.util.DB;
public class LoginUseImp implements LoginUse{
public static Vector vec = new Vector();
//获取数据库连接
Connection conn = DB.getConnection();
//查询方法
public boolean Query(User user, String sql) throws SQLException {
// TODO Auto-generated method stub
//加载SQL语句
PreparedStatement pra = conn.prepareStatement(sql);
pra.setString(1, user.getusername());
pra.setString(2, user.getuserpwd());
//放入结果集
ResultSet rs = pra.executeQuery();
//遍历结果集
while(rs.next()){
//获取数据库列字段
String name = rs.getString("username");
String pass = rs.getString("userpwd");
//判断用户名和密码是否符合数据库数据
if(name.equals(user.getusername()) && pass.equals(user.getuserpwd())) {
//符合数据返回 true
return true;
}else{
//不符合数据返回false
return false;
}
}
return false;
}
public boolean Query1(User user, String sql) throws SQLException {
// TODO Auto-generated method stub
//加载SQL语句
PreparedStatement pra = conn.prepareStatement(sql);
//放入结果集
ResultSet rs = pra.executeQuery();
//遍历结果集
while(rs.next()){
//获取数据库列字段
String name = rs.getString("username");
String pass = rs.getString("userpwd");
String flag = rs.getString("flag");
//判断用户名和密码是否符合数据库数据
if(name.equals(user.getusername()) ) {
//符合数据返回 true
user.setusername(name);
user.setuserpwd(pass);
user.setFlag(flag);
return true;
}else{
//不符合数据返回false
return false;
}
}
return false;
}
public void Add(User user, String sql) throws SQLException {
// TODO Auto-generated method stub
PreparedStatement pra = conn.prepareStatement(sql);
pra.setString(1, user.getusername());
pra.setString(2, user.getuserpwd());
pra.setString(3, user.getFlag());
pra.executeUpdate();
pra.close();
}
public void Delete(User user, String sql) throws SQLException {
// TODO Auto-generated method stub
PreparedStatement pra = conn.prepareStatement(sql);
pra.executeUpdate();
pra.close();
}
public void Update(User user, String sql) throws SQLException {
// TODO Auto-generated method stub
PreparedStatement pra = conn.prepareStatement(sql);
pra.executeUpdate();
pra.close();
}
public void Select(String sql) throws SQLException {
PreparedStatement pra = conn.prepareStatement(sql);
ResultSet rs = pra.executeQuery();
vec.removeAllElements();
while(rs.next()) {
Vector v = new Vector();
v.add(rs.getInt("id"));
v.add(rs.getString("username"));
if(rs.getString("flag").equals("1")) {
v.add("普通用户");
}else {
v.add("管理员");
}
vec.add(v);
}
}
}
/*6.创建一个StoragemanagementImp类实现Storagemanagement*/
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import net.wms.bean.Storage;
import net.wms.util.DB;
public class StoragemanagementImp implements Storagemanagement{
public static Vector vec = new Vector();
public static Vector vr = new Vector();
//获取数据库连接
Connection conn = DB.getConnection();
//查询方法
public void Query(String sql) throws SQLException {
// TODO Auto-generated method stub
//加载SQL语句
PreparedStatement pra = conn.prepareStatement(sql);
//放入结果集
ResultSet rs = pra.executeQuery();
vec.removeAllElements();
while(rs.next()) {
Vector v = new Vector();
v.add(rs.getInt("id"));
v.add(rs.getString("storagename"));
v.add(rs.getString("storagestyle"));
v.add(rs.getInt("storageID"));
vec.add(v);
}
}
public void Query1(String sql) throws SQLException {
// TODO Auto-generated method stub
//加载SQL语句
PreparedStatement pra = conn.prepareStatement(sql);
//放入结果集
ResultSet rs = pra.executeQuery();
vr.removeAllElements();
while(rs.next()) {
vr.add(rs.getInt("storageID"));
}
}
public void Add(Storage storage, String sql) throws SQLException {
// TODO Auto-generated method stub
PreparedStatement pra = conn.prepareStatement(sql);
pra.setString(1, storage.getStoragename());
pra.setString(2, storage.getStoragestyle());
pra.setInt(3, storage.getStorageID());
pra.executeUpdate();
pra.close();
}
public void Delete(String sql) throws SQLException {
// TODO Auto-generated method stub
PreparedStatement pra = conn.prepareStatement(sql);
pra.executeUpdate();
pra.close();
}
public void Update(Storage storage, String sql) throws SQLException {
// TODO Auto-generated method stub
PreparedStatement pra = conn.prepareStatement(sql);
pra.setString(1, storage.getStoragename());
pra.setString(2, storage.getStoragestyle());
pra.setInt(3, storage.getStorageID());
pra.executeUpdate();
pra.close();
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。