示例#1
0
        public bool AddStationVehicleContext(StationVehicleContext sv)
        {
            int rows;
            using (var com = new SqlCeCommand("INSERT INTO StanicaVoziloSet (Id, StanicaId, VoziloId, TimeOffset, PolazisnaStanicaId, Indeks)" +
                                              " VALUES(@Id, @StanicaId, @VoziloId, @TimeOffset, @PolazisnaStanicaId, @Indeks)", _connection))
            {
                int nextId = CalculateMaxId("StanicaVoziloSet") + 1;
                sv.Id = nextId < (int)Settings.Default["Id"] ? (int)Settings.Default["Id"] : nextId;

                com.Parameters.AddWithValue("@Id", sv.Id);
                com.Parameters.AddWithValue("@StanicaId", sv.StanicaId);
                com.Parameters.AddWithValue("@VoziloId", sv.VoziloId);
                com.Parameters.AddWithValue("@TimeOffset", sv.TimeOffset);
                com.Parameters.AddWithValue("@PolazisnaStanicaId", sv.PolazisnaStanicaId);
                com.Parameters.AddWithValue("@Indeks", sv.Index);
                rows = com.ExecuteNonQuery();
            }

            return rows > 0;
        }
示例#2
0
        public bool AddStationVehicleContext(StationVehicleContext sv)
        {
            int rows;

            using (var com = new SqlCeCommand("INSERT INTO StanicaVoziloSet (Id, StanicaId, VoziloId, TimeOffset, PolazisnaStanicaId, Indeks)" +
                                              " VALUES(@Id, @StanicaId, @VoziloId, @TimeOffset, @PolazisnaStanicaId, @Indeks)", _connection))
            {
                int nextId = CalculateMaxId("StanicaVoziloSet") + 1;
                sv.Id = nextId < (int)Settings.Default["Id"] ? (int)Settings.Default["Id"] : nextId;

                com.Parameters.AddWithValue("@Id", sv.Id);
                com.Parameters.AddWithValue("@StanicaId", sv.StanicaId);
                com.Parameters.AddWithValue("@VoziloId", sv.VoziloId);
                com.Parameters.AddWithValue("@TimeOffset", sv.TimeOffset);
                com.Parameters.AddWithValue("@PolazisnaStanicaId", sv.PolazisnaStanicaId);
                com.Parameters.AddWithValue("@Indeks", sv.Index);
                rows = com.ExecuteNonQuery();
            }

            return(rows > 0);
        }