package dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import bean.Clothes;
import bean.Consumption;
import util.DBUtil;
public class ClothesDao {
Statement pstmt=null;
Connection conn=null;
ResultSet rSet=null;
Clothes c;
public List<Consumption> selectUserConsumption() {
conn=DBUtil.getConnection();
String sql="select * from consumption";
List<Consumption> consumptions=new ArrayList<Consumption>();
try {
PreparedStatement ps=conn.prepareStatement(sql);
rSet=ps.executeQuery();
while(rSet.next()){
Consumption d=new Consumption();
d.setUser_id(rSet.getInt("user_id"));
d.setUser_name(rSet.getNString("user_name"));
d.setUser_nickname(rSet.getString("user_nickname"));
d.setUser_tel(rSet.getString("user_tel"));
d.setConsumption_Time(rSet.getDate("consumption_Time"));
d.setClothes_name(rSet.getString("clothes_name"));
d.setNumber(rSet.getString("number"));
d.setTotal(rSet.getString("total"));
consumptions.add(d);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
DBUtil.close(rSet, pstmt, conn);
}
return consumptions;
}
public List<Consumption> selectConAllUser_nameLike(Consumption con) {
conn=DBUtil.getConnection();
String sql="select * from consumption where user_name like ?";
List<Consumption> consumptions=new ArrayList<Consumption>();
try {
PreparedStatement ps=conn.prepareStatement(sql);
ps.setString(1, "%".concat(con.getUser_name()).concat("%"));
rSet=ps.executeQuery();
while(rSet.next()){
Consumption d=new Consumption();
d.setUser_id(rSet.getInt("user_id"));
d.setUser_name(rSet.getNString("user_name"));
d.setUser_nickname(rSet.getString("user_nickname"));
d.setUser_tel(rSet.getString("user_tel"));
d.setConsumption_Time(rSet.getDate("consumption_Time"));
d.setClothes_name(rSet.getString("clothes_name"));
d.setNumber(rSet.getString("number"));
d.setTotal(rSet.getString("total"));
consumptions.add(d);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
DBUtil.close(rSet, pstmt, conn);
}
System.out.println("dao层con:"+con.getUser_name());
System.out.println("consumptions"+consumptions);
return consumptions;
}
public List<Consumption> selectConAllClothes_nameLike(Consumption con) {
conn=DBUtil.getConnection();
String sql="select * from consumption where clothes_name like ?";
List<Consumption> consumptions=new ArrayList<Consumption>();
try {
PreparedStatement ps=conn.prepareStatement(sql);
ps.setString(1, "%".concat(con.getClothes_name()).concat("%"));
rSet=ps.executeQuery();
while(rSet.next()){
Consumption d=new Consumption();
d.setUser_id(rSet.getInt("user_id"));
d.setUser_name(rSet.getNString("user_name"));
d.setUser_nickname(rSet.getString("user_nickname"));
d.setUser_tel(rSet.getString("user_tel"));
d.setConsumption_Time(rSet.getDate("consumption_Time"));
d.setClothes_name(rSet.getString("clothes_name"));
d.setNumber(rSet.getString("number"));
d.setTotal(rSet.getString("total"));
consumptions.add(d);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
DBUtil.close(rSet, pstmt, conn);
}
return consumptions;
}
public List<Clothes> selectAllClothes() {
List<Clothes> list=new ArrayList<Clothes>();
conn=DBUtil.getConnection();
String sql="select * from clothes";
try {
PreparedStatement ps=conn.prepareStatement(sql);
rSet=ps.executeQuery();
while(rSet.next()){
Clothes clothes=new Clothes();
clothes.setClothes_id(rSet.getString("clothes_id"));
clothes.setClothes_name(rSet.getNString("clothes_name"));
clothes.setType(rSet.getString("type"));
clothes.setManufacturer_name(rSet.getString("manufacturer_name"));
clothes.setPurchasePrice(rSet.getString("purchasePrice"));
clothes.setPrice(rSet.getString("price"));
clothes.setPicture(rSet.getString("picture"));
clothes.setCode(rSet.getString("code"));
clothes.setInventory(rSet.getString("inventory"));
list.add(clothes);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
public int deleteClothes(Clothes clothes) {
int n=0;
conn=DBUtil.getConnection();
String sql="delete from clothes where clothes_id=?";
try {
PreparedStatement ps=conn.prepareStatement(sql);
ps.setString(1, clothes.getClothes_id());
n=ps.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return n;
}
public int insertClothes(Clothes clothes) {
int n=0;
conn=DBUtil.getConnection();
String sql="insert into clothes value(?,?,?,?,?,?,?,?,?)";
try {
PreparedStatement ps=conn.prepareStatement(sql);
ps.setString(1, clothes.getClothes_id());
ps.setString(2, clothes.getClothes_name());
ps.setString(3, clothes.getType());
ps.setString(4, clothes.getManufacturer_name());
ps.setString(5, clothes.getPurchasePrice());
ps.setString(6, clothes.getPrice());
ps.setString(7, clothes.getPicture());
ps.setString(8, clothes.getCode());
ps.setString(9, clothes.getInventory());
n=ps.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return n;
}
public int deleteClothesAll(String string) {
int n=0;
conn=DBUtil.getConnection();
String sql="DELETE FROM clothes WHERE clothes_id=?";
try {
PreparedStatement ps=conn.prepareStatement(sql);
ps.setString(1, string);
n=ps.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return n;
}
public Clothes selectClothesByClothes_id(String clothes_id) {
conn=DBUtil.getConnection();
String sql="select * from clothes where clothes_id=?";
try {
PreparedStatement ps=conn.prepareStatement(sql);
ps.setString(1, clothes_id);
rSet=ps.executeQuery();
if (rSet.next()) {
c=new Clothes();
c.setClothes_id(rSet.getString("clothes_id"));
c.setClothes_name(rSet.getString("clothes_name"));
c.setType(rSet.getString("type"));
c.setManufacturer_name(rSet.getString("manufacturer_name"));
c.setPurchasePrice(rSet.getString("purchasePrice"));
c.setPrice(rSet.getString("price"));
c.setPicture(rSet.getString("picture"));
c.setInventory(rSet.getString("inventory"));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return c;
}
public Clothes SelectClothesById(Clothes clothes) {
conn=DBUtil.getConnection();
String sql="select * from clothes where clothes_id=?";
try {
PreparedStatement ps=conn.prepareStatement(sql);
ps.setString(1, clothes.getClothes_id());
rSet=ps.executeQuery();
if (rSet.next()) {
c=new Clothes();
c.setClothes_id(rSet.getString("clothes_id"));
c.setClothes_name(rSet.getString("clothes_name"));
c.setType(rSet.getString("type"));
c.setManufacturer_name(rSet.getString("manufacturer_name"));
c.setPurchasePrice(rSet.getString("purchasePrice"));
c.setPrice(rSet.getString("price"));
c.setPicture(rSet.getString("picture"));
c.setInventory(rSet.getString("inventory"));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return c;
}
public int updateClothes(Clothes clothes) {
int n=0;
conn=DBUtil.getConnection();
String sql="update clothes set
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
jsp服装售卖管理系统源码(含数据库脚本).zip (471个子文件)
ClothesDao.class 8KB
UserDao.class 6KB
ExportServlet.class 5KB
UpdateClothesServlet.class 4KB
QrCodeUtil.class 3KB
LoginFilter.class 3KB
InsertClothesServlet.class 3KB
ClothesService.class 3KB
SelectUserLikeServlet.class 3KB
UploadFileUtil.class 3KB
Clothes.class 3KB
Consumption.class 3KB
SelectConsLikeServlet.class 3KB
DownloadServlet.class 3KB
RegisterServlet.class 3KB
LoginServlet.class 2KB
User.class 2KB
UpdatePasswordServlet.class 2KB
DeleteClothesAllServlet.class 2KB
UserService.class 2KB
SelectClothesByIdServlet.class 2KB
DisplayImageServlet.class 2KB
DBUtil.class 2KB
DeleteClothesServlet.class 2KB
SelectAllUserDevServlet01.class 2KB
SelectAllDevServlet.class 2KB
AdminUser.class 2KB
SelectAllClothesServlet01.class 2KB
SelectAllDevsServlet.class 2KB
SelectClothesDetailServlet.class 2KB
SelectAllUserServlet.class 2KB
IndexServlet.class 1KB
LogoutServlet.class 1KB
test1.class 742B
.classpath 606B
org.eclipse.wst.common.component 473B
org.eclipse.wst.jsdt.ui.superType.container 49B
summernote-bs3.css 143KB
style.css 133KB
bootstrap.min.css 118KB
animate.css 64KB
datepicker3.css 33KB
font-awesome.css 32KB
bootstrap-rtl.css 31KB
font-awesome.min.css 26KB
ambiance.css 25KB
style.min.css 25KB
sweetalert.css 18KB
simditor.css 17KB
ui.jqgrid.css 16KB
styleUpdate.css 15KB
jasny-bootstrap.min.css 14KB
jquery-ui-1.10.4.custom.min.css 14KB
common.css 13KB
chosen.css 12KB
dropzone.css 11KB
layer.css 11KB
layim.css 11KB
fullcalendar.css 11KB
summernote.css 10KB
plyr.css 10KB
webuploader-demo.css 7KB
codemirror.css 7KB
blueimp-gallery.min.css 7KB
awesome-bootstrap-checkbox.css 7KB
toastr.min.css 7KB
laydate.css 6KB
blueimp-gallery.css 6KB
jquery.steps.css 6KB
footable.core.css 5KB
jquery.fancybox.css 5KB
dataTables.bootstrap.css 5KB
admin_login.css 4KB
bootstrap-table.min.css 4KB
clockpicker.css 4KB
basic.css 4KB
style.css 4KB
bootstrap-colorpicker.min.css 3KB
laydate.css 3KB
main.css 3KB
cropper.min.css 3KB
ion.rangeSlider.css 3KB
jquery.nouislider.css 3KB
layer.ext.css 3KB
bootstrap-markdown.min.css 3KB
jquery.gritter.css 3KB
blueimp-gallery-video.css 2KB
login.css 2KB
ion.rangeSlider.skinFlat.css 2KB
bootstrap-duallistbox.css 2KB
blueimp-gallery-indicator.css 2KB
style01.css 1KB
custom.css 1KB
bootstrap-multiselect.css 1KB
bootstrap-treeview.css 1KB
demo.css 867B
fullcalendar.print.css 660B
switchery.css 611B
webuploader.css 515B
webuploader.css 515B
共 471 条
- 1
- 2
- 3
- 4
- 5
资源评论
- 小憨批宗太2022-07-01资源很赞,希望多一些这类资源。
等天晴i
- 粉丝: 5228
- 资源: 10万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功