⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newprotectget.java

📁 宠物医院管理系统 包含宠物的注册 管理 收费 诊断等一系列过程控制 还包含配应的数据库 Jar包
💻 JAVA
字号:
package yd.pethospital.protectcommom;

import java.sql.*;
import java.util.regex.*;
import javax.swing.*;
import yd.pethospital.protectregister.view.*;
import yd.pethospital.share.SystemShare;

public class NewProtectGet {
	
	Statement st;
	public static String code,date,medicine,account,man,SQL;   //获取编号、日期、疫苗、数量、诊断人、数据库语句
	boolean check = false;
	public JFrame frame;

	public NewProtectGet(JFrame frame){
		
		this.frame=frame;
		if(setDao(check)){
			
			frame.dispose();
		}
	}
	
	public boolean setDao(boolean check){
		
		try {
			
			if(NewProtect.TNum.getText().trim().equals("")){           //宠物编号为空的处理
				
				JOptionPane.showMessageDialog(null,"宠物编号不允许为空!","新增防疫",JOptionPane.ERROR_MESSAGE);
				NewProtect.TNum.requestFocus();
				return false;
			}
			
			Pattern codes=Pattern.compile("[0-9]{8}");                 //宠物编号格式
			Matcher mcode=codes.matcher(NewProtect.TNum.getText()); 
			
			if (!mcode.matches()){ 
				
				JOptionPane.showMessageDialog(null,"编号格式不符,重新输入!", "错误对话框",JOptionPane.ERROR_MESSAGE);
				NewProtect.TNum.setText("");
				NewProtect.TNum.requestFocus();
                return false;
			} 
			
			if(NewProtect.TDate.getText().trim().equals("")){            //接种日期为空处理
				
				JOptionPane.showMessageDialog(null,"接种日期不允许为空!","新增防疫",JOptionPane.ERROR_MESSAGE);
				NewProtect.TDate.requestFocus();
				return false;
			} 
			                                                              //接种日期格式
			Pattern dates=Pattern.compile("(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29) "); 
			Matcher mbirth=dates.matcher(NewProtect.TDate.getText()); 
		
			if (!mbirth.matches()){ 
				
				JOptionPane.showMessageDialog(null,"接种日期格式不符,重新输入!", "错误对话框",JOptionPane.ERROR_MESSAGE);
				NewProtect.TDate.setText("");
				NewProtect.TDate.requestFocus();
                return false;
			} 
			
			if(NewProtect.TMedicine.getText().trim().equals("")){   //疫苗编号为空处理
				
				JOptionPane.showMessageDialog(null,"疫苗编号不允许为空!","新增防疫",JOptionPane.ERROR_MESSAGE);
				NewProtect.TMedicine.requestFocus();
				return false;
			}
			
			if(NewProtect.TAccount.getText().trim().equals("")){     //数量为空处理
				 
				JOptionPane.showMessageDialog(null,"使用数量不允许为空!","新增防疫",JOptionPane.ERROR_MESSAGE);
				NewProtect.TAccount.requestFocus();
				return false;
			}
			
			
			if(NewProtect.TMan.getText().trim().equals("")){        //接种人为空处理
				
				JOptionPane.showMessageDialog(null,"接种人不允许为空!","新增防疫",JOptionPane.ERROR_MESSAGE);
				NewProtect.TMan.requestFocus();
				return false;
			}
			
			code=NewProtect.TNum.getText();                              //获取宠物编号
			date=NewProtect.TDate.getText();                             //获取接种日期
			medicine=NewProtect.TMedicine.getText();                     //获取疫苗编号
			account=NewProtect.TAccount.getText();                       //获取使用数量
			man=NewProtect.TMan.getText();                               //获取接种人
			
			String Srecord="('"+ code + "','"+date +"','" +medicine +"','" +account+"','" +man+"')";   //数据库语句
			SystemShare.SQL="insert into EpidemicInfo values" + Srecord;

			SystemShare.getConnection();
			st=SystemShare.con.createStatement();
			st.executeUpdate(SystemShare.SQL);                        //处理数据库
				
			SystemShare.newsuccess();
			frame.dispose();
			new ProtectRegister();
			
			this.check=check;

		}catch (SQLException e) {
			SystemShare.newfail();
		}
		SystemShare.close();
		return false;
	} 
			
}

⌨️ 快捷键说明

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