摘要: + ',' + sellMain.getPzs() + ', + sellMain.getJe() + ,' + sellMain.getYsjl() + ',' + sellMain.getKhname() + ',' + sellMain.getXsdate() + ',' + sellMain.getCzy() + ',' + sellMain.getJsr() + ',' + sellMa
+ "','" + sellMain.getPzs() + "'," + sellMain.getJe()
+ ",'" + sellMain.getYsjl() + "','" + sellMain.getKhname()
+ "','" + sellMain.getXsdate() + "','" + sellMain.getCzy()
+ "','" + sellMain.getJsr() + "','" + sellMain.getJsfs()
+ "')");
Set<TbSellDetail> rkDetails = sellMain.getTbSellDetails();
for (Iterator<TbSellDetail> iter = rkDetails.iterator(); iter
.hasNext();) {
TbSellDetail details = iter.next();
// 添加销售详细表记录
insert("insert into tb_sell_detail values('"
+ sellMain.getSellId() + "','" + details.getSpid()
+ "'," + details.getDj() + "," + details.getSl() + ")");
// 修改库存表记录
Item item = new Item();
item.setId(details.getSpid());
TbSpinfo spInfo = getSpInfo(item);
if (spInfo.getId() != null && !spInfo.getId().isEmpty()) {
TbKucun kucun = getKucun(item);
if (kucun.getId() != null && !kucun.getId().isEmpty()) {
int sl = kucun.getKcsl() - details.getSl();
update("update tb_kucun set kcsl=" + sl + " where id='"
+ kucun.getId() + "'");
}
}
}
conn.commit();
conn.setAutoCommit(autoCommit);
} catch (SQLException e) {
e.printStackTrace();
}
return true;
}
// 获取更类主表最大ID
private static String getMainTypeTableMaxId(Date date, String table,
String idChar, String idName) {
String dateStr = date.toString().replace("-", "");
String id = idChar + dateStr;
String sql = "select max(" + idName + ") from " + table + " where "
+ idName + " like '" + id + "%'";
ResultSet set = query(sql);
String baseId = null;
try {
if (set.next())
baseId = set.getString(1);
} catch (SQLException e) {
e.printStackTrace();
}
baseId = baseId == null ? "000" : baseId.substring(baseId.length() - 3);
int idNum = Integer.parseInt(baseId) + 1;
id += String.format("%03d", idNum);
return id;
}
public static String getXsthMainMaxId(Date date) {
return getMainTypeTableMaxId(date, "tb_xsth_main", "XT", "xsthID");
}
public static List getKucunInfos() {
List list = findForList("select id,spname,dj,kcsl from tb_kucun");
return list;
}
// 在事务中添加销售退货信息
public static boolean insertXsthInfo(TbXsthMain xsthMain) {
try {
boolean autoCommit = conn.getAutoCommit();
conn.setAutoCommit(false);
// 添加销售退货主表记录
insert("insert into tb_xsth_main values('" + xsthMain.getXsthId()
+ "','" + xsthMain.getPzs() + "'," + xsthMain.getJe()
+ ",'" + xsthMain.getYsjl() + "','" + xsthMain.getKhname()
+ "','" + xsthMain.getThdate() + "','" + xsthMain.getCzy()
+ "','" + xsthMain.getJsr() + "','" + xsthMain.getJsfs()
+ "')");
Set<TbXsthDetail> xsthDetails = xsthMain.getTbXsthDetails();
for (Iterator<TbXsthDetail> iter = xsthDetails.iterator(); iter
.hasNext();) {
TbXsthDetail details = iter.next();
// 添加销售退货详细表记录
insert("insert into tb_xsth_detail values('"
+ xsthMain.getXsthId() + "','" + details.getSpid()
+ "'," + details.getDj() + "," + details.getSl() + ")");
// 修改库存表记录
Item item = new Item();
item.setId(details.getSpid());
TbSpinfo spInfo = getSpInfo(item);
if (spInfo.getId() != null && !spInfo.getId().isEmpty()) {

RSS订阅





