public bool AddDepartureTimeContext(DepartureTimeContext vp) { int rows; using (var com = new SqlCeCommand("INSERT INTO VrijemePolaska (Id, StanicaId, VoziloId, VrijemePolaska, Dan) " + "VALUES(@Id, @StanicaId, @VoziloId, @VrijemePolaska, @Dan)", _connection)) { int nextId = CalculateMaxId("VrijemePolaska") + 1; vp.Id = nextId < (int)Settings.Default["Id"] ? (int)Settings.Default["Id"] : nextId; com.Parameters.AddWithValue("@Id", vp.Id); com.Parameters.AddWithValue("@StanicaId", vp.StanicaId); com.Parameters.AddWithValue("@VoziloId", vp.VoziloId); com.Parameters.AddWithValue("@VrijemePolaska", vp.Time); com.Parameters.AddWithValue("@Dan", vp.DayStatus); rows = com.ExecuteNonQuery(); } return rows > 0; }
public bool AddDepartureTimeContext(DepartureTimeContext vp) { int rows; using (var com = new SqlCeCommand("INSERT INTO VrijemePolaska (Id, StanicaId, VoziloId, VrijemePolaska, Dan) " + "VALUES(@Id, @StanicaId, @VoziloId, @VrijemePolaska, @Dan)", _connection)) { int nextId = CalculateMaxId("VrijemePolaska") + 1; vp.Id = nextId < (int)Settings.Default["Id"] ? (int)Settings.Default["Id"] : nextId; com.Parameters.AddWithValue("@Id", vp.Id); com.Parameters.AddWithValue("@StanicaId", vp.StanicaId); com.Parameters.AddWithValue("@VoziloId", vp.VoziloId); com.Parameters.AddWithValue("@VrijemePolaska", vp.Time); com.Parameters.AddWithValue("@Dan", vp.DayStatus); rows = com.ExecuteNonQuery(); } return(rows > 0); }