简单的员工信息管理系统源码
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
据库连接3.查询4.增、5删6改(操作数据库)
import .*;
import .*;
import .*;
import .*;
public class EmpManageSys implements ActionListener { Connection con;
Statement stmt;
String sql;
ResultSet rs;
StringBuffer sb = new StringBuffer();
JTextField jtf2 = new JTextField("张飞",10);
JTextField jtf3 = new JTextField(10);
JTextField jtf4 = new JTextField(10);
JTextField jtf7 = new JTextField(10);
JTextField jtf5 = new JTextField(10);
JTextField jtf6 = new JTextField(10);
JTextField jtf8 = new JTextField(10);
JTextField jtf9 = new JTextField(10);
JTextArea jta10 = new JTextArea(50, 40);
public void actionPerformed(ActionEvent e) {
String str = ();
if ("查询".equals(str)) {
quals(str)) {
quals(str)) {
quals(str)) {
EmpManageSys() {
createGUI();
connectToDataBase();
public Connection connectToDataBase() { con = ();
(con);
return con;
}
public void searchEmp() {
("");
try {
stmt = ();
oLowerCase().trim() + "or id="
+ ().toLowerCase().trim() + "or engName=" + ().toLowerCase().trim() + "or UNIT="
+ ().toLowerCase().trim() + "or TEAM="
+ ().toLowerCase().trim() + "or Phone="
+ ().toLowerCase().trim() + "or region="
+ ().toLowerCase().trim() + "or busStation=" + ().toLowerCase().trim();
(sql);
rs = ();
ResultSetMetaData meta = ();
int cols = ();
while ()) {
for (int i = 1; i <= cols; i++) {
(" " + (i) + " =");
(i));
}
("\n");
());
}
} catch (SQLException e11) {
();
}
}
public void addEmp() {
try {
stmt = ();
sql = "update Mstar values(" + () + ()
+ () + () + ()
+ () + () + () + ")";
int i = ();
if (() != null) && () != null)
&& () != null) && () != null)) {
(sql);
("添加记录成功" + i + "条");
} else {
("带*号项为添加记录时不能为空");
}
} catch (SQLException e1) {
();
}
}
public void deleteEmp() {
searchEmp();
try {
stmt = ();
sql = "delete from Mstar where chineseName=" + ().toLowerCase().trim() + "or id="
+ ().toLowerCase().trim() + "or engName="
+ ().toLowerCase().trim() + "or UNIT="
+ ().toLowerCase().trim() + "or TEAM="
+ ().toLowerCase().trim() + "or Phone="
+ ().toLowerCase().trim() + "or region="
+ ().toLowerCase().trim() + "or busStation=" + ().toLowerCase().trim();
(sql);
int i = ();
("撤除操作成功" + i + "条");
} catch (SQLException e) {
();
}
}
public void alterEmp() {
searchEmp();
sql = "update Mstar set chineseName="
+ ().toLowerCase().trim() + "and id="
+ ().toLowerCase().trim() + "and engName=" + ().toLowerCase().trim() + "and UNIT="
+ ().toLowerCase().trim() + "and TEAM="
+ ().toLowerCase().trim() + "and Phone="
+ ().toLowerCase().trim() + "and region="
+ ().toLowerCase().trim() + "and busStation="