-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathManagerModel.java
61 lines (48 loc) · 1.62 KB
/
ManagerModel.java
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
package ems.erp.model;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import ems.erp.beans.Employee;
import ems.erp.beans.Project;
import ems.erp.beans.Salary;
import ems.erp.util.MYDb;
public class ManagerModel {
public static String addProject(Project project) {
String s1 = null;
Connection con = MYDb.getCon();
try {
Statement stmt = con.createStatement();
String sql = "insert into project(name,status,des,cost,assignTo,department)values('" + project.getPname() + "', '"
+ project.getPstatus() + "'," + "'" + project.getDescription() + "','" + project.getCost() + "', '"+project.getAssignTo()+"','"+project.getDepartment()+"')";
int rs = stmt.executeUpdate(sql);
if (rs > 0) {
s1 = "sucess";
} else {
s1 = "unsucess";
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return s1;
}
static Project pro= null;
public static ArrayList<Project> viewProject() {
Connection con = MYDb.getCon();
ArrayList<Project> proList = new ArrayList<Project>();
try {
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from project");
while (rs.next()) {
pro = new Project(rs.getString("name"), rs.getString("status"), rs.getString("des"), rs.getString("cost"), rs.getString("assignTo"), rs.getString("department"));
proList.add(pro);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return proList;
}
}