storehousetool.java
来自「hibernate应用测试,初学hibernate 的会员可以看看.」· Java 代码 · 共 38 行
JAVA
38 行
package com.tool;
import com.bean.*;
import com.dao.*;
import java.sql.SQLException;
//仓库管理及仓管员管理用到的一些方法
public class StorehouseTool {
//判断仓管员类型
//如果是自有仓管返回true,第三方仓管返回false
public static boolean getSHManagerType (int shMId) throws SQLException,Exception{
StorehouseShmanagerView shM = StorehouseShmanagerViewDAO.selectStorehouseShmanagerViewByshmId(shMId);
if(shM.getCompFlag()==0) return true;
if(shM.getCompFlag()==1) return false;
else throw new Exception("未知的仓管员类型!");
}
//判仓库类型
//自有仓库返回true,第三方仓库返回false
public static boolean getStorehouseType(int shId) throws SQLException,Exception{
Storehouse storehouse = StorehouseDAO.selectStorehouseByshId(shId);
if(storehouse.getShKind()==0) return true;
if(storehouse.getShKind()==1) return false;
else throw new Exception("未知的仓库类型!");
}
//判断某仓管员能否添加到某仓库
//true表示可,false表示不可以
//shMId为要判断的仓管员Id,shId要判断的仓库Id
public static boolean isShMCanAddToSh(int shMId,int shId) throws Exception{
boolean tmpShManageType = getSHManagerType(shMId);
boolean tmpStorehouseType = getStorehouseType(shId);
if(tmpShManageType&&tmpStorehouseType) return true;//自有仓管员可添加到自有仓库
if(!tmpShManageType&&!tmpStorehouseType) return true;//第三方仓管员可添加到第三方仓库
else return false;//其它情况都不允许添加
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?