?? goodscanceldao.java
字號:
package com.dao;
import java.util.*;
import java.sql.*;
import com.tool.JDBConnection;
import com.domain.GoodsCancelVO;
//退貨信息
public class GoodsCancelDao {
private JDBConnection connection = null;
public GoodsCancelDao() {
connection = new JDBConnection();
this.connection.creatConnection(); //利用構(gòu)造方法調(diào)用類中的對象對數(shù)據(jù)庫創(chuàng)建連接
}
//添加退貨信息
public void cancelInsert(GoodsCancelVO vo) {
String sql = "insert into tb_goodsCancel values ('" + vo.getCancel_number() +
"','" + vo.getAccounts() + "','" + vo.getGoods_number() +
"','" + vo.getOrder_number() + "','" + vo.getReason() + "','" +
vo.getBack() + "','" + vo.getMoney() + "','" + vo.getEmployeeNumber() +
"','" + vo.getNumber() + "',getDate(),'" + vo.getClient() + "')";
connection.executeUpdate(sql);
connection.closeConnection();
}
public GoodsCancelVO cancelSelectOne(String number) {
GoodsCancelVO vo = null;
String sql = "select * from tb_goodsCancel where cancel_number='" + number +
"'";
ResultSet rs = connection.executeQuery(sql);
try {
while (rs.next()) {
vo = new GoodsCancelVO();
vo.setId(Integer.valueOf(rs.getString(1)));
vo.setCancel_number(rs.getString(2));
vo.setAccounts(rs.getString(3));
vo.setGoods_number(rs.getString(4));
vo.setOrder_number(rs.getString(5));
vo.setReason(rs.getString(6));
vo.setBack(Integer.parseInt(rs.getString(7)));
vo.setMoney(Float.parseFloat(rs.getString(8)));
vo.setEmployeeNumber(rs.getString(9));
vo.setNumber(rs.getString(10));
vo.setCancelTime(rs.getString(11));
vo.setClient(rs.getString(12));
}
}
catch (SQLException ex) {
}
connection.closeConnection();
return vo;
}
public void cancelUpdateNumber(Integer id, String number) {
String unNumber = "cancel-" + String.valueOf(id);
String sql = "update tb_goodsCancel set cancel_number='" + unNumber +
"' where cancel_number='" + number + "'";
connection.executeUpdate(sql);
connection.closeConnection();
}
public List goodsCancelSelectTime(String start, String over ) {
List list = new ArrayList();
GoodsCancelVO vo = null;
String startime = start + " " + "00:00:00";
String overtime = over + " " + "00:00:00";
String sql = "select * from tb_goodsCancel where cancelTime between '"+startime+"' and '"+overtime+"' ";
ResultSet rs = connection.executeQuery(sql);
try {
while (rs.next()) {
vo = new GoodsCancelVO();
vo.setId(Integer.valueOf(rs.getString(1)));
vo.setCancel_number(rs.getString(2));
vo.setAccounts(rs.getString(3));
vo.setGoods_number(rs.getString(4));
vo.setOrder_number(rs.getString(5));
vo.setReason(rs.getString(6));
vo.setBack(Integer.parseInt(rs.getString(7)));
vo.setMoney(Float.parseFloat(rs.getString(8)));
vo.setEmployeeNumber(rs.getString(9));
vo.setNumber(rs.getString(10));
vo.setCancelTime(rs.getString(11));
vo.setClient(rs.getString(12));
list.add(vo);
}
}
catch (SQLException ex) {
}
connection.closeConnection();
return list;
}
public List cancelSelect(String back) {
String sql = "";
List list = new ArrayList();
GoodsCancelVO vo = null;
if (back.equals("")) {
sql = "select * from tb_goodsCancel";
}
else {
sql = "select * from tb_goodsCancel where back='" + back + "'";
}
ResultSet rs = connection.executeQuery(sql);
System.out.println("sql=" + sql);
try {
while (rs.next()) {
vo = new GoodsCancelVO();
vo.setId(Integer.valueOf(rs.getString(1)));
vo.setCancel_number(rs.getString(2));
vo.setAccounts(rs.getString(3));
vo.setGoods_number(rs.getString(4));
vo.setOrder_number(rs.getString(5));
vo.setReason(rs.getString(6));
vo.setBack(Integer.parseInt(rs.getString(7)));
vo.setMoney(Float.parseFloat(rs.getString(8)));
vo.setEmployeeNumber(rs.getString(9));
vo.setNumber(rs.getString(10));
vo.setCancelTime(rs.getString(11));
vo.setClient(rs.getString(12));
list.add(vo);
}
}
catch (SQLException ex) {
}
connection.closeConnection();
return list;
}
//把貨品返回供應(yīng)商
public void backCompany(int accounts, int id) {
String sql = "update tb_goodsCancel set back='" + accounts + "' where id='" +
id + "'";
connection.executeUpdate(sql);
connection.closeConnection();
}
//刪除退貨信息
public void deleteCancel(Integer id) {
String sql = "delete from tb_goodsCancel where id='" + id + "'";
connection.executeUpdate(sql);
connection.closeConnection();
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -