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
|
public static int f_save_incidentMission(int id,int mission,java.lang.String nom, java.lang.String description, java.sql.Date dateincident, float cout,int nbjour)
throws SQLException
{
int out=0;
con = DriverManager.getConnection(ad.geturl(),ad.getidt(),ad.getmdp());
if(id <= 0)
{
if((nom == null) || (nom.isEmpty() == true))
throw new SQLException(ad.getexception(37));
if((description == null) || (description.isEmpty() == true))
throw new SQLException(ad.getexception(38));
if((dateincident == null))
throw new SQLException(ad.getexception(39));
st = con.prepareStatement("INSERT INTO incidentmission (mission, nom, description, dateincident,cout,nbjour) VALUES(?, ?, ?, ?, ?, ?);");
st.setInt(1, mission);
st.setString(2, nom);
st.setString(3, description);
st.setDate(4, dateincident);
st.setFloat(5, cout);
st.setInt(6, nbjour);
out= st.executeUpdate();
}else
{
if((nom == null) || (nom.isEmpty() == true))
throw new SQLException(ad.getexception(37));
if((description == null) || (description.isEmpty() == true))
throw new SQLException(ad.getexception(38));
if((dateincident == null))
st = con.prepareStatement("UPDATE incidentmission SET mission= ?, nom= ?, description= ?,dateincident= ?, cout= ?, nbjour=? WHERE id= ?");
st.setInt(1, mission);
st.setString(2, nom);
st.setString(3, description);
st.setDate(4, dateincident);
st.setFloat(5, cout);
st.setInt(6, nbjour);
st.setInt(7, id);
out= st.executeUpdate();
}
return out;
} |
Partager