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

📄 newchargeget.java

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

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

public class NewChargeGet {
	
	Statement st;
	public static String code,date,money,go,receive,man;       //获取宠物编号 收费日期 金额 就诊日期 接种日期 收费人
	boolean check = false;
	public JFrame frame;

	public NewChargeGet(JFrame frame){
		
		this.frame=frame;
		if(setDao(check)){
			
			frame.dispose();
		}
		
	}
	
	public boolean setDao(boolean check){
		
		try {
			if(NewCharge.TNum.getText().trim().equals("")){              //宠物编号为空的处理
				
				JOptionPane.showMessageDialog(null,"宠物编号不允许为空!","新增收费",JOptionPane.ERROR_MESSAGE);
				NewCharge.TNum.requestFocus();
				return false;
			}
			
			Pattern codes=Pattern.compile("[0-9]{8}");                   //宠物编号格式
			Matcher mcode=codes.matcher(NewCharge.TNum.getText()); 
			
			if (!mcode.matches()){ 
				
				JOptionPane.showMessageDialog(null,"编号格式不符,重新输入!", "错误对话框",JOptionPane.ERROR_MESSAGE);
				NewCharge.TNum.setText("");
				NewCharge.TNum.requestFocus();
                return false;
			} 
			
			if(NewCharge.TDate.getText().trim().equals("")){
				
				JOptionPane.showMessageDialog(null,"收费日期不允许为空!","新增收费",JOptionPane.ERROR_MESSAGE);
				NewCharge.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(NewCharge.TDate.getText()); 
		
			if (!mbirth.matches()){ 
				
				JOptionPane.showMessageDialog(null,"收费日期格式不符,重新输入!", "错误对话框",JOptionPane.ERROR_MESSAGE);
				NewCharge.TDate.setText("");
				NewCharge.TDate.requestFocus();
                return false;
			} 
			
			if(NewCharge.TMoney.getText().trim().equals("")){            //金额为空判断     
				
				JOptionPane.showMessageDialog(null,"金额不允许为空!","新增收费",JOptionPane.ERROR_MESSAGE);
				NewCharge.TMoney.requestFocus();
				return false;
			}
			
			if(NewCharge.TGo.getText().trim().equals("")){
				
				JOptionPane.showMessageDialog(null,"就诊日期不允许为空!","新增收费",JOptionPane.ERROR_MESSAGE);
				NewCharge.TGo.requestFocus();
				return false;
			}
			                                                                   //就诊日期格式
			Pattern gos=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 mgo=gos.matcher(NewCharge.TDate.getText()); 
		
			if (!mgo.matches()){ 
				
				JOptionPane.showMessageDialog(null,"就诊日期格式不符,重新输入!", "错误对话框",JOptionPane.ERROR_MESSAGE);
				NewCharge.TDate.setText("");
				NewCharge.TDate.requestFocus();
                return false;
			} 
			
			if(NewCharge.TDate.getText().trim().equals("")){
				
				JOptionPane.showMessageDialog(null,"接种日期不允许为空!","新增收费",JOptionPane.ERROR_MESSAGE);
				NewCharge.TDate.requestFocus();
				return false;
			}
			                                                                //接种日期格式
			Pattern receives=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 mreceive=receives.matcher(NewCharge.TDate.getText()); 
		
			if (!mreceive.matches()){ 
				
				JOptionPane.showMessageDialog(null,"接种日期格式不符,重新输入!", "错误对话框",JOptionPane.ERROR_MESSAGE);
				NewCharge.TDate.setText("");
				NewCharge.TDate.requestFocus();
                return false;
			} 
			
			if(NewCharge.TMan.getText().trim().equals("")){              //诊断人为空处理
				
				JOptionPane.showMessageDialog(null,"接种人不允许为空!","新增收费",JOptionPane.ERROR_MESSAGE);
				NewCharge.TMan.requestFocus();
				return false;
			}
			
			code=NewCharge.TNum.getText();                               //获取宠物编号
			date=NewCharge.TDate.getText();                              //获取收费日期
			money=NewCharge.TMoney.getText();                            //获取金额
			go=NewCharge.TGo.getText();                                //获取就诊日期
			receive=NewCharge.TDate.getText();                              //获取接种日期
			man=NewCharge.TMan.getText();                                //获取诊断人
			
			String Srecord="('"+ code + "','"+date +"','" +money +"','" +go+"','" +receive+"','"+man+"')";
			SystemShare.SQL="insert into ChargeInfo values" + Srecord;
			
			SystemShare.getConnection();
			st=SystemShare.con.createStatement();                        //更新数据库
			st.executeUpdate(SystemShare.SQL);  
			
			SystemShare.newsuccess();
			frame.dispose();
			new ChargeRegister();
			
			this.check=check;

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

}

⌨️ 快捷键说明

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