package control.clothesinandout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.MouseAdapter;import java.awt.event.MouseEvent;import java.util.Iterator;import java.util.Vector;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JTable;import javax.swing.JTree;import javax.swing.table.DefaultTableModel;import javax.swing.tree.DefaultMutableTreeNode;import view.dialog.countmanage.ClothesInAndOutCountDialog;import vo.ClothesTypeVo;import vo.OrderItemVo;import vo.OrderVo;import vo.RefundmentVo;import vo.RewashVo;import vo.VipConsumeVo;import vo.VipVo;import common.LogWriter;import control.common.CheckTimeUtil;import dao.commomdao.CommonDao;import dao.commomdao.impl.CommonDaoImpl;import dao.common.DbException;import dao.export.ExportDao;import dao.export.head.TableHead;import dao.inandoutdao.ClothesInAndOutDao;import dao.inandoutdao.impl.ClothesInAndOutDaoImpl;public class ClothesInAndOutAction implements ActionListener {private ClothesInAndOutCountDialog dialog;private LogWriter log;private ExportDao edao;public ClothesInAndOutAction(ClothesInAndOutCountDialog dialog,LogWriter log) {this.dialog = dialog;this.log = log;}public void actionPerformed(ActionEvent e) {String name = e.getActionCommand();if (name.equals("统计")) {String fromDate = dialog.buildFromDateBox().getSelectedItem().toString();String toDate = dialog.buildToDateBox().getSelectedItem().toString();if (CheckTimeUtil.CheckTime(fromDate, toDate)) {buildTableData(fromDate, toDate);} else {JOptionPane.showMessageDialog(null, "查找的开始日期不能大于结束日期!");}} else if (name.equals("打印")) {JTree tree = dialog.buildClothesTree();// 获得选中的节点DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();// 获得选中的节点的字符串内容if (tree.isSelectionEmpty()) {JOptionPane.showMessageDialog(null, "请选择您要统计的方式");} else {String nodeStr = node.getUserObject().toString();if (node.isLeaf()) {if (nodeStr.equals("索赔衣物记录")) {JTable table = dialog.buildDamagedCollectionTable();String headTitle = "索赔衣物记录";String[] head = TableHead.CLOTHES_REFUNDMENT;edao = new ExportDao(dialog);edao.export(table, headTitle, head);} else if (nodeStr.equals("返回重洗记录")) {JTable table = dialog.buildReturnedCollectionTable();String headTitle = "返回重洗记录";String[] head = TableHead.CLOTHES_REWASH;edao = new ExportDao(dialog);edao.export(table, headTitle, head);} else if (nodeStr.equals("过期未取走衣物")) {JTable table = dialog.buildOverTimeCollectionTable();String headTitle = "过期未取走衣物";String[] head = TableHead.CLOTHES_OUTOFDATE;edao = new ExportDao(dialog);edao.export(table, headTitle, head);} else if(nodeStr.equals("收衣数量金额统计")){JTable table = dialog.buildTable();String headTitle = "收衣数量金额统计";String[] head = TableHead.NUMBERCOUNT;edao = new ExportDao(dialog);edao.export(table, headTitle, head);}else {JOptionPane.showMessageDialog(null, "此处不支持报表打印,在收衣记录中已经打印!", "提示",JOptionPane.YES_OPTION);}}}} else if (name.equals("退出")) {dialog.dispose();}}public void buildTableData(String fromDate, String toDate) {ClothesInAndOutDao dao = new ClothesInAndOutDaoImpl(log);CommonDao cdao = new CommonDaoImpl(log);JTree tree = dialog.buildClothesTree();// 获得选中的节点DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();// 获得选中的节点的字符串内容if (tree.isSelectionEmpty()) {JOptionPane.showMessageDialog(null, "请选择您要统计的方式");} else {String nodeStr = node.getUserObject().toString();if (node.isLeaf()) {if (nodeStr.equals("收衣取衣记录")) {JTable collectionTable = dialog.buildCollectionTable();try {OrderVo value = null;Iterator iter = null;Vector v = null;v = dao.findClothesInGether(fromDate, toDate);iter = v.iterator();DefaultTableModel model = (DefaultTableModel) collectionTable.getModel();int rows = collectionTable.getRowCount();for (int i = rows - 1; i >= 0; i--) {model.removeRow(i);}while (iter.hasNext()) {value = (OrderVo) iter.next();String vipName = "无卡用户";String vipPhone = "无";int vipId = value.getCustomerId();if (vipId != 0) {VipVo vipVo = cdao.getVipInfoByVipId(vipId);vipName = vipVo.getVipName();vipPhone = vipVo.getVipPhone();}Object[] data = { value.getOrderId(),value.getGetClothesDate(),value.getTakeClothesDate(),value.getOrderValue(),value.getOrderValue(),value.getCustomerId(), vipName, vipPhone,value.isTakeOrNot()?"是":"否", value.getOperatorName() };model.addRow(data);}collectionTable.addMouseListener(new MouseAdapter() {public void mouseClicked(MouseEvent e) {JTable table = dialog.buildCollectionTable();int row = table.getSelectedRow();long orderId = Long.parseLong(table.getValueAt(row, 0).toString());int vipId = Integer.parseInt(table.getValueAt(row, 5).toString());double neededAmount = Double.parseDouble(table.getValueAt(row, 3).toString());double receivedAmount = Double.parseDouble(table.getValueAt(row, 4).toString());buildItemTableData(orderId, vipId);buildLabelPanel(orderId, neededAmount,receivedAmount, vipId);}});} catch (DbException e) {JOptionPane.showMessageDialog(null, "统计衣物收取记录失败!" + e.getMessage());}} else if (nodeStr.equals("收衣数量金额统计")) {int[] clothesIds;JTable table = dialog.buildTable();try {clothesIds = dao.findClothesIds(fromDate, toDate);DefaultTableModel model = (DefaultTableModel) table.getModel();int rows = table.getRowCount();for (int i = rows - 1; i >= 0; i--) {model.removeRow(i);}for (int i = 0; i < clothesIds.length; i++) {ClothesTypeVo type = cdao.getClothesTypeByClothesID(clothesIds[i]);int count = dao.findClothesCountById(clothesIds[i]);double income = dao.getClothesIncomeByClothesId(clothesIds[i]);Object[] data = { type.getClothesName(), count,type.getServiceType(), income };model.addRow(data);}} catch (DbException e) {JOptionPane.showMessageDialog(null, "收衣数量金额统计失败" + e.getMessage());e.printStackTrace();}} else if (nodeStr.equals("索赔衣物记录")) {JTable table = dialog.buildDamagedCollectionTable();try {RefundmentVo value = null;Iterator iter = null;Vector v = null;v = dao.findRefundment(fromDate, toDate);iter = v.iterator();DefaultTableModel model = (DefaultTableModel) table.getModel();int rows = table.getRowCount();for (int i = rows - 1; i >= 0; i--) {model.removeRow(i);}while (iter.hasNext()) {value = (RefundmentVo) iter.next();Object[] data = { value.getRefundDate(),value.getOrderId(),value.getRefundAmount(),value.getRefundReason(),value.getOperatorName() };model.addRow(data);}table.addMouseListener(new MouseAdapter() {public void mouseClicked(MouseEvent e) {JTable table = dialog.buildDamagedCollectionTable();int row = table.getSelectedRow();long orderId = Long.parseLong(table.getValueAt(row, 1).toString());buildDamagedItemTableData(orderId);buildLabelPanel(orderId);}});} catch (DbException e) {JOptionPane.showMessageDialog(null, "统计索赔衣物记录失败!" + e.getMessage());}} else if (nodeStr.equals("返回重洗记录")) {JTable table = dialog.buildReturnedCollectionTable();try {RewashVo value = null;Iterator iter = null;Vector v = null;v = dao.findReWashed(fromDate, toDate);iter = v.iterator();DefaultTableModel model = (DefaultTableModel) table.getModel();int rows = table.getRowCount();for (int i = rows - 1; i >= 0; i--) {model.removeRow(i);}while (iter.hasNext()) {value = (RewashVo) iter.next();OrderVo orderVo = cdao.getOrderInfoByOrderId(value.getOrderId());VipConsumeVo vo = null;if (orderVo.getCustomerId() != 0) {vo = cdao.getVipConsumeInfoByOrderId(value.getOrderId());}int vipId = 0;String vipName = "无卡用户";String vipPhone = "无";if (vo != null) {vipId = vo.getVipId();VipVo vipVo = cdao.getVipInfoByVipId(vo
inandout java,clothesinandoutaction.java 源代码在线查看 - 一个优秀的干洗店管理系统 资源下载 虫虫电子下载站...
最新推荐文章于 2024-03-23 13:29:51 发布