package com.weizhi.daoimp;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Set;
import java.util.Vector;
import javax.swing.JButton;
import com.weizhi.dao.UserDao;
import supermarketwee.User;
import supermarketwee.UserDan;
import com.weizhi.util.JdbcUtil;
import iol.UserGong;
public class UserDaoImpl implements UserDao {
public boolean insert(User user) {
Statement st=null;
Connection con=JdbcUtil.getCon();
int i=0;
String userName=user.getUserName();
String passWrd=user.getPassWrd();
String uid=user.getId();
String role=user.getRole();
String sql="insert into user values('"+userName+"','"+passWrd+"','"+uid+"','"+role+"')";
try {
st=con.createStatement();
i=st.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(i==1){
return true;
}
return false;
}
@Override
public boolean insert(UserDan user) {
String userName=user.getUserName();
String uid=user.getId();
Statement st=null;
Connection con=JdbcUtil.getCon();
int i=0;
String sql="insert into dw values('"+userName+"','"+uid+"')";
try {
st=con.createStatement();
i=st.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(i==1){
return true;
}
return false;
}
@Override
public boolean insert(UserGong user) {
String name=user.getName();
String dizhi=user.getDizhi();
String phone=user.getPhone();
String ren=user.getRen();
Statement st=null;
Connection con=JdbcUtil.getCon();
int i=0;
String sql="insert into gong values('"+name+"','"+dizhi+"','"+phone+"','"+ren+"')";
try {
st=con.createStatement();
i=st.executeUpdate(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(i==1){
return true;
}
return false;
}
@Override
public boolean delete2(String name) {
String sql="delete from gong where name='"+name+"'";
Connection con=JdbcUtil.getCon();
Statement st=null;
int x=0;
try {
st=con.createStatement();
x=st.executeUpdate(sql);
}catch(SQLException e){
e.printStackTrace();
}finally {
JdbcUtil.close(con,st,null);
}
if(x==1) {
return true;
}
return false;
}
@Override
public boolean delete(String uid) {
String sql="delete from user where uid='"+uid+"'";
Connection con=JdbcUtil.getCon();
Statement st=null;
int x=0;
try {
st=con.createStatement();
x=st.executeUpdate(sql);
}catch(SQLException e){
e.printStackTrace();
}finally {
JdbcUtil.close(con,st,null);
}
if(x==1) {
return true;
}
return false;
}
@Override
public boolean delete1(String userName) {
String sql="delete from dw where userName='"+userName+"'";
Connection con=JdbcUtil.getCon();
Statement st=null;
int x=0;
try {
st=con.createStatement();
x=st.executeUpdate(sql);
}catch(SQLException e){
e.printStackTrace();
}finally {
JdbcUtil.close(con,st,null);
}
if(x==1) {
return true;
}
return false;
}
@Override
public boolean update(User user) {
String userName=user.getUserName();
String passWrd=user.getPassWrd();
String uid=user.getId();
String role=user.getRole();
String sql="update user set passWrd='"+passWrd+"' ,role='"+role+"', uid='"+uid+"' where userName='"+userName+"'";
Connection con=JdbcUtil.getCon();
Statement st=null;
int x=0;
try {
st=con.createStatement();
x=st.executeUpdate(sql);
}catch(SQLException e){
e.printStackTrace();
}finally {
JdbcUtil.close(con,st,null);
}
if(x==1) {
return true;
}
return false;
}
@Override
public boolean update(UserDan user) {
String userName=user.getUserName();
String uid=user.getId();
String sql="update dw set userName='"+userName+"' where uid='"+uid+"'";
Connection con=JdbcUtil.getCon();
Statement st=null;
int x=0;
try {
st=con.createStatement();
x=st.executeUpdate(sql);
}catch(SQLException e){
e.printStackTrace();
}finally {
JdbcUtil.close(con,st,null);
}
if(x==1) {
return true;
}
return false;
}
@Override
public boolean update(UserGong user) {
String name=user.getName();
String dizhi=user.getDizhi();
String phone=user.getPhone();
String ren=user.getRen();
String sql="update gong set dizhi='"+dizhi+"',phone='"+phone+"',ren='"+ren+"' where name='"+name+"'";
Connection con=JdbcUtil.getCon();
Statement st=null;
int x=0;
try {
st=con.createStatement();
x=st.executeUpdate(sql);
}catch(SQLException e){
e.printStackTrace();
}finally {
JdbcUtil.close(con,st,null);
}
if(x==1) {
return true;
}
return false;
}
@Override
public User query(String userName) {
String userName1 = null;
String passWrd=null;
String role=null;
Statement st=null;
String uid=null;
Connection con=JdbcUtil.getCon();
int i=0;
String sql="select * from user where userName='"+userName+"'";
ResultSet rs=null;
try {
st=con.createStatement();
rs=st.executeQuery(sql);
while(rs.next()){
userName=rs.getString(1);
passWrd=rs.getString(2);
uid=rs.getString(3);
role=rs.getString(4);
}
//System.out.println(userName);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
JdbcUtil.close(con,st,rs);
}
User user=new User(userName,passWrd,uid,role);
//System.out.println(user.getPassWrd());
return user;
}
public Vector<Vector<String>> queryAll(String s){
String userName = null;
String passWrd=null;
String uid=null;
String role=null;
Statement st=null;
Vector<Vector<String>> vv=new Vector<Vector<String>>();
Connection con=JdbcUtil.getCon();
String sql="select * from user where userName='"+s+"'or uid='"+s+"' ";
ResultSet rs=null;
try {
st=con.createStatement();
rs=st.executeQuery(sql);
while(rs.next()){
Vector<String> v=new Vector<String>();
v.add(rs.getString("userName"));
v.add(rs.getString("passWrd"));
v.add(rs.getString("uid"));
v.add(rs.getString("role"));
vv.add(v);
}
//System.out.println(userName);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
JdbcUtil.close(con,st,rs);
}
return vv;
}
public Vector<Vector<String>> queryAlld(String s){
String userName = null;
String uid=null;
Statement st=null;
Vector<Vector<String>> vv=new Vector<Vector<String>>();
Connection con=JdbcUtil.getCon();
String sql="select * from dw where userName='"+s+"'or uid='"+s+"' ";
ResultSet rs=null;
try {
st=con.createStatement();
rs=st.executeQuery(sql);
while(rs.next()){
Vector<String> v=new Vector<String>();
v.add(rs.getString("userName"));
v.add(rs.getString("uid"));
vv.add(v);
}
//System.out.println(userName);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
JdbcUtil.close(con,st,rs);
}
return vv;
}
public Vector<Vector<String>> queryAlla(String s){
Statement st=null;
Vector<Vector<String>> vv=new Vector<Vector<String>>();
Connection con=JdbcUtil.getCon();
String sql="select * from gong where phone='"+s+"'or name='"+s+"' ";
ResultSet rs=null;
try {
st=con.createStatement();
rs=st.executeQuery(sql);
while(rs.next()){
Vector<String> v=new Vector<String>();
v.add(rs.getString("name"));
没有合适的资源?快使用搜索试试~ 我知道了~
基于java开发的超市收银系统
共79个文件
class:32个
png:16个
jpg:15个
需积分: 2 1 下载量 18 浏览量
2023-06-26
21:44:44
上传
评论
收藏 3.62MB ZIP 举报
温馨提示
超市收银系统
资源推荐
资源详情
资源评论
收起资源包目录
supermarketwee.zip (79个子文件)
supermarketwee
截图
20190619203029.png 218KB
20190619202957.png 224KB
20190620073042.png 227KB
20190619203040.png 224KB
20190620073059.png 227KB
20190619203048.png 219KB
20190620072851.png 231KB
20190620072808.png 231KB
20190619202148.png 488KB
20190619202950.png 224KB
20190620073016.png 217KB
20190619202138.png 102KB
20190620072844.png 220KB
20190619203016.png 224KB
20190620072859.png 219KB
.classpath 530B
.settings
org.eclipse.jdt.core.prefs 598B
src
supermarketwee
UserDan.java 745B
UserJbt.java 7KB
UserG.java 5KB
chaoshiguanlixitong.java 6KB
UserD.java 4KB
UserIu.java 5KB
UserZ.java 59B
User.java 1KB
iol
UserGong.java 1KB
LoginFrame.java 5KB
com
weizhi
dao
UserDao.java 748B
daoimp
UserDaoImpl.java 8KB
util
JdbcUtil.java 1KB
bin
supermarketwee
UserG$4.class 2KB
User.class 2KB
UserJbt$3.class 2KB
chaoshiguanlixitong$1.class 941B
UserIu$4.class 2KB
UserG$2.class 2KB
chaoshiguanlixitong.class 5KB
UserJbt$1.class 2KB
UserZ.class 270B
UserDan.class 1KB
UserJbt$5.class 2KB
UserJbt$4.class 2KB
UserG$1.class 2KB
UserG$3.class 2KB
chaoshiguanlixitong$5.class 1KB
UserJbt.class 4KB
UserG.class 3KB
UserIu$2.class 2KB
UserJbt$2.class 2KB
chaoshiguanlixitong$3.class 942B
UserD.class 5KB
UserIu$3.class 2KB
chaoshiguanlixitong$Mk.class 1KB
chaoshiguanlixitong$2.class 941B
UserIu.class 3KB
chaoshiguanlixitong$4.class 942B
UserIu$1.class 2KB
iol
LoginFrame.class 5KB
UserGong.class 2KB
com
weizhi
dao
UserDao.class 607B
daoimp
UserDaoImpl.class 8KB
util
JdbcUtil.class 2KB
.project 390B
images
xitongguanli.jpg 3KB
top.jpg 22KB
jinhuo.jpg 2KB
guanyu.jpg 43KB
mainlogo (5).jpg 12KB
mainlogo.jpg 23KB
leib.jpg 12KB
mainlogo (8).jpg 3KB
mainlogo (6).jpg 3KB
mainlogo (9).jpg 3KB
QQ.png 81KB
mainlogo (3).jpg 3KB
mainlogo (7).jpg 3KB
mainlogo (2).jpg 3KB
mainlogo (1).jpg 2KB
mainlogo (4).jpg 12KB
共 79 条
- 1
资源评论
下﹁秒待續
- 粉丝: 4
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功