package imis_elec;

public class ElecUseInfoCheck {
	public static String message = "";
	public static boolean check = true;
	public static String message1 = "如果是浮点数,整数位最多7位, 小数位最多3位<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;如果是整数,最多7位";
	public static String message2 = "如果是浮点数,整数位最多9位, 小数位最多3位<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;如果是整数,最多9位";

	public static String checkElecMeterRegNo(String elecMeterRegNo) {
		
		if(elecMeterRegNo.equals("")) {
			message = "电表编号不能为空!";
			check = false;
		} else {
			if(elecMeterRegNo.length() > 30) {
				message = "电表编号长度超出,限定为0-30个英文字符";
				check = false;
			}
		}
		return message;
	}
	
	public static String checkNowReading(String nowReading) {
		
		if(nowReading.equals("")) {
			message = "本月指数不能为空";
			check = false;
		} else {
			if(!nowReading.matches("(^[\\d]{1,9}|^[\\d]{1,9})($|[\\.][\\d]{0,3}$)")) {
				message = "本月指数" + message2;
				check = false;
			}
		}
		return message;
	}
	
	public static String checkElecMeterReading(String elecMeterReading) {
		
		if(elecMeterReading.equals("")) {
			message = "上月指数不能为空";
			check = false;
		} else {
			if(!elecMeterReading.matches("(^[\\d]{1,9}|^[\\d]{1,9})($|[\\.][\\d]{0,3}$)")) {
				message = "上月指数" + message2;
				check = false;
			}
		}
		return message;
	}
	
	public static String checkXianLoss(String xianLoss) {
		
		if(xianLoss.equals("")) {
			message = "线损不能为空";
			check = false;
		} else {
			if(!xianLoss.matches("(^[\\d]{1,7}|^[\\d]{1,7})($|[\\.][\\d]{0,3}$)")) {
				message = "线损" + message1;
				check = false;
			}
		}
		return message;
	}
	
	public static String checkBianLoss(String bianLoss) {
		
		if(bianLoss.equals("")) {
			message = "变损不能为空";
			check = false;
		} else {
			if(!bianLoss.matches("(^[\\d]{1,7}|^[\\d]{1,7})($|[\\.][\\d]{0,3}$)")) {
				message = "变损" + message1;
				check = false;
			}
		}
		return message;
	}
	
	public static String checkTuiBu(String tuiBu) {
		
		if(tuiBu.equals("")) {
			message = "退补电量不能为空";
			check = false;
		} else {
			if(!tuiBu.matches("(^\\-?[\\d]{1,7}|^\\-?[\\d]{1,7})($|[\\.][\\d]{0,3}$)")) {
				message = "退补电量" + message1;
				check = false;
			}
		}
		return message;
	}
	
	public static String checkPriceUnit(String priceUnit) {
		
		if(priceUnit.equals("")) {
			message = "单价不能为空";
			check = false;
		} else {
			if(!priceUnit.matches("(^[\\d]{1,7}|^[\\d]{1,7})($|[\\.][\\d]{0,4}$)")) {
				message = "单价" + message1;
				check = false;
			}
		}
		return message;
	}
	
	public static String checkMemo(String memo) {
		
		if (memo.length() > 100) {
			message = "输入备注长度超出,限定为0-100个英文字符";
			check = false;
		}
		return message;
	}
	
	public static void setCheck() {
		check = true;
	}
}