📄 patient.java
字号:
package com.hospital.web;
import java.sql.*;
import java.text.SimpleDateFormat;
import com.hospital.util.*;
import com.hospital.web.*;
import java.util.Vector;
import java.util.Date;
import java.util.Calendar;
/**
* patient
*/
public class patient extends DataBase {
private String ic; //身份证号
private String passwd; //登录密码
private String name=""; //真实姓名
private String sex="";
private int age;
private String address="";
private String phone="";
private String email="";
private int pid;
public Vector searchlist_1=new Vector();
public String did;
public int day;
public int isam;
public int week;
public int wd;
public patient() throws Exception{
super();
this.pid=0;
this.ic = "";
this.passwd = "";
this.name=""; //真实姓名
this.sex="";
this.age=0;
this.address="";
this.phone="";
this.email="";
this.did="";
this.day=-1;
this.week=-1;
this.isam=-1;
}
public String getIc() {
return this.ic;
}
public void setIc(String newic) {
this.ic = newic;
}
public String getName() {
return this.name;
}
public void setName(String newname) {
this.name = newname;
}
public String getPasswd() {
return this.passwd;
}
public void setPasswd(String newpasswd) {
this.passwd = newpasswd;
}
public String getSex() {
return this.sex;
}
public void setSex(String newsex) {
this.sex = newsex;
}
public String getAddress() {
return this.address;
}
public void setAddress(String newaddress) {
this.address = newaddress;
}
public String getPhone() {
return this.phone;
}
public void setPhone(String newphone) {
this.phone = newphone;
}
public String getEmail() {
return this.email;
}
public void setEmail(String newemail) {
this.email = newemail;
}
public int getAge() {
return this.age;
}
public void setAge(int newage) {
this.age = newage;
}
public int getPid() {
return this.pid;
}
public void setPid(int newpid) {
this.pid = newpid;
}
public void setWeek(int newweek) {
this.week = newweek;
}
public void setDay(int newday) {
this.day = newday;
}
public void setDid(String newdid) {
this.did = newdid;
}
public void setIsam(int newisam) {
this.isam = newisam;
}
public String getDid() {
return this.did;
}
public int getDay() {
return this.day;
}
public int getIsam() {
return this.isam;
}
public int getWeek() {
return this.week;
}
public int getWd() {
return this.wd;
}
public Vector getSearchlist_1() {
return searchlist_1;
}
protected int getPid(String newic){
try{
sqlStr="select * from patient where ic='"+ic+"'";
rs = stmt.executeQuery(sqlStr);
if(rs.next()){
int i=rs.getInt("pid");
return i;
}
}
catch (SQLException e)
{
return -2;
}
return -1;
}
public String Reg() throws Exception {
try{
sqlStr="select * from patient where ic='"+ic+"'";
rs = stmt.executeQuery(sqlStr);
if(rs.next())
return "已存在此身份证号";
else{
if(ic.length()!=18)
return "身份证长度错误";
else{
sqlStr="insert into patient (password,name,ic,age,sex,address,phone,email)" +
" values('"+passwd+"','"+name+"','"+ic+"','"+age+"','"+sex+"','"+address+"','"+phone+"','"+email+"')";
int res1 = stmt.executeUpdate(sqlStr);
if(res1!=1)
return "注册失败";
}
}
}
catch (SQLException e)
{
return e.toString();
}
return "";
}
public String UpdatePinfo() throws Exception {
try{
this.pid=getPid(ic);
sqlStr="select * from patient where pid='"+this.pid+"'";
rs = stmt.executeQuery(sqlStr);
if(!rs.next())
return "请重新登陆";
else{
sqlStr="update patient set password='"+this.passwd+"',name='"+this.name+"',age='"+this.age+"'" +
",sex='"+this.sex+"',address='"+this.address+"',phone='"+this.phone+"',email='"+this.email+"' " +
"where pid='"+this.pid+"'";
int res1 = stmt.executeUpdate(sqlStr);
if(res1!=1)
return "修改失败";
}
}
catch (SQLException e)
{
return e.toString();
}
return "";
}
public String appinfo() throws Exception {
try{
searchlist_1=new Vector();
pid=getPid(ic);
sqlStr="select * from pinqueue where pid='"+pid+"'";
rs = stmt.executeQuery(sqlStr);
searchlist_1.removeAllElements();
if(rs.wasNull())
return "请重新登陆";
else{
while(rs.next()){
patient p1=new patient();
p1.setDay(rs.getInt("day"));
p1.setDid(rs.getString("did"));
p1.setIsam(rs.getInt("isam"));
p1.setWeek(rs.getInt("week"));
searchlist_1.addElement(p1);
}
}
}
catch (SQLException e)
{
return e.toString();
}
return "";
}
public String delapp(String d,int w,int da,int ia) throws Exception {
try{
int p=getPid(this.ic);
sqlStr="select * from pinqueue where pid='"+p+"' and did='"+d+"' and Day='"+da+"' and Week='"+w+"' and Isam='"+ia+"'";
rs = stmt.executeQuery(sqlStr);
if(!rs.next())
return "请重新登陆";
else{
if(!candel(w,da))
return "时限已过,您不能取消预约";
sqlStr="delete from pinqueue where pid='"+p+"'and did='"+d+"' and day='"+da+"' and week='"+w+"' and isam='"+ia+"'";
int res2 = stmt.executeUpdate(sqlStr);
if(res2!=1)
return "删除失败";
}
}
catch (SQLException e)
{
return e.toString();
}
return "";
}
public int datetime(){
Calendar c=Calendar.getInstance();
return c.get(Calendar.DAY_OF_WEEK);
}
public boolean candel(int w,int da){
wd=datetime();
wd=wd-1;
if(wd==0)
wd=7;
if(w==1&&da-wd>=-5)
return true;
else if(w==0&&da-wd>=2)
return true;
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -