-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegistration.java
More file actions
107 lines (96 loc) · 2.54 KB
/
Registration.java
File metadata and controls
107 lines (96 loc) · 2.54 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
package com.company;
import java.sql.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Registration
{
private static int total = 0;
private String No;
private String grade;
private String start = "10-08-2020";
private String end = "14-08-2020";
private String withdraw = "1-12-2020";
Section sec;
Course course;
Student stu;
Teacher tea;
Marks mark;
private boolean isSave = false;
public Registration()
{
total++;
grade = "I";
}
public Registration( Section se, Student st)
{
total++;
sec = se;
stu = st;
}
public void setStu(Student s)
{
stu =s;
}
public void setsec(Section s)
{
sec = s;
}
public void setsec(Course s)
{
course = s;
}
public void setRegno()
{
No = String.valueOf(total);
}
public Date getstartDate() throws ParseException {
return new SimpleDateFormat("dd-MM-yyyy").parse(start);
}
public Date getendDate() throws ParseException {
return new SimpleDateFormat("dd-MM-yyyy").parse(end);
}
public Date getwithdrawDate() throws ParseException {
return new SimpleDateFormat("dd-MM-yyyy").parse(withdraw);
}
public String getregNo()
{
return No;
}
public void save() throws SQLException, ClassNotFoundException {
if (!isSave)
{
setRegno();
Connection con = DBConnection.connect();
PreparedStatement ps;
ps = null;
String sql = "INSERT INTO Registration(Grade, Withdraw_time, Start_time, S_ID, Student_no,No,End_time) VALUES(?,?,?,?,?,?,?) ";
ps = con.prepareStatement(sql);
ps.setString(1, grade);
ps.setString(2, withdraw);
ps.setString(3, start);
ps.setString(4,sec.getSectionName() );
ps.setString(5,stu.getRollNo() );
ps.setString(6,No );
ps.setString(7,end);
ps.setString(8,course.getCourseCode());
ps.execute();
System.out.println("Registration Saved!");
ps.close();
con.close();
isSave = true;
}
}
public void print()
{
System.out.println("RegNo: " + No + "Course Name: " + sec.course.getName() + "Section: " + sec.getSectionName());
}
public void setGrade(String g)
{
grade = g;
}
public String getGrade()
{
return grade;
}
}