📄 addactionservice.java
字号:
/*
* 僔僗僥儉丂丂丗 嶳廏HR僔僗僥儉奐敪
* 僒僽僔僗僥儉丗 WEB僔僗僥儉
*
* VER 丂曄峏擔 丂晹壽 扴摉幰 丂曄峏撪梕
* -----------------------------------------------------------------
* V1.00 丂丂2006/09/14 (ShanXiu丂Soft) Tuwenjie 弶斉
*
* (C) Copyright SHANXIU CORPORATION 2006
* All Rights Reserved.
*
*/
package net.shanxiu.HR.service;
import net.shanxiu.HR.actionform.AddActionForm;
import net.shanxiu.HR.dao.UpdateDao;
import net.shanxiu.HR.entity.CommonMethod;
/*******************************************************************************
* 僋儔僗偺奣梫:private a middle layer that connect add action to DAO
*
* @author 挘楉
* @version 1.0
*******************************************************************************
*/
public class AddActionService {
/*******************************************************************************
* 張棟撪梕偺奣梫:create a sql language that insert to emp table
*
* @param 堷悢:addActionForm
* @return 栠傝抣:String
* @exception ?忢丗null
*******************************************************************************
*/
public String logic_emp(AddActionForm addActionForm) {
String strSqlBegin = "insert into emp(";
String strSqlValues= " values(";
String strSql = "";
String id = addActionForm.getId();
if (id != null && !id.equals("")){
strSqlBegin += "id";
strSqlValues += "'" + id + "'";
}
String Name = addActionForm.getName();
if (Name != null && !Name.equals("")){
Name = CommonMethod.ChangeChar(Name);
strSqlBegin += ",Name";
strSqlValues += ",'" + Name +"'";
}
String Birth_year = addActionForm.getBirth_year();
String Birth_month= addActionForm.getBirth_month();
String Birth_day = addActionForm.getBirth_day();
if (Birth_year != null && !Birth_year.equals("")){
strSql = strSql + Birth_year
+ Birth_month
+ Birth_day;
strSqlBegin += ",Birthday";
strSqlValues += "," + "'"+Birth_year+"-" + Birth_month +"-" + Birth_day+"'";
}
String Sex = addActionForm.getSex();
if (Sex != null && !Sex.equals("")){
strSqlBegin += ",Sex";
strSqlValues += ",'" + Sex + "'";
}
String Grade = addActionForm.getGrade();
if (Grade != null && !Grade.equals("")){
strSqlBegin += ",Grade";
strSqlValues += ",'" + Grade + "'";
}
String Born_in = addActionForm.getBorn_in();
if (Born_in != null && !Born_in.equals("")){
Born_in = CommonMethod.ChangeChar(Born_in);
strSqlBegin += ",Born_in";
strSqlValues += ",'" + Born_in + "'";
}
String Polity = addActionForm.getPolity();
if (Polity != null && !Polity.equals("")){
strSqlBegin += ",Polity";
strSqlValues += ",'" + Polity + "'";
}
String Telephone = addActionForm.getTelephone();
if (Telephone != null && !Telephone.equals("")){
Telephone = CommonMethod.ChangeChar(Telephone);
strSqlBegin += ",Telephone";
strSqlValues += ",'" + Telephone + "'";
}
String Address = addActionForm.getAddress();
if (Address != null && !Address.equals("")){
Address = CommonMethod.ChangeChar(Address);
strSqlBegin += ",Address";
strSqlValues += ",'" + Address + "'";
}
String Number = addActionForm.getNumber();
if (Number != null && !Number.equals("")){
Number = CommonMethod.ChangeChar(Number);
strSqlBegin += ",Number";
strSqlValues += ",'" + Number + "'";
}
String Get_marry = addActionForm.getGet_marry();
if (Get_marry != null && !Get_marry.equals("")){
strSqlBegin += ",Get_marry";
strSqlValues += ",'" + Get_marry +"'";
}
String In_year = addActionForm.getIn_year();
String In_month= addActionForm.getIn_month();
String In_day = addActionForm.getIn_day();
if (In_year != null && !In_year.equals("")){
strSql = strSql + In_year
+ In_month
+ In_day;
strSqlBegin += ",In_time";
strSqlValues += "," + "'"+In_year+"-" + In_month +"-" + In_day+"'";
}
String Salary = addActionForm.getSalary();
if (Salary != null && !Salary.equals("")){
Salary = CommonMethod.ChangeChar(Salary);
strSqlBegin += ",Salary";
strSqlValues += ",'" + Salary + "'";
}
String Password = addActionForm.getPassword();
if (Password != null && !Password.equals("")){
Password = CommonMethod.ChangeChar(Password);
strSqlBegin += ",Password";
strSqlValues += ",'" + Password + "'";
}
String Guard = addActionForm.getGuard();
if (Guard != null && !Guard.equals("")){
strSqlBegin += ",Guard";
strSqlValues += ",'" + Guard + "'";
}
String Dep_ID = addActionForm.getDep_name();
if (Dep_ID != null && !Dep_ID.equals("")){
strSqlBegin += ",Dep_ID";
strSqlValues += ",'" + Dep_ID + "'";
}
//combin
strSqlBegin += ")";
strSqlValues += ")";
strSql = strSqlBegin + strSqlValues;
return strSql;
}
/*******************************************************************************
* 張棟撪梕偺奣梫:judge if this employer existed
*
* @param 堷悢:String employer's ID
* @return 栠傝抣:int 1 means not exist ,0 means exist
* @exception ?忢丗Exception
*******************************************************************************
*/
public int is_present (String ID) throws Exception {
UpdateDao updateDao = new UpdateDao();
int use = updateDao.is_present(ID);
return use;
}
/*******************************************************************************
* 張棟撪梕偺奣梫:update the database
*
* @param 堷悢:String SQL language
* @return 栠傝抣:void
* @exception ?忢丗Exception
*******************************************************************************
*/
public void update(String strSql) throws Exception {
UpdateDao updateDao = new UpdateDao();
updateDao.update(strSql);
}
/* public static void main(String[] args) {
AddActionForm addActionForm = new AddActionForm();
addActionForm.setID("112");
addActionForm.setName("zhangli");
addActionForm.setAddress("jiangsuwuxi");
addActionForm.setBorn_in("jilin");
addActionForm.setBirth_year("1982");
addActionForm.setBirth_month("10");
addActionForm.setBirth_day("10");
addActionForm.setSex("0");
addActionForm.setPassword("821010");
addActionForm.setTelephone("01010101");
addActionForm.setGuard("1");
addActionForm.setGrade("F");
addActionForm.setPolity("dangyuan");
addActionForm.setNumber("00000000");
addActionForm.setGet_marry("0");
addActionForm.setIn_year("2006");
addActionForm.setIn_month("07");
addActionForm.setIn_day("09");
addActionForm.setSalary("2000");
addActionForm.setDep_name("base");
addActionForm.setDep_ID("b1");
addActionForm.setManager("zhangbing");
AddActionService service = new AddActionService();
String sql = service.logic_emp(addActionForm);
String sql1= service.logic_dep(addActionForm);
System.out.println(sql);
System.out.println(sql1);
}*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -