📄 pldrvalidatebean.java
字号:
throw new Exception("数据库连接出错");
}
}
//暂估否(k_zgf smallint) 只能为0或1
public boolean validateZgf(int k_zgf) throws Exception {
if (k_zgf == 0 || k_zgf == 1) {
return true;
} else {
throw new Exception("暂估否只能为0或1");
}
}
// 父子(k_fz smallint) 只能为0或1,2
public boolean validateFz(int k_fz) throws Exception {
if (k_fz == 0 || k_fz == 1 || k_fz == 2) {
return true;
} else {
throw new Exception("父子只能为0或1或2");
}
}
//判断关联卡片编号
public boolean validateGlkpbh(long k_glkpbh) throws Exception {
if (k_glkpbh != 0) {
throw new Exception("关联卡片编号应为0");
}
return true;
}
//判断父卡片编号
public boolean validateFkpbh(int k_fz, long k_fkpbh, String tableName)
throws Exception {
String sql =
" select count(*) from " + tableName + " where k_kpbh=" + k_fkpbh;
ResultSet rs = db.executeQuery(sql);
rs.next();
if (k_fz == 2 && k_fkpbh != 0) {
if (rs.getInt(1) > 0) {
rs.close();
return true;
}
} else {
if (k_fz == 2 && k_fkpbh == 0) {
throw new Exception("子卡片需要填写父卡片编号");
} else if (k_fkpbh == 0) {
return true;
} else {
throw new Exception("普通卡片和父卡片的父卡片编号请填零");
}
}
rs.close();
throw new Exception("卡片表中不存在该父卡片编号");
}
// 判断父卡片序号
public boolean validateFkpxh(long k_fkpxh, int k_fz, String tableName)
throws Exception {
if (k_fz == 2) {
if (k_fkpxh == 0) {
throw new Exception("父卡片序号不能为零");
}
String sql =
"select count(*) from " + tableName + " where xh =" + k_fkpxh;
ResultSet rs = db.executeQuery(sql);
if (rs.next()) {
if (rs.getInt(1) > 0) {
rs.close();
return true;
} else {
rs.close();
throw new Exception("Excel表中不存在该父卡片序号");
}
} else {
rs.close();
throw new Exception("数据库连接出错");
}
} else {
if (k_fkpxh == 0) {
return true;
} else {
throw new Exception("父卡片序号应为零");
}
}
}
//判断父卡片的原值是否为各子卡片原值的和
public boolean validateFkpYz(String tableName, int count)
throws Exception {
HashMap map = new HashMap();
long[] xh = new long[count];
String message = "";
String sql =
" select distict(xh),yz from " + tableName + " where fz = 1 ";
ResultSet rs = db.executeQuery(sql);
int i = 0;
while (rs.next()) {
xh[i++] = rs.getLong(1);
map.put(new Long(rs.getLong(1)), new Double(rs.getDouble(2)));
}
rs.close();
for (int j = 0; j < i; j++) {
sql =
"select sum(yz) from "
+ tableName
+ " where fz = 2 and fkpxh ="
+ xh[j];
rs = db.executeQuery(sql);
if (rs.next()) {
double fkpyz =
((Double) map.get(new Long(xh[j]))).doubleValue();
if (rs.getDouble(1) != fkpyz) {
message += "父卡片序号为" + xh[j] + "的各卡片原值不等于各子卡片原值总和\n";
}
}
}
if (message.equals("")) {
return true;
} else {
throw new Exception(message);
}
}
//判断父卡片编号
public boolean validateFkpbh(int k_fz, long k_fkpbh) throws Exception {
if (k_fz == 2) {
if (k_fkpbh == 0) {
throw new Exception("父卡片编号不能为零或空");
} else {
return true;
}
} else {
if (k_fkpbh == 0) {
return true;
} else {
throw new Exception("父卡片编号应为零或空");
}
}
}
//判断父卡片序号
public boolean validateFkpxh(int k_fz, long k_fkpbh, long k_fkpxh)
throws Exception {
if (k_fz == 2) {
if (k_fkpbh == 0 && k_fkpxh == 0) {
throw new Exception("子卡片必须填父卡片编号或父卡片序号");
} else if (k_fkpbh != 0 && k_fkpxh != 0) {
throw new Exception("子卡片必须只能有一个父卡片编号或父卡片序号");
} else {
return true;
}
} else {
if (k_fkpbh == 0 && k_fkpxh == 0) {
return true;
} else {
if (k_fz == 0) {
throw new Exception("普通卡片的父卡片编号和父卡片序号不填或只能填0");
} else {
throw new Exception("父卡片的父卡片编号和父卡片序号不填或只能填0");
}
}
}
}
// 判断凭证号码
public boolean validatePzhm(String k_pzhm, String k_dwbh)
throws Exception {
String sql =
"select count(*) from gd_pzb where k_dwbh = '"
+ k_dwbh
+ "'"
+ " and k_pzbh = '"
+ k_pzhm
+ "'";
ResultSet rs = db.executeQuery(sql);
if (rs.next()) {
if (rs.getInt(1) > 0) {
rs.close();
return true;
} else {
rs.close();
throw new Exception("凭证号码不存在");
}
} else {
rs.close();
throw new Exception("数据库连接出错");
}
}
// 判断增加类型
public boolean validateZjlx(int k_zjlx) throws Exception {
String sql = "select count(*) from gd_zjlxb where k_zjlx =" + k_zjlx;
ResultSet rs = db.executeQuery(sql);
if (rs.next()) {
if (rs.getInt(1) > 0) {
rs.close();
return true;
} else {
rs.close();
throw new Exception("增加类型不存在");
}
} else {
rs.close();
throw new Exception("数据库连接出错");
}
}
//判断减少类型
public boolean validateJslx(int k_jslx) throws Exception {
String sql = "select count(*) from gd_jslxb where k_jslx =" + k_jslx;
ResultSet rs = db.executeQuery(sql);
if (rs.next()) {
if (rs.getInt(1) > 0) {
rs.close();
return true;
} else {
rs.close();
throw new Exception("减少类型不存在");
}
} else {
rs.close();
throw new Exception("数据库连接出错");
}
}
/*// 判断工程编号
public boolean validateGcbh(String k_gcbh)throws Exception{
String sql = "select count(*) from gd_gcdrb where k_gcbh = '" + k_gcbh + "'";
ResultSet rs = db.executeQuery(sql);
if(rs.next()){
if(rs.getInt(1)>0){
rs.close();
return true;
}
else{
rs.close();
throw new Exception("工程编号不存在");
}
}
else {
rs.close();
throw new Exception("数据库连接出错");
}
}
// 判断设备位置号
public boolean validateSbwzh(String k_sbwzh)throws Exception{
String sql = "select count(*) from gd_gcdrb where k_zjlx = '" + k_sbwzh + "'";
ResultSet rs = db.executeQuery(sql);
if(rs.next()){
if(rs.getInt(1)>0){
rs.close();
return true;
}
else{
rs.close();
throw new Exception("工程编号不存在");
}
}
else {
rs.close();
throw new Exception("数据库连接出错");
}
}
*/
// 盘盈否只能为0或1
public boolean validatePyf(int k_pyf) throws Exception {
if (k_pyf == 0 || k_pyf == 1) {
return true;
} else {
throw new Exception("盘盈否只能为0或1");
}
}
//板卡利用率
public boolean validateBklyl(double k_bklyl) throws Exception {
if (k_bklyl >= 0 && k_bklyl <= 100) {
return true;
} else {
throw new Exception("板卡利用率应在0.00到100.00之间");
}
}
//用户实装率
public boolean validateYhszl(double k_bklyl) throws Exception {
if (k_bklyl >= 0 && k_bklyl <= 100) {
return true;
} else {
throw new Exception("板卡利用率应在0.00到100.00之间");
}
}
//原帐面原值
public boolean validateYzmjz(String k_yzmjz) throws Exception {
String temp = k_yzmjz;
if (temp.indexOf(".") != -1
&& (temp.substring(temp.indexOf(".") + 1)).length() > 2) {
throw new Exception("原帐面净值小数点后最多两位");
}
return true;
}
//原帐面净值
public boolean validateYzmyz(String k_yzmyz) throws Exception {
String temp = k_yzmyz;
if (temp.indexOf(".") != -1
&& (temp.substring(temp.indexOf(".") + 1)).length() > 2) {
throw new Exception("原帐面原值小数点后最多两位");
}
return true;
}
//成新率
public boolean validateCxl(double k_bklyl) throws Exception {
if (k_bklyl >= 0 && k_bklyl <= 100) {
return true;
} else {
throw new Exception("板卡利用率应在0.00到100.00之间");
}
}
public boolean validateDate(
java.util.Date k_gmrq,
java.util.Date k_rzrq,
java.util.Date k_kssyrq,
java.util.Date k_jkrq,
String k_ywrq
)
throws Exception {
DateCom date=new DateCom();
int i=0;
if (k_gmrq.after(k_kssyrq)) {
if (k_rzrq.after(k_gmrq)) {
throw new Exception("购买日期应在开始使用日期之前,购买日期应在入帐日期之前!");
}
if (k_kssyrq.after(k_rzrq)) {
throw new Exception("购买日期应在开始使用日期之前,开始使用日期应在入帐日期之前!");
}
throw new Exception("购买日期应在开始使用日期之前!");
}
if (k_kssyrq.after(k_jkrq)) {
throw new Exception("开始使用日期应在建卡日期之前!");
}
i=date.do_Month(k_kssyrq,k_ywrq);
if(i<-1 || i>3){
throw new Exception("开始使用日期应小于折旧日期三个月或大于折旧日期一个月!");
}
i=date.do_Month(k_jkrq,k_ywrq);
if(i<-1 || i>0){
throw new Exception("建卡日期应等于折旧日期或大于折旧日期一个月!");
}
return true;
}
//2006-7-31增加,外省导入时判断入帐日期应大于业务日期
public boolean validateDate(java.util.Date k_rzrq,String k_ywrq)throws Exception{
DateCom date=new DateCom();
int i=0;
i=date.do_Month(k_rzrq,k_ywrq);
if(i>0){
throw new Exception("入帐日期应大于折旧日期!");
}
return true;
}
public void close() {
try {
/* if (db != null) {
db.close();
} */
} catch (Exception e) {
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -