예제 #1
0
        public void RemoveLocation(ContactBookLogic contactbooklogic, long countLocation, SQLConnection sql, int value)
        {
            var  CommandText = $"SELECT COUNT(l.LocationID) FROM locations l, contacts c WHERE {value} = c.LocationID AND {value} = l.LocationID;"; // check ob locationID von der zu löschenden location in contacts vorhanden ist - wenn ja -> nicht löschen
            long count       = sql.ExecuteScalar(CommandText);

            CommandText = $"SELECT * FROM locations WHERE LocationID = {value}";
            long c = sql.ExecuteScalar(CommandText);

            if (count == 0 && c > 0)
            {
                CommandText = $"DELETE FROM locations WHERE LocationID = {value};";
                sql.ExecuteNonQuery(CommandText);
                //TODOL: location successfully deleted message
            }
            //TODOL: all messages for : alternatives else 1. no location with index value found 2. you can not delete location that is associated to a contact 3. invalid input
        }
예제 #2
0
        //----------------------------------------REMOVE METHOD------------------------------------------------------------------------------

        public void RemoveContact(ContactBookLogic contactbooklogic, long countContact, SQLConnection sql, int value)
        {
            var CommandText = $"DELETE FROM contacts WHERE ContactID = '{value}';";

            sql.ExecuteNonQuery(CommandText);
            //TODOL: contact successfully deleted message + invalid input message
        }