This repository was archived by the owner on Dec 12, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFeelSafeLogic.java
More file actions
163 lines (146 loc) · 3.63 KB
/
FeelSafeLogic.java
File metadata and controls
163 lines (146 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package feelsafeLogic;
import java.util.*;
import feelsafeHibernatePackage.*;
import org.hibernate.*;
import org.hibernate.criterion.*;
public class FeelSafeLogic {
public String id1()
{
Random random=new Random();
int i=random.nextInt();
if(i<0)
{
i=-(i);
}
if(i<1000)
i=i+1000;
while(i>9999)
{
i=i/10;
}
return i+"";
}
public String id2()
{
Random random=new Random();
int i=random.nextInt();
if(i<0)
{
i=-(i);
}
if(i<10000)
i=i+10000;
while(i>99999)
{
i=i/10;
}
return "PAT-"+i;
}
public Integer id3()
{
Random random=new Random();
int i=random.nextInt();
if(i<0)
{
i=-(i);
}
if(i<1000)
i=i+1000;
while(i>9999)
{
i=i/10;
}
return i;
}
public Integer verifyUser(String username, String password)
{
Session session=HibernateSessionFactory.getSession();
Criteria criteria=session.createCriteria(Employees.class);
criteria.add(Expression.eq("username", username));
criteria.add(Expression.eq("password", password));
List list=criteria.list();
Employees employees=new Employees();
for(Iterator i=list.iterator();i.hasNext();)
{
employees=(Employees)i.next();
return employees.getType();
}
return -1;
}
public Integer addNewEmployee(String username, String password, String firstname, String lastname, String address, String phone, Integer sex, String nationality, String verificationcode, Integer type, String consultinghours, String qualification, String specialist)
{
Session session=HibernateSessionFactory.getSession();
Transaction transaction=session.beginTransaction();
Employees employees=new Employees();
try
{
employees.setUsername(username);
employees.setPassword(password);
employees.setFirstname(firstname);
employees.setLastname(lastname);
employees.setAddress(address);
employees.setPhone(phone);
employees.setSex(sex);
employees.setNationality(nationality);
employees.setVerificationcode(verificationcode);
employees.setType(type);
employees.setConsultinghours(consultinghours);
employees.setQualification(qualification);
employees.setSpecialist(specialist);
session.save(employees);
transaction.commit();
}catch(Exception e)
{
return -1;
}
return 1;
}
public List readDoctor()
{
Session session=HibernateSessionFactory.getSession();
Criteria criteria=session.createCriteria(Employees.class);
criteria.add(Expression.eq("type", 3));
return criteria.list();
}
public Integer addNewEquipment(String name, Float price)
{
Session session=HibernateSessionFactory.getSession();
Transaction transaction=session.beginTransaction();
Otherfees otherfees=new Otherfees();
try
{
otherfees.setId(this.id3());
otherfees.setEquipmentname(name);
otherfees.setFees(price);
session.save(otherfees);
transaction.commit();
}catch(Exception e)
{
return -1;
}
return 1;
}
public Integer appointmentScheduling(String patientname, Integer patientage, Integer patientsex, String patienthealthproblem, String patientdate, String patienttime)
{
Session session=HibernateSessionFactory.getSession();
Transaction transaction=session.beginTransaction();
Appointments appointments=new Appointments();
try
{
appointments.setAge(patientage);
appointments.setAppointmentdate(patientdate);
appointments.setAppointmenttime(patienttime);
appointments.setHealthproblem(patienthealthproblem);
appointments.setId(this.id3());
appointments.setPatientname(patientname);
appointments.setSex(patientsex);
appointments.setType(1);
session.save(appointments);
transaction.commit();
}catch(Exception e)
{
return -1;
}
return 1;
}
}