- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
AdminService.java
资源名称:shihua.rar [点击查看]
上传用户:zghglow
上传日期:2022-08-09
资源大小:27227k
文件大小:3k
源码类别:
WEB源码(ASP,PHP,...)
开发平台:
JavaScript
- package com.chinacannel.xlchemical.service;
- import org.apache.commons.logging.Log;
- import org.apache.commons.logging.LogFactory;
- import com.chinacannel.common.CommonDAO;
- import com.chinacannel.common.DAOException;
- import com.chinacannel.common.TranUtil;
- import com.chinacannel.entity.Admin;
- import java.util.List;
- import com.chinacannel.entity.Role;
- import com.chinacannel.common.PageInfo;
- public class AdminService extends TranUtil {
- private CommonDAO dao = new CommonDAO();
- private static Log log = LogFactory.getLog(AdminService.class);
- public Admin CheckLogin(String Name, String Pwd) {
- Admin admin = null;
- try {
- admin = (Admin) dao.loadOneObjectBySQL
- ("from Admin where Adm_Name='" + Name + "' and Adm_Pwd='" +
- Pwd + "'");
- return admin;
- } catch (DAOException ex) {
- log.error(ex.getMessage(), ex);
- return null;
- }
- }
- public boolean AddAdmin(Admin adm) {
- try {
- return dao.createObject(adm);
- } catch (DAOException ex) {
- log.error(ex.getMessage(), ex);
- return false;
- }
- }
- public boolean UpdateAdmin(Admin adm) {
- try {
- return dao.updateObject(adm);
- } catch (DAOException ex) {
- log.error(ex.getMessage(), ex);
- return false;
- }
- }
- public boolean DeleteAdmin(Admin adm) {
- try {
- return dao.removeObject(adm);
- } catch (DAOException ex) {
- log.error(ex.getMessage(), ex);
- return false;
- }
- }
- public Admin GetAdminById(Long ID) {
- try {
- return (Admin) dao.loadObject(ID, Admin.class);
- } catch (DAOException ex) {
- log.error(ex.getMessage(), ex);
- return null;
- }
- }
- public List getAdminList(String name, Role role, int start, int top) {
- List list = null;
- String hql = "from Admin as adm where adm.adm_ID!=" + 0;
- try {
- if (role != null) {
- hql += " and adm.role.rol_ID=" + role.getRol_ID();
- }
- if (!name.equals("")) {
- hql += " and adm.adm_Name like '%" + name + "%'";
- }
- hql += " order by adm.adm_Time desc";
- list = dao.loadObjectListBySQL(hql, start, top);
- } catch (DAOException ex) {
- log.error(ex.getMessage(), ex);
- return null;
- }
- return list;
- }
- public int getCount(String name, Role role) {
- String hql =
- "select count(*) from Admin as adm where adm.adm_ID!=" + 0;
- if (role != null) {
- hql += " and adm.role.rol_ID='" + role.getRol_ID() + "'";
- }
- if (!name.equals("")) {
- hql += " and adm.adm_Name like '%" + name + "%'";
- }
- try {
- return dao.getCountBySql(hql);
- } catch (DAOException ex) {
- log.error(ex.getMessage(), ex);
- return 0;
- }
- }
- public PageInfo getPageInfo(String name, Role role, int pageno) {
- PageInfo pageInfo = new PageInfo(this.getCount(name, role), pageno, 10);
- pageInfo.setRows(this.getAdminList(name, role, pageInfo.getStartRow(),
- pageInfo.getPageSize()));
- return pageInfo;
- }
- }