日期:2014-05-20 浏览次数:20926 次
public static void AddNew(Employeea aEmployee)
{
Statement aStatement=null;
String strSQL;
strSQL="INSERT INTO Employees";
strSQL+=" (Address,BirthDate,Country,Extension,FirstName,LastName,HireDate,";
strSQL+=" HomePhone,Notes,PostalCode,Region,City,ReportsTO,Title,TitleOfCourtesy,photoPath)";
strSQL+=" VALUES (";
strSQL+="'"+ aEmployee.getAddress()+"'"+",";
strSQL+="'"+ aEmployee.getBirthDate()+"'"+",";
strSQL+="'"+ aEmployee.getCountry()+"'"+",";
strSQL+="'"+ aEmployee.getExtension()+"'"+",";
strSQL+="'"+ aEmployee.getFirstName()+"'"+",";
strSQL+="'"+ aEmployee.getLastName()+"'"+",";
strSQL+="'"+ aEmployee.getHireDate()+"'"+",";
strSQL+="'"+ aEmployee.getHomePhone()+"'"+",";
strSQL+="'"+ aEmployee.getNotes()+"'"+",";
strSQL+="'"+ aEmployee.getPostalCode()+"'"+",";
strSQL+="'"+ aEmployee.getRegion()+"'"+",";
strSQL+="'"+ aEmployee.getCity()+"'"+",";
strSQL+="'"+ aEmployee.getReportsTo()+"'"+",";
strSQL+="'"+ aEmployee.getTitle()+"'"+",";
strSQL+="'"+ aEmployee.getTitleOfCourtesy()+"'"+",";
strSQL+="'"+ aEmployee.getphotoPath()+"')";
try
{
getDBConnection();
aStatement.executeUpdate(strSQL);
i=Employees.size()-1;
}
catch(SQLException e)
{
JOptionPane.showMessageDialog(null,e.getMessage(),"ERROR",JOptionPane.ERROR_MESSAGE);
}
finally
{
closeStatement(aStatement);
closeConnection();
}
}