bookselldao.java

来自「图书管理系统 jsp+tomcat+sql2000」· Java 代码 · 共 123 行

JAVA
123
字号
package com.dao;
import java.io.Reader;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.engine.builder.xml.XmlSqlMapClientBuilder;
import com.actionForm.BookSellForm;
import java.sql.SQLException;
import java.util.List;
//图书销售操作
public class BookSellDao {
    public SqlMapClient sqlMap;

 public void getSqlMapClient() {
     try {
         String resource = "DataAccess.xml";
         Reader reader = Resources.getResourceAsReader(resource);
         XmlSqlMapClientBuilder xmlBuilder = new XmlSqlMapClientBuilder();
         sqlMap = xmlBuilder.buildSqlMap(reader);
     } catch (Exception e) {
         e.printStackTrace();
         throw new RuntimeException("Error initializing SqlConfig. Cause: " +
                                    e);
     }
 }



 //添加图书销售信息的方法
 public boolean insertBook(BookSellForm form) {
     try {
         this.getSqlMapClient();
         sqlMap.startTransaction();
         sqlMap.insert("insertBookSell", form);
         sqlMap.commitTransaction();
         return true;
     } catch (SQLException ex) {
         return false;
     }
 }

 //全部查询,分页显示
 public List selectBookSell(int number) {
     List list = null;
     try {
         this.getSqlMapClient();
         sqlMap.startTransaction();
         list = sqlMap.queryForList("selectBookSell", null, number * 14,
                                    14);
     } catch (SQLException ex) {
     }
     return list;
 }




 //查询出多少条纪录
 public List selectBookSellTop() {
	 List list = null;
     try {
         this.getSqlMapClient();
         sqlMap.startTransaction();
         
         list=sqlMap.queryForList("selectBookSellTop", null);
  
     } catch (SQLException ex) {
     }
   
     return list;
 }

 
 public int selectBookSell() {
     List list = null;
     try {
         this.getSqlMapClient();
         sqlMap.startTransaction();
         list = sqlMap.queryForList("selectBookSell", null);
     } catch (SQLException ex) {
     }
     int number = list.size();
     if (number % 14 == 0) {
         number = number / 14;
     } else {
         number = number / 14 + 1;
     }
     return number;
 }

 
 
 
 
 
 //以图书编号为条件,删除一组数据
 public boolean deleteBookSell(BookSellForm form) {
     try {
         this.getSqlMapClient();
         sqlMap.delete("deleteBookSell", form);
         return true;
     } catch (SQLException ex) {
         return false;
     }
 }



 //修改图书销售数目
 public boolean addBookSell(BookSellForm form) {
     try {

         this.getSqlMapClient();
         sqlMap.update("addBookSellNumber", form);
         return true;
     } catch (SQLException ex) {
         return false;
     }
 }



}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?