public int insertarTerrestres(string placa, int serialMotor, int capacidad, int peso, string descripcion, int serialCarroceria, string fechaCreacion, string tipo, int fkSucursal, int fkModelo) { NpgsqlConnection conn = DAOTerrestre.getInstanceDAO(); conn.Open(); String sql = "INSERT INTO \"Terrestre\" (\"Placa\", \"SerialMotor\", \"Capacidad\", " + "\"Peso\" ,\"Descripcion\", \"SerialCarroceria\", \"FechaCreacion\", \"Tipo\", " + " \"FK-SucursalT\", \"FK-ModeloT\") " + "VALUES ('" + placa + "','" + serialMotor + "','" + capacidad + "','" + peso + "'," + "'" + descripcion + "','" + serialCarroceria + "',TO_DATE('" + fechaCreacion + "', 'YYYY-MM-DD'), '" + tipo + "'," + " " + fkSucursal + ", " + fkModelo + ")"; NpgsqlCommand cmd = new NpgsqlCommand(sql, conn); try { int resp = cmd.ExecuteNonQuery(); //CONTROLAR EXCEPTION DE UNIQUE conn.Close(); return(resp); } catch (Exception e) { conn.Close(); return(0); } }
public static DAOTerrestre getInstance() { if (DAOTerrestre.c != null) { return(c); } else { c = new DAOTerrestre(); return(c); } }